Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.uka.ipd.consensus.foundation.user
Interface UserManager

All Superinterfaces:
  ConsensusFoundationModule

All Known Implementing Classes:
  UserManagerImpl

public interface UserManager
extends ConsensusFoundationModule

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.

Version:
  2006-06-14
Author:
  Thomas Much
See Also:
  `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

### init

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

  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()`

### login

    public User login(String username,
                      String password)
               throws UserManagerException

  Loads a user by the given username and password and sets his status to "logged on".

  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

  Sets a user's status to "logged off".

  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

  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.

  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

  Changes an existing user account.

  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:
    `UserManagerInvalidUsernameException` - if the old password is wrong
    `UserManagerException` - if the user data could not be changed

### deleteUser

    public void deleteUser(User user,
                           String password)
                    throws UserManagerException

  Deletes a user account permanently from the user database.

  Parameters:
    `user` - the user account to be deleted
    `password` - the password for the account
  Throws:
    `UserManagerInvalidUsernameException` - if the password is wrong
    `UserManagerException` - if the user account could not be deleted

### getUsers

    public Iterator getUsers()
                      throws UserManagerException

  Returns all users in the user database.

  Returns:
    an Iterator over all User objects
  Throws:
    `UserManagerException` - if the users could not be read
  See Also:
    `User`

### getUserByUsername

    public User getUserByUsername(String username)
                           throws UserManagerException

  Returns a User with the given username.

  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

  Returns a User with the given id.

  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()`

### getRoles

    public Collection getRoles()

  Returns a collection of all UserRole objects that the UserManager provides.

  Returns:
    a collection of all UserRole objects
  See Also:
    `UserRole`

### findRole

    public UserRole findRole(String rolename)

  Returns a UserRole by the given name (e.g. "admin").

  Parameters:
    `rolename` - the name of the role to be returned
  Returns:
    the UserRole or `null` if no role with the given name exists

### addUserListener

    public void addUserListener(UserListener listener)

  Registers a new UserListener.

  Parameters:
    `listener` - the UserListener to be added

### removeUserListener

    public void removeUserListener(UserListener listener)

  Removes an UserListener, if it is registered with the UserManager (otherwise this call is ignored).

  Parameters:
    `listener` - the UserListener to be removed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD