org.apache.turbine.services.security

## Class DefaultUserManager

- java.lang.Object
- - org.apache.turbine.services.security.DefaultUserManager

- All Implemented Interfaces:
    UserManager

      public class DefaultUserManager
      extends Object
      implements UserManager

  Default user manager. The user manager wraps Fulcrum security user objects into Turbine-specific ones.
  Version:
    $Id: PassiveUserManager.java 1096130 2011-04-23 10:37:19Z ludwig $
  Author:
    Thomas Vandahl

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultUserManager()`

  - ### 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.
    `<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 set 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.
    `protected <U extends User> U` | `wrap(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)` Wrap a Fulcrum user object into a Turbine user object

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultUserManager

          public DefaultUserManager()

  - ### Method Detail

    - #### wrap

          protected <U extends User> U wrap(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)

      Wrap a Fulcrum user object into a Turbine user object
      Parameters:
        `user` - the user object to delegate to
      Returns:
        the wrapped object

    - #### init

          public void init(org.apache.commons.configuration.Configuration conf)

      Initializes the UserManager
      Specified by:
        `init` in interface `UserManager`
      Parameters:
        `conf` - A Configuration object to init this Manager

    - #### accountExists

          public 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.
      Specified by:
        `accountExists` in interface `UserManager`
      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

          public 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.
      Specified by:
        `accountExists` in interface `UserManager`
      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

          public <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.
      Specified by:
        `retrieve` in interface `UserManager`
      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

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

      Retrieve a set 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.
      Specified by:
        `retrieveList` in interface `UserManager`
      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

          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 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.
      Specified by:
        `retrieve` in interface `UserManager`
      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

          public 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.
      Specified by:
        `store` in interface `UserManager`
      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

          public 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.
      Specified by:
        `saveOnSessionUnbind` in interface `UserManager`
      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

          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 an User with the specified password. If authentication is successful the method returns nothing. If there are any problems, exception was thrown.
      Specified by:
        `authenticate` in interface `UserManager`
      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

          public 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.
      Specified by:
        `createAccount` in interface `UserManager`
      Parameters:
        `user` - the object describing account to be created.
        `initialPassword` - The password to use for the object creation
      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

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

      Removes an user account from the system.
      Specified by:
        `removeAccount` in interface `UserManager`
      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

          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

      Change the password for an User.
      Specified by:
        `changePassword` in interface `UserManager`
      Parameters:
        `user` - an User to change password for.
        `oldPassword` - the current password supplied 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

          public 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 implementations of this feature would require administrative level access to the authenticating server / program.
      Specified by:
        `forcePassword` in interface `UserManager`
      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

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

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

    - #### isAnonymousUser

          public boolean isAnonymousUser(User u)

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

    - #### getUserInstance

          public <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.
      Specified by:
        `getUserInstance` in interface `UserManager`
      Returns:
        an object implementing User interface.
      Throws:
        `org.apache.fulcrum.security.util.DataBackendException` - if the object could not be instantiated.

    - #### getUserInstance

          public <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.
      Specified by:
        `getUserInstance` in interface `UserManager`
      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

          public <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.
      Specified by:
        `getACL` in interface `UserManager`
      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.