1 13 package org.jahia.services.usermanager; 14 15 import org.jahia.data.JahiaDOMObject; 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.services.JahiaService; 18 import org.jahia.utils.Base64; 19 20 import java.security.MessageDigest ; 21 import java.security.NoSuchAlgorithmException ; 22 import java.util.Properties ; 23 import java.util.Set ; 24 import java.util.Vector ; 25 26 27 35 public abstract class JahiaUserManagerProvider extends JahiaService { 36 41 public static final String GUEST_USERNAME = "guest"; 42 43 44 54 public abstract JahiaUser createUser (String name, String password, String userKey, int siteID, 55 Properties properties); 56 57 58 67 public abstract boolean deleteUser (JahiaUser user); 68 69 70 78 public abstract boolean login (String userKey, String userPassword); 79 80 90 public abstract JahiaUser lookupUser (int siteID, String name); 91 92 public abstract JahiaUser lookupUser (String name, String searchAttributeName); 93 94 101 public abstract JahiaUser lookupUser (String userKey); 102 103 104 114 public abstract boolean userExists (int siteID, String name); 115 116 122 public abstract Vector getUsernameList (int siteID); 123 124 125 126 132 public abstract Vector getUserList (int siteID); 133 134 140 public abstract Vector getUserList (); 141 142 143 156 public abstract Set searchUsers (int siteID, Properties searchCriterias); 157 158 159 171 public static String encryptPassword (String password) { 172 173 if (password == null) { 174 return null; 175 } 176 177 if (password.length () == 0) { 178 return null; 179 } 180 181 String result = null; 182 183 try { 184 MessageDigest md = MessageDigest.getInstance ("SHA-1"); 185 if (md != null) { 186 md.reset (); 187 md.update (password.getBytes ()); 188 result = new String (Base64.encode (md.digest ())); 189 } 190 md = null; 191 } catch (NoSuchAlgorithmException ex) { 192 result = null; 193 } 194 195 return result; 196 } 197 198 199 205 public abstract int getNbUsers () 206 throws JahiaException; 207 208 214 public abstract int getNbUsers (int siteID) 215 throws JahiaException; 216 217 218 228 public abstract JahiaDOMObject getUsersAsDOM (int siteID) 229 throws JahiaException; 230 231 232 242 public abstract JahiaDOMObject getUserPropsAsDOM (int siteID) 243 throws JahiaException; 244 245 251 public abstract void updateCache(JahiaUser jahiaUser); 252 253 } 254 | Popular Tags |