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
- Direct Known Subclasses:
MemoryUserManagerImpl
,TorqueAbstractUserManager
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$
- Author:
- Eric Pugh
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.fulcrum.security.spi.AbstractManager
manager
-
Fields inherited from interface org.apache.fulcrum.security.UserManager
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractUserManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends User>
TaddUser(T user, String password)
Creates new user account with specified attributes.void
authenticate(User user, String password)
Authenticate an User with the specified password.void
changePassword(User user, String oldPassword, String newPassword)
Change the password for an User.boolean
checkExists(User user)
Check whether a specified user's account exists.void
forcePassword(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.ACLFactory
getACLFactory()
<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, setClassName
-
Methods inherited from class org.apache.fulcrum.security.spi.AbstractManager
dispose, getGroupManager, getPermissionManager, getRoleManager, getServiceManager, getUserManager, release, resolve, service
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.fulcrum.security.UserManager
checkExists, getAllUsers, removeUser, saveUser
-
-
-
-
Constructor Detail
-
AbstractUserManager
public AbstractUserManager()
-
-
Method Detail
-
persistNewUser
protected abstract <T extends User> T persistNewUser(T user) throws DataBackendException
- Type Parameters:
T
- User type- Parameters:
user
- user to persist- Returns:
- a User object
- Throws:
DataBackendException
- if fail to connect
-
getACL
public <T extends AccessControlList> T getACL(User user) throws UnknownEntityException
Description copied from interface:UserManager
Return a Class object representing the system's chosen implementation of of ACL interface.- Specified by:
getACL
in 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
public boolean checkExists(User user) throws DataBackendException
Check whether a specified user's account exists. The login name is used for looking up the account.- Specified by:
checkExists
in 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, DataBackendException
Retrieve 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:
getUser
in 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
public <T extends User> T getUser(String name) throws DataBackendException, UnknownEntityException
Description copied from interface:UserManager
Retrieve a user from persistent storage using username as the key.- Specified by:
getUser
in 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, UnknownEntityException
Retrieve a User object with specified Id.- Specified by:
getUserById
in 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, DataBackendException
Authenticate an User with the specified password. If authentication is successful the method returns nothing. If there are any problems, exception was thrown.- Specified by:
authenticate
in 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, DataBackendException
Change the password for an User. The user must have supplied the old password to allow the change.- Specified by:
changePassword
in 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, DataBackendException
Forcibly 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:
forcePassword
in 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
public <T extends User> T getUserInstance() throws DataBackendException
Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.- Specified by:
getUserInstance
in interfaceUserManager
- Type Parameters:
T
- User type- Returns:
- an object implementing User interface.
- Throws:
DataBackendException
- if the object could not be instantiated.
-
getUserInstance
public <T extends User> T getUserInstance(String userName) throws DataBackendException
Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.- Specified by:
getUserInstance
in 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, EntityExistsException
Creates new user account with specified attributes.- Specified by:
addUser
in 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
public ACLFactory getACLFactory()
- Returns:
- Returns the ACLFactory.
-
-