Class InMemoryUserDetailsManager
- java.lang.Object
-
- org.springframework.security.provisioning.InMemoryUserDetailsManager
-
- All Implemented Interfaces:
UserDetailsPasswordService,UserDetailsService,UserDetailsManager
public class InMemoryUserDetailsManager extends java.lang.Object implements UserDetailsManager, UserDetailsPasswordService
Non-persistent implementation ofUserDetailsManagerwhich is backed by an in-memory map.Mainly intended for testing and demonstration purposes, where a full blown persistent system isn't required.
- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Loglogger
-
Constructor Summary
Constructors Constructor Description InMemoryUserDetailsManager()InMemoryUserDetailsManager(java.util.Collection<UserDetails> users)InMemoryUserDetailsManager(java.util.Properties users)InMemoryUserDetailsManager(UserDetails... users)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangePassword(java.lang.String oldPassword, java.lang.String newPassword)Modify the current user's password.voidcreateUser(UserDetails user)Create a new user with the supplied details.voiddeleteUser(java.lang.String username)Remove the user with the given login name from the system.UserDetailsloadUserByUsername(java.lang.String username)Locates the user based on the username.voidsetAuthenticationManager(AuthenticationManager authenticationManager)UserDetailsupdatePassword(UserDetails user, java.lang.String newPassword)Modify the specified user's password.voidupdateUser(UserDetails user)Update the specified user.booleanuserExists(java.lang.String username)Check if a user with the supplied login name exists in the system.
-
-
-
Constructor Detail
-
InMemoryUserDetailsManager
public InMemoryUserDetailsManager()
-
InMemoryUserDetailsManager
public InMemoryUserDetailsManager(java.util.Collection<UserDetails> users)
-
InMemoryUserDetailsManager
public InMemoryUserDetailsManager(UserDetails... users)
-
InMemoryUserDetailsManager
public InMemoryUserDetailsManager(java.util.Properties users)
-
-
Method Detail
-
createUser
public void createUser(UserDetails user)
Description copied from interface:UserDetailsManagerCreate a new user with the supplied details.- Specified by:
createUserin interfaceUserDetailsManager
-
deleteUser
public void deleteUser(java.lang.String username)
Description copied from interface:UserDetailsManagerRemove the user with the given login name from the system.- Specified by:
deleteUserin interfaceUserDetailsManager
-
updateUser
public void updateUser(UserDetails user)
Description copied from interface:UserDetailsManagerUpdate the specified user.- Specified by:
updateUserin interfaceUserDetailsManager
-
userExists
public boolean userExists(java.lang.String username)
Description copied from interface:UserDetailsManagerCheck if a user with the supplied login name exists in the system.- Specified by:
userExistsin interfaceUserDetailsManager
-
changePassword
public void changePassword(java.lang.String oldPassword, java.lang.String newPassword)Description copied from interface:UserDetailsManagerModify the current user's password. This should change the user's password in the persistent user repository (datbase, LDAP etc).- Specified by:
changePasswordin interfaceUserDetailsManager- Parameters:
oldPassword- current password (for re-authentication if required)newPassword- the password to change to
-
updatePassword
public UserDetails updatePassword(UserDetails user, java.lang.String newPassword)
Description copied from interface:UserDetailsPasswordServiceModify the specified user's password. This should change the user's password in the persistent user repository (database, LDAP etc).- Specified by:
updatePasswordin interfaceUserDetailsPasswordService- Parameters:
user- the user to modify the password fornewPassword- the password to change to, encoded by the configuredPasswordEncoder- Returns:
- the updated UserDetails with the new password
-
loadUserByUsername
public UserDetails loadUserByUsername(java.lang.String username) throws UsernameNotFoundException
Description copied from interface:UserDetailsServiceLocates the user based on the username. In the actual implementation, the search may possibly be case sensitive, or case insensitive depending on how the implementation instance is configured. In this case, theUserDetailsobject that comes back may have a username that is of a different case than what was actually requested..- Specified by:
loadUserByUsernamein interfaceUserDetailsService- Parameters:
username- the username identifying the user whose data is required.- Returns:
- a fully populated user record (never
null) - Throws:
UsernameNotFoundException- if the user could not be found or the user has no GrantedAuthority
-
setAuthenticationManager
public void setAuthenticationManager(AuthenticationManager authenticationManager)
-
-