Class HybridUserProvider

  • All Implemented Interfaces:
    UserProvider

    public class HybridUserProvider
    extends UserMultiProvider
    Delegate UserProvider operations among up to three configurable provider implementation classes. This class related to, but is distinct from MappedUserProvider. The Hybrid variant of the provider iterates over providers, operating on the first applicable instance. The Mapped variant, however, maps each user to exactly one provider.
    Author:
    Marc Seeger, Chris Neasbitt, Tom Evans, Guus der Kinderen
    • Constructor Detail

      • HybridUserProvider

        public HybridUserProvider()
    • Method Detail

      • createUser

        public User createUser​(String username,
                               String password,
                               String name,
                               String email)
                        throws UserAlreadyExistsException
        Creates a new user in the first non-read-only provider.
        Parameters:
        username - the username.
        password - the plain-text password.
        name - the user's name, which can be null, unless isNameRequired is set to true.
        email - the user's email address, which can be null, unless isEmailRequired is set to true.
        Returns:
        The user that was created.
        Throws:
        UserAlreadyExistsException - if the user already exists
      • deleteUser

        public void deleteUser​(String username)
        Removes a user from all non-read-only providers.
        Parameters:
        username - the username to delete.
      • getUserProvider

        public UserProvider getUserProvider​(String username)
        Returns the first provider that contains the user, or the first provider that is not read-only when the user does not exist in any provider.
        Parameters:
        username - the username (cannot be null or empty).
        Returns:
        The user provider (never null)
      • loadUser

        public User loadUser​(String username)
                      throws UserNotFoundException
        Loads a user from the first provider that contains the user.
        Parameters:
        username - the username (cannot be null or empty).
        Returns:
        The user (never null).
        Throws:
        UserNotFoundException - When none of the providers contains the user.
      • setCreationDate

        public void setCreationDate​(String username,
                                    Date creationDate)
                             throws UserNotFoundException
        Changes the creation date of a user in the first provider that contains the user.
        Parameters:
        username - the username.
        creationDate - the date the user was created.
        Throws:
        UserNotFoundException - when the user was not found in any provider.
        UnsupportedOperationException - when the provider is read-only.
      • setModificationDate

        public void setModificationDate​(String username,
                                        Date modificationDate)
                                 throws UserNotFoundException
        Changes the modification date of a user in the first provider that contains the user.
        Parameters:
        username - the username.
        modificationDate - the date the user was (last) modified.
        Throws:
        UserNotFoundException - when the user was not found in any provider.
        UnsupportedOperationException - when the provider is read-only.