public class InMemoryUserDetailsManager extends java.lang.Object implements UserDetailsManager, UserDetailsPasswordService
UserDetailsManager
which is backed by an
in-memory map.
Mainly intended for testing and demonstration purposes, where a full blown persistent system isn't required.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
InMemoryUserDetailsManager() |
InMemoryUserDetailsManager(java.util.Collection<UserDetails> users) |
InMemoryUserDetailsManager(java.util.Properties users) |
InMemoryUserDetailsManager(UserDetails... users) |
Modifier and Type | Method and Description |
---|---|
void |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
Modify the current user's password.
|
void |
createUser(UserDetails user)
Create a new user with the supplied details.
|
void |
deleteUser(java.lang.String username)
Remove the user with the given login name from the system.
|
UserDetails |
loadUserByUsername(java.lang.String username)
Locates the user based on the username.
|
void |
setAuthenticationManager(AuthenticationManager authenticationManager) |
UserDetails |
updatePassword(UserDetails user,
java.lang.String newPassword)
Modify the specified user's password.
|
void |
updateUser(UserDetails user)
Update the specified user.
|
boolean |
userExists(java.lang.String username)
Check if a user with the supplied login name exists in the system.
|
public InMemoryUserDetailsManager()
public InMemoryUserDetailsManager(java.util.Collection<UserDetails> users)
public InMemoryUserDetailsManager(UserDetails... users)
public InMemoryUserDetailsManager(java.util.Properties users)
public void createUser(UserDetails user)
UserDetailsManager
createUser
in interface UserDetailsManager
public void deleteUser(java.lang.String username)
UserDetailsManager
deleteUser
in interface UserDetailsManager
public void updateUser(UserDetails user)
UserDetailsManager
updateUser
in interface UserDetailsManager
public boolean userExists(java.lang.String username)
UserDetailsManager
userExists
in interface UserDetailsManager
public void changePassword(java.lang.String oldPassword, java.lang.String newPassword)
UserDetailsManager
changePassword
in interface UserDetailsManager
oldPassword
- current password (for re-authentication if required)newPassword
- the password to change topublic UserDetails updatePassword(UserDetails user, java.lang.String newPassword)
UserDetailsPasswordService
updatePassword
in interface UserDetailsPasswordService
user
- the user to modify the password fornewPassword
- the password to change to,
encoded by the configured PasswordEncoder
public UserDetails loadUserByUsername(java.lang.String username) throws UsernameNotFoundException
UserDetailsService
UserDetails
object that comes back may have a username that is of a different case than what
was actually requested..loadUserByUsername
in interface UserDetailsService
username
- the username identifying the user whose data is required.null
)UsernameNotFoundException
- if the user could not be found or the user has no
GrantedAuthoritypublic void setAuthenticationManager(AuthenticationManager authenticationManager)