org.apache.turbine.services.security

## Interface UserManager

- All Known Implementing Classes:
    DefaultUserManager, PassiveUserManager

      public interface UserManager

  An UserManager performs `User` objects related tasks on behalf of the `DefaultSecurityService`. The responsibilities of this class include loading data of an user from the storage and putting them into the `User` objects, saving those data to the permanent storage, and authenticating users.
  Version:
    $Id: UserManager.java 1706239 2015-10-01 13:18:35Z tv $
  Author:
    Rafal Krzewski, Henning P. Schmiedehausen

- - ### Method Summary

    Methods
    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.
    `<T extends org.apache.fulcrum.security.acl.AccessControlList> T` | `getACL(User user)` Return a Class object representing the system's chosen implementation of of ACL interface for the given user
    `<T extends User> T` | `getAnonymousUser()` Constructs an User object to represent an anonymous user of the application.
    `<T extends User> T` | `getUserInstance()` Construct a blank User object.
    `<T extends User> T` | `getUserInstance(String userName)` Construct a blank User object.
    `void` | `init(org.apache.commons.configuration.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> U` | `retrieve(String username)` Retrieve a user from persistent storage using username as the key.
    `<U extends User> U` | `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 list of users that meet the specified criteria.
    `void` | `saveOnSessionUnbind(User user)` Saves User data when the session is unbound.
    `void` | `store(User user)` Save an User object to persistent storage.

- - ### Method Detail

    - #### init

          void init(org.apache.commons.configuration.Configuration conf)
                    throws InitializationException

      Initializes the UserManager
      Parameters:
        `conf` - A Configuration object to init this Manager
      Throws:
        `InitializationException` - When something went wrong.

    - #### accountExists

          boolean accountExists(User user)
                                throws org.apache.fulcrum.security.util.DataBackendException

      Check whether a specified user's account exists. The login name is used for looking up the account.
      Parameters:
        `user` - The user to be checked.
      Returns:
        true if the specified account exists
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if there was an error accessing the data backend.

    - #### accountExists

          boolean accountExists(String userName)
                                throws org.apache.fulcrum.security.util.DataBackendException

      Check whether a specified user's account exists. The login name is used for looking up the account.
      Parameters:
        `userName` - The name of the user to be checked.
      Returns:
        true if the specified account exists
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if there was an error accessing the data backend.

    - #### retrieve

          <U extends User> U retrieve(String username)
                                  throws org.apache.fulcrum.security.util.UnknownEntityException,
                                         org.apache.fulcrum.security.util.DataBackendException

      Retrieve a user from persistent storage using username as the key.
      Parameters:
        `username` - the name of the user.
      Returns:
        an User object.
      Throws:
        `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.

    - #### retrieveList

          List<? extends User> retrieveList(Object criteria)
                                            throws org.apache.fulcrum.security.util.DataBackendException

      Retrieve a list of users that meet the specified criteria. As the keys for the criteria, you should use the constants that are defined in `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.
      Parameters:
        `criteria` - The criteria of selection.
      Returns:
        a List of users meeting the criteria.
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if there is a problem accessing the storage.

    - #### retrieve

          <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 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.
      Parameters:
        `username` - the name of the user.
        `password` - the user supplied password.
      Returns:
        an User object.
      Throws:
        `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.

    - #### store

          void store(User user)
                     throws org.apache.fulcrum.security.util.UnknownEntityException,
                            org.apache.fulcrum.security.util.DataBackendException

      Save an User object to persistent storage. User's record is required to exist in the storage.
      Parameters:
        `user` - an User object to store.
      Throws:
        `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.

    - #### saveOnSessionUnbind

          void saveOnSessionUnbind(User user)
                                   throws org.apache.fulcrum.security.util.UnknownEntityException,
                                          org.apache.fulcrum.security.util.DataBackendException

      Saves User data when the session is unbound. The user account is required to exist in the storage. LastLogin, AccessCounter, persistent pull tools, and any data stored in the permData hashtable that is not mapped to a column will be saved.
      Parameters:
        `user` - the user in the session
      Throws:
        `org.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.

    - #### authenticate

          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 an User with the specified password. If authentication is successful the method returns nothing. If there are any problems, exception was thrown.
      Parameters:
        `user` - an User object to authenticate.
        `password` - the user supplied password.
      Throws:
        `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.

    - #### createAccount

          void createAccount(User user,
                           String initialPassword)
                             throws org.apache.fulcrum.security.util.EntityExistsException,
                                    org.apache.fulcrum.security.util.DataBackendException

      Creates new user account with specified attributes.
      Parameters:
        `user` - the object describing account to be created.
        `initialPassword` - password for the new user
      Throws:
        `org.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.

    - #### removeAccount

          void removeAccount(User user)
                             throws org.apache.fulcrum.security.util.UnknownEntityException,
                                    org.apache.fulcrum.security.util.DataBackendException

      Removes an user account from the system.
      Parameters:
        `user` - the object describing the account to be removed.
      Throws:
        `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.

    - #### changePassword

          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

      Change the password for an User.
      Parameters:
        `user` - an User to change password for.
        `oldPassword` - the current password suplied by the user.
        `newPassword` - the current password requested by the user.
      Throws:
        `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.

    - #### forcePassword

          void forcePassword(User user,
                           String password)
                             throws org.apache.fulcrum.security.util.UnknownEntityException,
                                    org.apache.fulcrum.security.util.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.
      Parameters:
        `user` - an User to change password for.
        `password` - the new password.
      Throws:
        `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.

    - #### getAnonymousUser

          <T extends User> T getAnonymousUser()
                                          throws org.apache.fulcrum.security.util.UnknownEntityException

      Constructs an User object to represent an anonymous user of the application.
      Returns:
        An anonymous Turbine User.
      Throws:
        `org.apache.fulcrum.security.util.UnknownEntityException` - if the anonymous User object couldn't be constructed.

    - #### isAnonymousUser

          boolean isAnonymousUser(User u)

      Checks whether a passed user object matches the anonymous user pattern according to the configured user manager
      Parameters:
        `u` - a user object
      Returns:
        True if this is an anonymous user

    - #### getUserInstance

          <T extends User> T getUserInstance()
                                         throws org.apache.fulcrum.security.util.DataBackendException

      Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.
      Returns:
        an object implementing User interface.
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if the object could not be instantiated.

    - #### getUserInstance

          <T extends User> T getUserInstance(String userName)
                                         throws org.apache.fulcrum.security.util.DataBackendException

      Construct a blank User object. This method calls getUserClass, and then creates a new object using the default constructor.
      Parameters:
        `userName` - The name of the user.
      Returns:
        an object implementing User interface.
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if the object could not be instantiated.

    - #### getACL

          <T extends org.apache.fulcrum.security.acl.AccessControlList> T getACL(User user)
                                                                             throws org.apache.fulcrum.security.util.UnknownEntityException

      Return a Class object representing the system's chosen implementation of of ACL interface for the given user
      Parameters:
        `user` - the user
      Returns:
        systems's chosen implementation of ACL interface.
      Throws:
        `org.apache.fulcrum.security.util.UnknownEntityException` - if the implementation of ACL interface could not be determined, or does not exist.

Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.