📄 jahiausermanagerprovider.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//package org.jahia.services.usermanager;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Properties;import java.util.Vector;import java.util.Set;import org.jahia.data.JahiaDOMObject;import org.jahia.exceptions.JahiaException;import org.jahia.services.JahiaService;import org.jahia.utils.Base64;/** * The user manager is responsible to manage all the users in the Jahia * environment. * * blablabla .. sait pas quoi dire .... * * @author Fulco Houkes * @version 2.0 */public abstract class JahiaUserManagerProvider extends JahiaService{ /** Guest user unique identification name. * Each usermanager should create this special user, who is assigned * automatically for each anonymous session internally in Jahia. */ public static final String GUEST_USERNAME = "guest"; //------------------------------------------------------------------------- /** * This is the method that creates a new user in the system, with all the * specified attributes. * * @param username User identification name. * @param password User password * @param attributes User additional parameters. If the user has no additional * attributes, give a NULL pointer to this parameter. */ public abstract JahiaUser createUser (String name, String password, String userKey, int siteID, Properties properties); //------------------------------------------------------------------------- /** * This method removes a user from the system. All the user's attributes are * remove, and also all the related objects belonging to the user. On success, * true is returned and the user parameter is not longer valid. Return false * on any failure. * * @param user reference on the user to be deleted. */ public abstract boolean deleteUser (JahiaUser user); /** * Performs a login of the specified user. * @param userKey the user identifier defined in this service properties * @param userPassword the password of the user * @return boolean true if the login succeeded, false otherwise */ public abstract boolean login(String userKey, String userPassword); //------------------------------------------------------------------------- /** * Load all the user data and attributes. On success a reference on the user * is returned, otherwise NULL is returned. * * @param int site id * @param username User's identification name. * @return Return a reference on a new created jahiaUser object. */ public abstract JahiaUser lookupUser (int siteID, String name); //------------------------------------------------------------------------- /** * Load all the user data and attributes. On success a reference on the user * is returned, otherwise NULL is returned. * * @return Return a reference on a new created jahiaUser object. */ public abstract JahiaUser lookupUser (String userKey); //------------------------------------------------------------------------- /** * This function checks into the system if the username has already been * assigned to another user. * * @param username User login name. * @return Return true if the specified username has not been assigned yet, * return false on any failure. */ public abstract boolean userExists (int siteID, String name); //------------------------------------------------------------------------- /** * This method returns the list of all the user names registed into the system. * * @return Return a vector of strings holding the user identification names. */ public abstract Vector getUsernameList (int siteID); //------------------------------------------------------------------------- /** * This method returns the list of this site's users' keys. * * @return Return a vector of strings holding the user identification key . */ public abstract Vector getUserList (int siteID); //------------------------------------------------------------------------- /** * This method return all users' keys in the system. * * @return Return a vector of strings holding the user identification key . */ public abstract Vector getUserList (); /** * Find users according to a table of name=value properties. If the left * side value is "*" for a property then it will be tested against all the * properties. ie *=test* will match every property that starts with "test" * @param siteID site identifier * @param searchCriterias a Properties object that contains search criterias * in the format name,value (for example "*"="*" or "username"="*test*") or * null to search without criterias * @return Set a set of JahiaUser elements that correspond to those * search criterias */ public abstract Set searchUsers(int siteID, Properties searchCriterias); //-------------------------------------------------------------------------- // FH 29 Mar. 2001 // Initial implementation // /** * Encrypt the specified password using the SHA algorithm. * * @param password * String representation of a password. * * @return * Return a String representation of the password encryption. Return * null on any failure. */ public static String encryptPassword (String password) { if (password == null) { return null; } if (password.length() == 0) { return null; } String result = null; try { MessageDigest md = MessageDigest.getInstance ("SHA-1"); if (md != null) { md.reset (); md.update (password.getBytes()); result = new String(Base64.encode (md.digest())); } md = null; } catch (NoSuchAlgorithmException ex) { result = null; } return result; } //------------------------------------------------------------------------- /** * Return the number of user in the system. * * @return * Return the number of users in the system. */ public abstract int getNbUsers () throws JahiaException; //------------------------------------------------------------------------- /** * Return the number of user for a gived site * * @return * Return the number of users in the system. */ public abstract int getNbUsers (int siteID) throws JahiaException; //-------------------------------------------------------------------------- /** * return a DOM document of all users of a site * * @param int the site id * * @return JahiaDOMObject a DOM representation of this object * * @author NK */ public abstract JahiaDOMObject getUsersAsDOM( int siteID ) throws JahiaException; //-------------------------------------------------------------------------- /** * return a DOM document of all user props of a site * * @param int the site id * * @return JahiaDOMObject a DOM representation of this object * * @author NK */ public abstract JahiaDOMObject getUserPropsAsDOM( int siteID ) throws JahiaException; //-------------------------------------------------------------------------- /** * return a DOM document of all user group access for a site * * @param int the site id * * @return JahiaDOMObject a DOM representation of this object * * @author NK */ public abstract JahiaDOMObject getUserGroupAccessAsDOM( int siteID ) throws JahiaException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -