|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The UserManager manages the user database (creating/changing/deleting of user accounts etc.). It is also responsible for the roles that can be assigned to users.
The UserManager implementation can be configured with the key cf.usermanager
in the ConsensusFoundation.properties
configuration file. It's a core component and not optional.
The implementation is loaded by the ConsensusFoundation
constructor. For successful instantiation,
the UserManager implementation must provide a default constructor without arguments.
ConsensusFoundation
Method Summary | |
void |
addUserListener(UserListener listener)
Registers a new UserListener. |
void |
changeUser(User user,
String oldPassword,
String newPassword,
Map data)
Changes an existing user account. |
User |
createUser(String username,
String password,
Map data)
Creates a new user accout with the given username and password, and sets the new user's status to "logged on". |
void |
deleteUser(User user,
String password)
Deletes a user account permanently from the user database. |
UserRole |
findRole(String rolename)
Returns a UserRole by the given name (e.g. |
Collection |
getRoles()
Returns a collection of all UserRole objects that the UserManager provides. |
User |
getUserById(String userid)
Returns a User with the given id. |
User |
getUserByUsername(String username)
Returns a User with the given username. |
Iterator |
getUsers()
Returns all users in the user database. |
void |
init(Properties config,
LoggingManager logging)
This method is called by the ConsensusFoundation constructor to initialize the UserManager.
|
User |
login(String username,
String password)
Loads a user by the given username and password and sets his status to "logged on". |
void |
logout(User user)
Sets a user's status to "logged off". |
void |
removeUserListener(UserListener listener)
Removes an UserListener, if it is registered with the UserManager (otherwise this call is ignored). |
Methods inherited from interface de.uka.ipd.consensus.foundation.ConsensusFoundationModule |
getConsensusFoundationManager, getVersion, initCompleted, shutdown |
Method Detail |
public void init(Properties config, LoggingManager logging) throws Exception
This method is called by the ConsensusFoundation
constructor to initialize the UserManager.
The UserManager should create default user roles here (e.g. an admin role).
config
- all entries from ConsensusFoundation.properties
logging
- the successfully initialized LoggingManager instance
Exception
- if any error occurs (startup of the application is aborted in this case)ConsensusFoundation.ConsensusFoundation()
public User login(String username, String password) throws UserManagerException
username
- the username for the user to be loaded and logged onpassword
- the password for the username
UserManagerException
- if the username does not exist or the password is wrongUser.isLoggedOn()
public void logout(User user) throws UserManagerException
user
- the user to be logged off
UserManagerException
- if the user isn't logged onUser.isLoggedOn()
public User createUser(String username, String password, Map data) throws UserManagerException
An implementation can define keys for passing additional user information (first name, last name, e-mail address etc.) in the data map.
username
- the username for the new user accountpassword
- the password for the usernamedata
- implementation-specific data
UserManagerException
- if the username is invalid or already in usepublic void changeUser(User user, String oldPassword, String newPassword, Map data) throws UserManagerException
user
- the User object to be changedoldPassword
- the old password or null
if the password is not to be changednewPassword
- a new password or null
if the password is not to be changeddata
- implementation-specific data (e.g. for the real name and e-mail address)
UserManagerInvalidUsernameException
- if the old password is wrong
UserManagerException
- if the user data could not be changedpublic void deleteUser(User user, String password) throws UserManagerException
user
- the user account to be deletedpassword
- the password for the account
UserManagerInvalidUsernameException
- if the password is wrong
UserManagerException
- if the user account could not be deletedpublic Iterator getUsers() throws UserManagerException
UserManagerException
- if the users could not be readUser
public User getUserByUsername(String username) throws UserManagerException
username
- the username of the user to be returned
null
if no user with the given username exists
UserManagerException
- if the user data could not be readUser.getUsername()
public User getUserById(String userid) throws UserManagerException
userid
- the id of the user to be returned
null
if no user with the given id exists
UserManagerException
- if the user data could not be readUser.getId()
public Collection getRoles()
UserRole
public UserRole findRole(String rolename)
rolename
- the name of the role to be returned
null
if no role with the given name existspublic void addUserListener(UserListener listener)
listener
- the UserListener to be addedpublic void removeUserListener(UserListener listener)
listener
- the UserListener to be removed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |