Interface UserManager

All Known Implementing Classes:
InMemoryUserManager

public interface UserManager
Provide user management capabilities. It includes methods for creating, updating, deleting users, changing passwords, and checking user existence.
  • Method Details

    • createUser

      CompletableFuture<User> createUser(@NotNull @NotNull UsernamePasswordCredentials credentials, @Nullable @Nullable Set<String> roles, @Nullable @Nullable Map<String,Object> attributes) throws CredentialValidationException
      Creates a new user with the specified credentials. The method allows specifying roles and additional attributes for the user.
      Parameters:
      credentials - the credentials for the new user, typically containing a username and password
      roles - an optional set of roles to assign to the user
      attributes - an optional map of additional attributes to associate with the user
      Returns:
      a CompletableFuture that, upon completion, returns the created User object.
      Throws:
      CredentialValidationException - if the provided credentials do not meet the required validation criteria.
    • updateUser

      CompletableFuture<User> updateUser(@NotNull @NotNull String username, @Nullable @Nullable Set<String> roles, @Nullable @Nullable Map<String,Object> attributes) throws UserNotFoundException
      Updates an existing user identified by the username. This method allows updating the user's roles and additional attributes.
      Parameters:
      username - the username of the user to be updated
      roles - an optional new set of roles for the user
      attributes - an optional map of new or updated attributes for the user
      Returns:
      a CompletableFuture that, when completed, returns the updated User object.
      Throws:
      UserNotFoundException - if no user exists with the given username
      CredentialValidationException - if any provided credentials are invalid
    • deleteUser

      CompletableFuture<User> deleteUser(@Nullable @Nullable String username)
      Deletes a user with the specified username.
      Parameters:
      username - the username of the user to be deleted.
      Returns:
      a CompletableFuture that, when completed, returns the deleted User
    • changePassword

      Changes the password of an existing user.
      Parameters:
      username - the username of the user whose password is to be changed
      newPassword - the new password for the user
      Returns:
      a CompletableFuture that, when completed, returns the user with the updated password
      Throws:
      UserNotFoundException - if no user exists with the given username
      CredentialValidationException - if the new password does not meet the required validation criteria
    • userExists

      boolean userExists(String username)
      Checks if a user exists with the specified username.
      Parameters:
      username - The username to check for existence.
      Returns:
      true if the user exists, false otherwise.
    • loadUserByUsername

      CompletableFuture<User> loadUserByUsername(String username) throws UserNotFoundException
      Locates the user based on the username.
      Parameters:
      username - the username identifying the user whose data is required
      Returns:
      a fully populated user record (never null)
      Throws:
      UserNotFoundException - if the user could not be found