Class InMemoryUserDetailsManager
java.lang.Object
org.springframework.security.provisioning.InMemoryUserDetailsManager
- All Implemented Interfaces:
- UserDetailsPasswordService,- UserDetailsService,- UserDetailsManager
public class InMemoryUserDetailsManager
extends Object
implements UserDetailsManager, UserDetailsPasswordService
Non-persistent implementation of 
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.
- Since:
- 3.1
- 
Field SummaryFieldsFields inherited from interface org.springframework.security.core.userdetails.UserDetailsPasswordServiceNOOP
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidchangePassword(String oldPassword, String newPassword) Modify the current user's password.voidcreateUser(UserDetails user) Create a new user with the supplied details.voiddeleteUser(String username) Remove the user with the given login name from the system.loadUserByUsername(String username) Locates the user based on the username.voidsetAuthenticationManager(AuthenticationManager authenticationManager) voidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.updatePassword(UserDetails user, @Nullable String newPassword) Modify the specified user's password.voidupdateUser(UserDetails user) Update the specified user.booleanuserExists(String username) Check if a user with the supplied login name exists in the system.
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
InMemoryUserDetailsManagerpublic InMemoryUserDetailsManager()
- 
InMemoryUserDetailsManager
- 
InMemoryUserDetailsManager
- 
InMemoryUserDetailsManager
 
- 
- 
Method Details- 
createUserDescription copied from interface:UserDetailsManagerCreate a new user with the supplied details.- Specified by:
- createUserin interface- UserDetailsManager
 
- 
deleteUserDescription copied from interface:UserDetailsManagerRemove the user with the given login name from the system.- Specified by:
- deleteUserin interface- UserDetailsManager
 
- 
updateUserDescription copied from interface:UserDetailsManagerUpdate the specified user.- Specified by:
- updateUserin interface- UserDetailsManager
 
- 
userExistsDescription copied from interface:UserDetailsManagerCheck if a user with the supplied login name exists in the system.- Specified by:
- userExistsin interface- UserDetailsManager
 
- 
changePasswordDescription copied from interface:UserDetailsManagerModify the current user's password. This should change the user's password in the persistent user repository (database, LDAP etc).- Specified by:
- changePasswordin interface- UserDetailsManager
- Parameters:
- oldPassword- current password (for re-authentication if required)
- newPassword- the password to change to
 
- 
updatePasswordDescription 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 interface- UserDetailsPasswordService
- Parameters:
- user- the user to modify the password for
- newPassword- the password to change to, encoded by the configured- PasswordEncoder
- Returns:
- the updated UserDetails with the new password
 
- 
loadUserByUsernameDescription 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 interface- UserDetailsService
- 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
 
- 
setSecurityContextHolderStrategypublic void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
 
- 
setAuthenticationManager
 
-