de.uka.ipd.consensus.impl
Class UserManagerImpl

java.lang.Object
  extended byde.uka.ipd.consensus.foundation.AbstractConsensusFoundationModule
      extended byde.uka.ipd.consensus.impl.UserManagerImpl
All Implemented Interfaces:
ConsensusFoundationManager, ConsensusFoundationModule, UserManager

public class UserManagerImpl
extends AbstractConsensusFoundationModule
implements UserManager

TODO

Version:
2006-06-14
Author:
Thomas Much

Field Summary
static String ROLE_ADMIN
           
static String ROLE_SUPERADMIN
           
static String USERDATA_COMMENT_KEY
           
static String USERDATA_EMAIL_KEY
           
static String USERDATA_FIRSTNAME_KEY
           
static String USERDATA_LASTNAME_KEY
           
 
Constructor Summary
UserManagerImpl()
           
 
Method Summary
 void addUserListener(UserListener listener)
          Registers a new UserListener.
protected  void assignSystemRoles(User user)
           
 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.
protected  void fireUserCreated(User user)
           
protected  void fireUserLoggedIn(User user)
           
protected  void fireUserLoggedOut(User user)
           
 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.
 String getVersion()
          Returns a version string of the implementation of this module.
 void init(Properties config, LoggingManager logging)
          This method is called by the ConsensusFoundation constructor to initialize the UserManager.
 void initCompleted(Properties config, ConsensusFoundationManager cfm)
          This method is called by the ConsensusFoundation constructor after all available modules have been initialized (i.e. their init() method has been called).
protected  void loadUserData(UserImpl user)
           
 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).
protected  void saveUserComment(User user)
           
protected  void saveUserRoles(User user)
           
protected  void saveUserScore(User user)
           
 void shutdown()
          Called by ConsensusFoundation.shutdown() when the application shuts down.
 
Methods inherited from class de.uka.ipd.consensus.foundation.AbstractConsensusFoundationModule
finalize, getConsensusFoundationManager, getDynamicRightsManager, getEvolutionManager, getIncentiveManager, getLoggingManager, getOntologyManager, getRatingManager, getUserManager
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.uka.ipd.consensus.foundation.ConsensusFoundationModule
getConsensusFoundationManager
 

Field Detail

USERDATA_FIRSTNAME_KEY

public static final String USERDATA_FIRSTNAME_KEY
See Also:
Constant Field Values

USERDATA_LASTNAME_KEY

public static final String USERDATA_LASTNAME_KEY
See Also:
Constant Field Values

USERDATA_EMAIL_KEY

public static final String USERDATA_EMAIL_KEY
See Also:
Constant Field Values

USERDATA_COMMENT_KEY

public static final String USERDATA_COMMENT_KEY
See Also:
Constant Field Values

ROLE_SUPERADMIN

public static final String ROLE_SUPERADMIN
See Also:
Constant Field Values

ROLE_ADMIN

public static final String ROLE_ADMIN
See Also:
Constant Field Values
Constructor Detail

UserManagerImpl

public UserManagerImpl()
Method Detail

init

public void init(Properties config,
                 LoggingManager logging)
          throws Exception
Description copied from interface: UserManager

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).

Specified by:
init in interface UserManager
Parameters:
config - all entries from ConsensusFoundation.properties
logging - the successfully initialized LoggingManager instance
Throws:
Exception - if any error occurs (startup of the application is aborted in this case)
See Also:
ConsensusFoundation.ConsensusFoundation()

initCompleted

public void initCompleted(Properties config,
                          ConsensusFoundationManager cfm)
                   throws Exception
Description copied from interface: ConsensusFoundationModule
This method is called by the ConsensusFoundation constructor after all available modules have been initialized (i.e. their init() method has been called). Here a module can perform some final initialization that is dependant on other modules.

Specified by:
initCompleted in interface ConsensusFoundationModule
Overrides:
initCompleted in class AbstractConsensusFoundationModule
Throws:
Exception

shutdown

public void shutdown()
Description copied from interface: ConsensusFoundationModule
Called by ConsensusFoundation.shutdown() when the application shuts down.

When implementing this method make sure that the shutdown code is executed only once even if this method is called multiple times.

Specified by:
shutdown in interface ConsensusFoundationModule
Overrides:
shutdown in class AbstractConsensusFoundationModule

login

public User login(String username,
                  String password)
           throws UserManagerException
Description copied from interface: UserManager
Loads a user by the given username and password and sets his status to "logged on".

