public class DefaultUserManager extends Object implements UserManager
createAccount(User, String)
createAccount -> addUser(User, String)
removeAccount(User)
-> removeUser(User)
store(User)
-> saveUser(User)
retrieve(String)
and retrieve(String, String)
-> getUser(String), getUser(String, String)
retrieveList(Object)
-> getAllUsers()
accountExists(String)
, accountExists(User)
-> checkExists(String), checkExists(User)
TurbineUserManager
interface are used by reference of the Fulcrum delegate umDelegate
and wrapped by this manager.Constructor and Description |
---|
DefaultUserManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
accountExists(String userName)
Check whether a specified user's account exists.
|
boolean |
accountExists(User user)
Check whether a specified user's account exists.
|
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.
|
void |
createAccount(User user,
String initialPassword)
Creates new user account with specified attributes.
|
void |
forcePassword(User user,
String password)
Forcibly sets new password for an User.
|
<A extends org.apache.fulcrum.security.acl.AccessControlList> |
getACL(User user)
Return a Class object representing the system's chosen implementation of
of ACL interface.
|
<U extends User> |
getAnonymousUser()
Constructs an User object to represent an anonymous user of the
application.
|
<U extends User> |
getUserInstance()
Construct a blank User object.
|
<U extends User> |
getUserInstance(String userName)
Construct a blank User object.
|
<U extends User> |
getUserWrapper(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
Exception could be ignored, as it is tested before in
init(Configuration) . |
String |
getUserWrapperClass()
Get the wrapper class for user objects
|
void |
init(org.apache.commons.configuration2.Configuration conf)
Initializes the UserManager
|
boolean |
isAnonymousUser(User u)
Checks whether a passed user object matches the anonymous user pattern
according to the configured user manager
|
void |
removeAccount(User user)
Removes an user account from the system.
|
<U extends User> |
retrieve(String username)
Retrieve a user from persistent storage using username as the
key.
|
<U extends User> |
retrieve(String username,
String password)
Retrieve a user from persistent storage using username as the
key, and authenticate the user.
|
List<? extends User> |
retrieveList(Object criteria)
Retrieve a set of users that meet the specified criteria.
|
void |
saveOnSessionUnbind(User user)
Saves User data when the session is unbound.
|
void |
setUserWrapperClass(String userWrapperClass2)
Set the wrapper class for user objects
|
void |
store(User user)
Save an User object to persistent storage.
|
protected <U extends User> |
wrap(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
Wrap a Fulcrum user object into a Turbine user object
|
public DefaultUserManager()
protected <U extends User> U wrap(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
U
- user classuser
- the user object to delegate topublic <U extends User> U getUserWrapper(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
init(Configuration)
.U
- user classuser
- the user object to wrapUser
public String getUserWrapperClass()
public void setUserWrapperClass(String userWrapperClass2)
userWrapperClass2
- the wrapper class namepublic void init(org.apache.commons.configuration2.Configuration conf) throws InitializationException
init
in interface UserManager
conf
- A Configuration object to init this ManagerInitializationException
- When something went wrong.public boolean accountExists(User user) throws org.apache.fulcrum.security.util.DataBackendException
accountExists
in interface UserManager
user
- The user to be checked.org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.public boolean accountExists(String userName) throws org.apache.fulcrum.security.util.DataBackendException
accountExists
in interface UserManager
userName
- The name of the user to be checked.org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.public <U extends User> U retrieve(String username) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
retrieve
in interface UserManager
U
- user classusername
- the name of the user.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public List<? extends User> retrieveList(Object criteria) throws org.apache.fulcrum.security.util.DataBackendException
User
interface, plus the names
of the custom attributes you added to your user representation
in the data storage. Use verbatim names of the attributes -
without table name prefix in case of DB implementation.retrieveList
in interface UserManager
criteria
- The criteria of selection.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public <U extends User> U retrieve(String username, String password) throws org.apache.fulcrum.security.util.PasswordMismatchException, org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
retrieve
in interface UserManager
U
- user classusername
- the name of the user.password
- the user supplied password.org.apache.fulcrum.security.util.PasswordMismatchException
- if the supplied password was
incorrect.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public void store(User user) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
store
in interface UserManager
user
- an User object to store.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public void saveOnSessionUnbind(User user) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
saveOnSessionUnbind
in interface UserManager
user
- the user in the sessionorg.apache.fulcrum.security.util.UnknownEntityException
- if the user's account does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public void authenticate(User user, String password) throws org.apache.fulcrum.security.util.PasswordMismatchException, org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
authenticate
in interface UserManager
user
- an User object to authenticate.password
- the user supplied password.org.apache.fulcrum.security.util.PasswordMismatchException
- if the supplied password was
incorrect.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public void createAccount(User user, String initialPassword) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.EntityExistsException, org.apache.fulcrum.security.util.DataBackendException
createAccount
in interface UserManager
user
- the object describing account to be created.initialPassword
- The password to use for the object creationorg.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.org.apache.fulcrum.security.util.EntityExistsException
- if the user account already exists.org.apache.fulcrum.security.util.UnknownEntityException
- if the user account cannot be created.public void removeAccount(User user) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
removeAccount
in interface UserManager
user
- the object describing the account to be removed.org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.org.apache.fulcrum.security.util.UnknownEntityException
- if the user account is not present.public void changePassword(User user, String oldPassword, String newPassword) throws org.apache.fulcrum.security.util.PasswordMismatchException, org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
changePassword
in interface UserManager
user
- an User to change password for.oldPassword
- the current password supplied by the user.newPassword
- the current password requested by the user.org.apache.fulcrum.security.util.PasswordMismatchException
- if the supplied password was
incorrect.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public void forcePassword(User user, String password) throws org.apache.fulcrum.security.util.UnknownEntityException, org.apache.fulcrum.security.util.DataBackendException
forcePassword
in interface UserManager
user
- an User to change password for.password
- the new password.org.apache.fulcrum.security.util.UnknownEntityException
- if the user's record does not
exist in the database.org.apache.fulcrum.security.util.DataBackendException
- if there is a problem accessing the
storage.public <U extends User> U getAnonymousUser() throws org.apache.fulcrum.security.util.UnknownEntityException
getAnonymousUser
in interface UserManager
U
- user classorg.apache.fulcrum.security.util.UnknownEntityException
- if the anonymous User object couldn't be constructed.public boolean isAnonymousUser(User u)
isAnonymousUser
in interface UserManager
u
- a user objectpublic <U extends User> U getUserInstance() throws org.apache.fulcrum.security.util.DataBackendException
getUserInstance
in interface UserManager
U
- user classorg.apache.fulcrum.security.util.DataBackendException
- if the object could not be instantiated.public <U extends User> U getUserInstance(String userName) throws org.apache.fulcrum.security.util.DataBackendException
getUserInstance
in interface UserManager
U
- user classuserName
- The name of the user.org.apache.fulcrum.security.util.DataBackendException
- if the object could not be instantiated.public <A extends org.apache.fulcrum.security.acl.AccessControlList> A getACL(User user) throws org.apache.fulcrum.security.util.UnknownEntityException
getACL
in interface UserManager
A
- ACL classuser
- the userorg.apache.fulcrum.security.util.UnknownEntityException
- if the implementation of ACL interface could not be
determined, or does not exist.Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.