Package org.apache.fulcrum.security.spi
Class AbstractUserManager
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.security.spi.AbstractManager
org.apache.fulcrum.security.spi.AbstractEntityManager
org.apache.fulcrum.security.spi.AbstractUserManager
- All Implemented Interfaces:
Serializable,org.apache.avalon.framework.activity.Disposable,org.apache.avalon.framework.configuration.Configurable,org.apache.avalon.framework.logger.LogEnabled,org.apache.avalon.framework.service.Serviceable,org.apache.avalon.framework.thread.ThreadSafe,UserManager
public abstract class AbstractUserManager extends AbstractEntityManager implements UserManager
This implementation keeps all objects in memory. This is mostly meant to help
with testing and prototyping of ideas.
- Version:
- $Id: AbstractUserManager.java 1845858 2018-11-05 21:14:02Z painter $
- Author:
- Eric Pugh
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractUserManager() -
Method Summary
Modifier and Type Method Description <T extends User>
TaddUser(T user, String password)Creates new user account with specified attributes.voidauthenticate(User user, String password)Authenticate an User with the specified password.voidchangePassword(User user, String oldPassword, String newPassword)Change the password for an User.booleancheckExists(User user)Check whether a specified user's account exists.voidforcePassword(User user, String password)Forcibly sets new password for an User.<T extends AccessControlList>
TgetACL(User user)Return a Class object representing the system's chosen implementation of of ACL interface.ACLFactorygetACLFactory()<T extends User>
TgetUser(String name)Retrieve a user from persistent storage using username as the key.<T extends User>
TgetUser(String userName, String password)Retrieve a user from persistent storage using username as the key, and authenticate the user.<T extends User>
TgetUserById(Object id)Retrieve a User object with specified Id.<T extends User>
TgetUserInstance()Construct a blank User object.<T extends User>
TgetUserInstance(String userName)Construct a blank User object.protected abstract <T extends User>
TpersistNewUser(T user)Methods inherited from class org.apache.fulcrum.security.spi.AbstractEntityManager
configure, getClassName, setClassNameMethods inherited from class org.apache.fulcrum.security.spi.AbstractManager
dispose, getGroupManager, getPermissionManager, getRoleManager, getServiceManager, getUserManager, release, resolve, serviceMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.fulcrum.security.UserManager
checkExists, getAllUsers, removeUser, saveUser
-
Constructor Details
-
AbstractUserManager
public AbstractUserManager()
-
-
Method Details
-
persistNewUser
- Type Parameters:
T- User type- Parameters:
user- user to persist- Returns:
- a User object
- Throws:
DataBackendException- if fail to connect
-
getACL
Description copied from interface:UserManagerReturn a Class object representing the system's chosen implementation of of ACL interface.- Specified by:
getACLin interfaceUserManager- Type Parameters:
T- AccessControlList- Parameters:
user- the user- Returns:
- systems's chosen implementation of ACL interface.
- Throws:
UnknownEntityException- if the implementation of ACL interface could not be determined, or does not exist.
-
checkExists
Check whether a specified user's account exists. The login name is used for looking up the account.- Specified by:
checkExistsin interfaceUserManager- Parameters:
user- The user to be checked.- Returns:
- true if the specified account exists
- Throws:
DataBackendException- if there was an error accessing the data backend.
-
getUser
public <T extends User> T getUser(String userName, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendExceptionRetrieve a user from persistent storage using username as the key, and authenticate the user. The implementation may chose to authenticate to the server as the user whose data is being retrieved.- Specified by:
getUserin interfaceUserManager- Type Parameters:
T- User- Parameters:
userName- the name of the user.password- the user supplied password.- Returns:
- an User object.
- Throws:
PasswordMismatchException- if the supplied password was incorrect.UnknownEntityException- if the user's account does not exist in the database.DataBackendException- if there is a problem accessing the storage.
-
getUser
Description copied from interface:UserManagerRetrieve a user from persistent storage using username as the key.- Specified by:
getUserin interfaceUserManager- Type Parameters:
T- User- Parameters:
name- the name of the user.- Returns:
- an User object.
- Throws:
DataBackendException- if there is a problem accessing the storage.UnknownEntityException- if the user's record does not exist in the database.
-
getUserById
public <T extends User> T getUserById(Object id) throws DataBackendException, UnknownEntityExceptionRetrieve a User object with specified Id.- Specified by:
getUserByIdin interfaceUserManager- Type Parameters:
T- User- Parameters:
id- the id of the User.- Returns:
- an object representing the User with specified id.
- Throws:
UnknownEntityException- if the user does not exist in the database.DataBackendException- if there is a problem accessing the storage.
-
authenticate
public void authenticate(User user, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendExceptionAuthenticate an User with the specified password. If authentication is successful the method returns nothing. If there are any problems, exception was thrown.- Specified by:
authenticatein interfaceUserManager- Parameters:
user- an User object to authenticate.password- the user supplied password.- Throws:
PasswordMismatchException- if the supplied password was incorrect.UnknownEntityException- if the user's account does not exist in the database.DataBackendException- if there is a problem accessing the storage.
-
changePassword
public void changePassword(User user, String oldPassword, String newPassword) throws PasswordMismatchException, UnknownEntityException, DataBackendExceptionChange the password for an User. The user must have supplied the old password to allow the change.- Specified by:
changePasswordin interfaceUserManager- Parameters:
user- an User to change password for.oldPassword- The old password to verifynewPassword- The new password to set- Throws:
PasswordMismatchException- if the supplied password was incorrect.UnknownEntityException- if the user's account does not exist in the database.DataBackendException- if there is a problem accessing the storage.
-
forcePassword
public void forcePassword(User user, String password) throws UnknownEntityException, DataBackendExceptionForcibly sets new password for an User. This is supposed by the administrator to change the forgotten or compromised passwords. Certain implementatations of this feature would require administrative level access to the authenticating server / program.- Specified by:
forcePasswordin interfaceUserManager- Parameters:
user- an User to change password for.password- the new password.- Throws:
UnknownEntityException- if the user's record does not exist in the database.DataBackendException- if there is a problem accessing the storage.
-
getUserInstance
Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.- Specified by:
getUserInstancein interfaceUserManager- Type Parameters:
T- User type- Returns:
- an object implementing User interface.
- Throws:
DataBackendException- if the object could not be instantiated.
-
getUserInstance
Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.- Specified by:
getUserInstancein interfaceUserManager- Type Parameters:
T- User- Parameters:
userName- The name of the user.- Returns:
- an object implementing User interface.
- Throws:
DataBackendException- if the object could not be instantiated.
-
addUser
public <T extends User> T addUser(T user, String password) throws DataBackendException, EntityExistsExceptionCreates new user account with specified attributes.- Specified by:
addUserin interfaceUserManager- Parameters:
user- the object describing account to be created.password- The password to use for the account.- Returns:
- User the user added
- Throws:
DataBackendException- if there was an error accessing the data backend.EntityExistsException- if the user account already exists.
-
getACLFactory
- Returns:
- Returns the ACLFactory.
-