Specified by:
login in interface UserManager
Parameters:
username - the username for the user to be loaded and logged on
password - the password for the username
Returns:
the User object loaded from the user database
Throws:
UserManagerException - if the username does not exist or the password is wrong
See Also:
User.isLoggedOn()

logout

public void logout(User user)
            throws UserManagerException
Description copied from interface: UserManager
Sets a user's status to "logged off".

Specified by:
logout in interface UserManager
Parameters:
user - the user to be logged off
Throws:
UserManagerException - if the user isn't logged on
See Also:
User.isLoggedOn()

createUser

public User createUser(String username,
                       String password,
                       Map data)
                throws UserManagerException
Description copied from interface: UserManager
Creates a new user accout with the given username and password, and sets the new user's status to "logged on".

An implementation can define keys for passing additional user information (first name, last name, e-mail address etc.) in the data map.

Specified by:
createUser in interface UserManager
Parameters:
username - the username for the new user account
password - the password for the username
data - implementation-specific data
Returns:
the newly created user
Throws:
UserManagerException - if the username is invalid or already in use

changeUser

public void changeUser(User user,
                       String oldPassword,
                       String newPassword,
                       Map data)
                throws UserManagerException
Description copied from interface: UserManager
Changes an existing user account.

Specified by:
changeUser in interface UserManager
Parameters:
user - the User object to be changed
oldPassword - the old password or null if the password is not to be changed
newPassword - a new password or null if the password is not to be changed
data - implementation-specific data (e.g. for the real name and e-mail address)
Throws:
UserManagerException - if the user data could not be changed

deleteUser

public void deleteUser(User user,
                       String password)
                throws UserManagerException
Description copied from interface: UserManager
Deletes a user account permanently from the user database.

Specified by:
deleteUser in interface UserManager
Parameters:
user - the user account to be deleted
password - the password for the account
Throws:
UserManagerException - if the user account could not be deleted

getUserByUsername

public User getUserByUsername(String username)
                       throws UserManagerException
Description copied from interface: UserManager
Returns a User with the given username.

Specified by:
getUserByUsername in interface UserManager
Parameters:
username - the username of the user to be returned
Returns:
the User object with the given username or null if no user with the given username exists
Throws:
UserManagerException - if the user data could not be read
See Also:
User.getUsername()

getUserById

public User getUserById(String userid)
                 throws UserManagerException
Description copied from interface: UserManager
Returns a User with the given id.

Specified by:
getUserById in interface UserManager
Parameters:
userid - the id of the user to be returned
Returns:
the User object with the given id or null if no user with the given id exists
Throws:
UserManagerException - if the user data could not be read
See Also:
User.getId()

findRole

public UserRole findRole(String rolename)
Description copied from interface: UserManager
Returns a UserRole by the given name (e.g. "admin").

Specified by:
findRole in interface UserManager
Parameters:
rolename - the name of the role to be returned
Returns:
the UserRole or null if no role with the given name exists

getRoles

public Collection getRoles()
Description copied from interface: UserManager
Returns a collection of all UserRole objects that the UserManager provides.

Specified by:
getRoles in interface UserManager
Returns:
a collection of all UserRole objects
See Also:
UserRole

assignSystemRoles

protected void assignSystemRoles(User user)

addUserListener

public void addUserListener(UserListener listener)
Description copied from interface: UserManager
Registers a new UserListener.

Specified by:
addUserListener in interface UserManager
Parameters:
listener - the UserListener to be added

removeUserListener

public void removeUserListener(UserListener listener)
Description copied from interface: UserManager
Removes an UserListener, if it is registered with the UserManager (otherwise this call is ignored).

Specified by:
removeUserListener in interface UserManager
Parameters:
listener - the UserListener to be removed

fireUserLoggedIn

protected void fireUserLoggedIn(User user)

fireUserLoggedOut

protected void fireUserLoggedOut(User user)

fireUserCreated

protected void fireUserCreated(User user)

saveUserScore

protected void saveUserScore(User user)

saveUserComment

protected void saveUserComment(User user)

saveUserRoles

protected void saveUserRoles(User user)

loadUserData

protected void loadUserData(UserImpl user)

getVersion

public String getVersion()
Description copied from interface: ConsensusFoundationModule
Returns a version string of the implementation of this module.

Specified by:
getVersion in interface ConsensusFoundationModule
Returns:
the version of the module's implementation

getUsers

public Iterator getUsers()
                  throws UserManagerException
Description copied from interface: UserManager
Returns all users in the user database.

Specified by:
getUsers in interface UserManager
Returns:
an Iterator over all User objects
Throws:
UserManagerException - if the users could not be read
See Also:
User