Class PassiveUserManager

  • All Implemented Interfaces:
    UserManager

    public class PassiveUserManager
    extends Object
    implements UserManager
    Void user manager can be used where no data storage is needed by the application. It's methods don't provide any useful functionality except throwing DataBackendExceptions. Security service will be still able to create anonymous User objects when this UserManager is used.
    Version:
    $Id$
    Author:
    Rafal Krzewski, Henning P. Schmiedehausen
    • Method Detail

      • init

        public void init​(org.apache.commons.configuration2.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
        Type Parameters:
        U - user class
        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 UserretrieveList​(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
        Type Parameters:
        U - user class
        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 hashmap 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
        Type Parameters:
        T - user class
        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
        Type Parameters:
        T - user class
        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
        Type Parameters:
        T - user class
        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
        Type Parameters:
        T - ACL class
        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.