Interface UserRepository<A extends Identity,B extends User<A>>

Type Parameters:
A - the identity type
B - the user type
All Superinterfaces:
CredentialsResolver<B>
All Known Implementing Classes:
InMemoryUserRepository, RedisUserRepository

public interface UserRepository<A extends Identity,B extends User<A>> extends CredentialsResolver<B>

A repository used to store, access and manage users.

It is used in a UserAuthenticator to resolve users during the authentication process. Since it also implements CredentialsResolver, it can also be used in the more generic PrincipalAuthenticator.

Since:
1.5
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    reactor.core.publisher.Mono<B>
    addUserToGroups(String username, String... groups)
    Adds the user identified by the specified username to the specified groups.
    reactor.core.publisher.Mono<B>
    changePassword(LoginCredentials credentials, String rawPassword)
    Changes the password of the user identified by the specified credentials.
    reactor.core.publisher.Mono<B>
    createUser(B user)
    Creates a user.
    reactor.core.publisher.Mono<B>
    deleteUser(String username)
    Deletes the he user identified by the specified username from the repository.
    reactor.core.publisher.Mono<B>
    getUser(String username)
    Returns the user identified by the specified username.
    reactor.core.publisher.Flux<B>
    Lists the users in the repository.
    reactor.core.publisher.Mono<B>
    lockUser(String username)
    Locks the user identified by the specified username.
    reactor.core.publisher.Mono<B>
    removeUserFromGroups(String username, String... groups)
    Removes the user identified by the specified username from the specified groups.
    reactor.core.publisher.Mono<B>
    unlockUser(String username)
    Unlocks the user identified by the specified username.
    reactor.core.publisher.Mono<B>
    updateUser(B user)
    Updates the specified user.

    Methods inherited from interface io.inverno.mod.security.authentication.CredentialsResolver

    resolveCredentials
  • Method Details

    • createUser

      reactor.core.publisher.Mono<B> createUser(B user) throws UserRepositoryException

      Creates a user.

      Parameters:
      user - the user to create
      Returns:
      a mono emitting the created user
      Throws:
      UserRepositoryException - if there was an error creating the user
    • getUser

      reactor.core.publisher.Mono<B> getUser(String username) throws UserRepositoryException

      Returns the user identified by the specified username.

      Parameters:
      username - a username
      Returns:
      a mono emittin the user or an empty mono if no user exists with the specified name
      Throws:
      UserRepositoryException - if there was an error fetchin the user
    • listUsers

      reactor.core.publisher.Flux<B> listUsers() throws UserRepositoryException

      Lists the users in the repository.

      Returns:
      a publisher of users
      Throws:
      UserRepositoryException - if there was an error fetching users
    • updateUser

      reactor.core.publisher.Mono<B> updateUser(B user) throws UserRepositoryException

      Updates the specified user.

      Note that this method does not update password nor groups and can not be used to lock a user, adhoc methods changePassword(io.inverno.mod.security.authentication.LoginCredentials, java.lang.String), addUserToGroups(java.lang.String, java.lang.String...), lockUser(java.lang.String) must be used instead.

      Parameters:
      user - the user to update
      Returns:
      a mono emitting the updated user
      Throws:
      UserRepositoryException - if there was an error updating the user
    • changePassword

      reactor.core.publisher.Mono<B> changePassword(LoginCredentials credentials, String rawPassword) throws AuthenticationException, PasswordPolicyException, PasswordException, UserRepositoryException

      Changes the password of the user identified by the specified credentials.

      Implementors must make sure the provided credentials are valid before actually updating the password. Whether a full authentiation is performed or a simple password match is implementation specific.

      Parameters:
      credentials - the current login credentials of the user for which password must be changed
      rawPassword - the new raw password value
      Returns:
      a mono emitting the updated user
      Throws:
      AuthenticationException - if there was an error authenticating the credentials
      PasswordPolicyException - if the new password is not compliant with the password policy
      PasswordException - if there was an error processing the new password
      UserRepositoryException - if there was an error updating the user
    • lockUser

      reactor.core.publisher.Mono<B> lockUser(String username) throws UserRepositoryException

      Locks the user identified by the specified username.

      Parameters:
      username - the name of the user to lock
      Returns:
      a mono emitting the updated user
      Throws:
      UserRepositoryException - if there was an error updating the user
    • unlockUser

      reactor.core.publisher.Mono<B> unlockUser(String username) throws UserRepositoryException

      Unlocks the user identified by the specified username.

      Parameters:
      username - the name of the user to unlock
      Returns:
      a mono emitting the updated user
      Throws:
      UserRepositoryException - if there was an error updating the user
    • addUserToGroups

      reactor.core.publisher.Mono<B> addUserToGroups(String username, String... groups) throws UserRepositoryException

      Adds the user identified by the specified username to the specified groups.

      Parameters:
      username - a username
      groups - a list of groups
      Returns:
      a mono emitting the updated user
      Throws:
      UserRepositoryException - if there was an error updating the user
    • removeUserFromGroups

      reactor.core.publisher.Mono<B> removeUserFromGroups(String username, String... groups) throws UserRepositoryException

      Removes the user identified by the specified username from the specified groups.

      Parameters:
      username - a username
      groups - a list of groups
      Returns:
      a mono emitting the updated user
      Throws:
      UserRepositoryException - if there was an error updating the user
    • deleteUser

      reactor.core.publisher.Mono<B> deleteUser(String username) throws UserRepositoryException

      Deletes the he user identified by the specified username from the repository.

      Parameters:
      username - a username
      Returns:
      a mono emitting the deleted user or an empty mono if no user exists with the specified name
      Throws:
      UserRepositoryException - if there was an error deleting the user