Interface UserRegistry

All Superinterfaces:
AuthenticationProvider, Registry<User,String>

@NonNullByDefault public interface UserRegistry extends Registry<User,String>, AuthenticationProvider
An interface for a generic Registry of User entities. User registries can also be used as AuthenticationProvider.
Author:
Yannick Schaus - initial contribution
  • Method Details

    • register

      User register(String username, String password, Set<String> roles)
      Adds a new User in this registry. The implementation receives the clear text credentials and is responsible for their secure storage (for instance by hashing the password), then return the newly created User instance.
      Parameters:
      username - the username of the new user
      password - the user password
      roles - the roles attributed to the new user
      Returns:
      the new registered User instance
    • changePassword

      void changePassword(User user, String newPassword)
      Change the password for a User in this registry. The implementation receives the new password and is responsible for their secure storage (for instance by hashing the password).
      Parameters:
      user - the username of the existing user
      newPassword - the new password
    • addUserSession

      void addUserSession(User user, UserSession session)
      Adds a new session to the user profile
      Parameters:
      user - the user
      session - the session to add
    • removeUserSession

      void removeUserSession(User user, UserSession session)
      Removes the specified session from the user profile
      Parameters:
      user - the user
      session - the session to remove
    • clearSessions

      void clearSessions(User user)
      Clears all sessions from the user profile
      Parameters:
      user - the user
    • addUserApiToken

      String addUserApiToken(User user, String name, String scope)
      Adds a new API token to the user profile. The implementation is responsible for storing the token in a secure way (for instance by hashing it).
      Parameters:
      user - the user
      name - the name of the API token to create
      scope - the scope this API token will be valid for
      Returns:
      the string that can be used as a Bearer token to match the new API token
    • removeUserApiToken

      void removeUserApiToken(User user, UserApiToken apiToken)
      Removes the specified API token from the user profile
      Parameters:
      user - the user
      apiToken - the API token