- 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 Summary
Modifier and TypeMethodDescriptionchangePassword(String username, String newPassword) Changes the password of an existing user.createUser(@NotNull UsernamePasswordCredentials credentials, @Nullable Set<String> roles, @Nullable Map<String, Object> attributes) Creates a new user with the specified credentials.deleteUser(@Nullable String username) Deletes a user with the specified username.loadUserByUsername(String username) Locates the user based on the username.updateUser(@NotNull String username, @Nullable Set<String> roles, @Nullable Map<String, Object> attributes) Updates an existing user identified by the username.booleanuserExists(String username) Checks if a user exists with the specified username.
-
Method Details
-
createUser
CompletableFuture<User> createUser(@NotNull @NotNull UsernamePasswordCredentials credentials, @Nullable @Nullable Set<String> roles, @Nullable @Nullable Map<String, Object> attributes) throws CredentialValidationExceptionCreates 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 passwordroles- an optional set of roles to assign to the userattributes- an optional map of additional attributes to associate with the user- Returns:
- a
CompletableFuturethat, upon completion, returns the createdUserobject. - 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 UserNotFoundExceptionUpdates 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 updatedroles- an optional new set of roles for the userattributes- an optional map of new or updated attributes for the user- Returns:
- a
CompletableFuturethat, when completed, returns the updatedUserobject. - Throws:
UserNotFoundException- if no user exists with the given usernameCredentialValidationException- if any provided credentials are invalid
-
deleteUser
Deletes a user with the specified username.- Parameters:
username- the username of the user to be deleted.- Returns:
- a
CompletableFuturethat, when completed, returns the deletedUser
-
changePassword
CompletableFuture<User> changePassword(String username, String newPassword) throws UserNotFoundException, CredentialValidationException Changes the password of an existing user.- Parameters:
username- the username of the user whose password is to be changednewPassword- the new password for the user- Returns:
- a
CompletableFuturethat, when completed, returns the user with the updated password - Throws:
UserNotFoundException- if no user exists with the given usernameCredentialValidationException- if the new password does not meet the required validation criteria
-
userExists
Checks if a user exists with the specified username.- Parameters:
username- The username to check for existence.- Returns:
trueif the user exists,falseotherwise.
-
loadUserByUsername
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
-