Interface UserRepository<A extends Identity,B extends User<A>>
- Type Parameters:
A
- the identity typeB
- the user type
- All Superinterfaces:
CredentialsResolver<B>
- All Known Implementing Classes:
InMemoryUserRepository
,RedisUserRepository
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 TypeMethodDescriptionaddUserToGroups
(String username, String... groups) Adds the user identified by the specified username to the specified groups.changePassword
(LoginCredentials credentials, String rawPassword) Changes the password of the user identified by the specified credentials.createUser
(B user) Creates a user.deleteUser
(String username) Deletes the he user identified by the specified username from the repository.Returns the user identified by the specified username.Lists the users in the repository.Locks the user identified by the specified username.removeUserFromGroups
(String username, String... groups) Removes the user identified by the specified username from the specified groups.unlockUser
(String username) Unlocks the user identified by the specified username.updateUser
(B user) Updates the specified user.Methods inherited from interface io.inverno.mod.security.authentication.CredentialsResolver
resolveCredentials
-
Method Details
-
createUser
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
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
Lists the users in the repository.
- Returns:
- a publisher of users
- Throws:
UserRepositoryException
- if there was an error fetching users
-
updateUser
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
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 changedrawPassword
- the new raw password value- Returns:
- a mono emitting the updated user
- Throws:
AuthenticationException
- if there was an error authenticating the credentialsPasswordPolicyException
- if the new password is not compliant with the password policyPasswordException
- if there was an error processing the new passwordUserRepositoryException
- if there was an error updating the user
-
lockUser
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
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
Adds the user identified by the specified username to the specified groups.
- Parameters:
username
- a usernamegroups
- a list of groups- Returns:
- a mono emitting the updated user
- Throws:
UserRepositoryException
- if there was an error updating the user
-
removeUserFromGroups
Removes the user identified by the specified username from the specified groups.
- Parameters:
username
- a usernamegroups
- a list of groups- Returns:
- a mono emitting the updated user
- Throws:
UserRepositoryException
- if there was an error updating the user
-
deleteUser
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
-