1 13 package org.jahia.services.usermanager; 14 15 import org.jahia.data.JahiaDOMObject; 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.exceptions.JahiaInitializationException; 18 import org.jahia.services.JahiaInitializableService; 19 import org.jahia.settings.SettingsBean; 20 import org.jahia.utils.Base64; 21 22 import java.security.MessageDigest ; 23 import java.security.NoSuchAlgorithmException ; 24 import java.util.Properties ; 25 import java.util.Set ; 26 import java.util.Vector ; 27 28 29 38 public abstract class JahiaUserManagerService extends JahiaInitializableService { 39 44 public static final String GUEST_USERNAME = "guest"; 45 46 public abstract void init (SettingsBean jSettings) 47 throws JahiaInitializationException; 48 49 57 public abstract Vector getProviderList (); 58 59 69 public abstract JahiaUser createUser (String name, String password, 70 String userKey, int siteID, 71 Properties properties); 72 73 74 83 public abstract boolean deleteUser (JahiaUser user); 84 85 86 96 public abstract JahiaUser lookupUser (int siteID, String name); 97 98 99 106 public abstract JahiaUser lookupUser (String userKey); 107 108 109 119 public abstract boolean userExists (int siteID, String name); 120 121 127 public abstract Vector getUsernameList (int siteID); 128 129 130 131 137 public abstract Vector getUserList (int siteID); 138 139 145 public abstract Vector getUserList (); 146 147 148 156 public abstract boolean login (String userKey, String userPassword); 157 158 170 public static String encryptPassword (String password) { 171 172 if (password == null) { 173 return null; 174 } 175 176 if (password.length () == 0) { 177 return null; 178 } 179 180 String result = null; 181 182 try { 183 MessageDigest md = MessageDigest.getInstance ("SHA-1"); 184 if (md != null) { 185 md.reset (); 186 md.update (password.getBytes ()); 187 result = new String (Base64.encode (md.digest ())); 188 } 189 md = null; 190 } catch (NoSuchAlgorithmException ex) { 191 result = null; 192 } 193 194 return result; 195 } 196 197 198 204 public abstract int getNbUsers () 205 throws JahiaException; 206 207 213 public abstract int getNbUsers (int siteID) 214 throws JahiaException; 215 216 217 227 public abstract JahiaDOMObject getUsersAsDOM (String providerName, int siteID) 228 throws JahiaException; 229 230 231 241 public abstract JahiaDOMObject getUserPropsAsDOM (String providerName, int siteID) 242 throws JahiaException; 243 244 257 public abstract Set searchUsers (int siteID, Properties searchCriterias); 258 259 274 public abstract Set searchUsers (String providerKey, int siteID, 275 Properties searchCriterias); 276 277 283 public abstract void updateCache(JahiaUser jahiaUser); 284 285 } 286 | Popular Tags |