Class InMemoryUserDetailsManager
java.lang.Object
com.codename1.backend.security.core.userdetails.InMemoryUserDetailsManager
- All Implemented Interfaces:
UserDetailsManager, UserDetailsPasswordService, UserDetailsService
public class InMemoryUserDetailsManager
extends Object
implements UserDetailsManager, UserDetailsPasswordService
Users kept in memory: for a demonstration, a test, or a server whose handful of accounts is part of its configuration. Names are compared without regard to ASCII case, and every lookup returns a copy, so erasing the credentials of a signed-in user does not erase the stored ones.
@Bean
UserDetailsService users() {
return new InMemoryUserDetailsManager(
User.withUsername("ada").password("{noop}secret").roles("USER").build());
}
The accounts live in this process only and are gone when it stops.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassword(String oldPassword, String newPassword) Changes the password of the user the calling thread is authenticated as.voidcreateUser(UserDetails user) voiddeleteUser(String username) loadUserByUsername(String username) The user of that name; never null.updatePassword(UserDetails user, String newPassword) StoresnewPassword, which is already encoded, asuser's password, and returns the user as it now is.voidupdateUser(UserDetails user) booleanuserExists(String username)
-
Constructor Details
-
InMemoryUserDetailsManager
public InMemoryUserDetailsManager() -
InMemoryUserDetailsManager
-
InMemoryUserDetailsManager
-
-
Method Details
-
createUser
- Specified by:
createUserin interfaceUserDetailsManager
-
updateUser
- Specified by:
updateUserin interfaceUserDetailsManager
-
deleteUser
- Specified by:
deleteUserin interfaceUserDetailsManager
-
userExists
- Specified by:
userExistsin interfaceUserDetailsManager
-
changePassword
Description copied from interface:UserDetailsManagerChanges the password of the user the calling thread is authenticated as. Both passwords are given as they would be stored.- Specified by:
changePasswordin interfaceUserDetailsManager
-
updatePassword
Description copied from interface:UserDetailsPasswordServiceStoresnewPassword, which is already encoded, asuser's password, and returns the user as it now is.- Specified by:
updatePasswordin interfaceUserDetailsPasswordService
-
loadUserByUsername
Description copied from interface:UserDetailsServiceThe user of that name; never null.
Throws
UsernameNotFoundException: when there is none, or the user has no authority at all
- Specified by:
loadUserByUsernamein interfaceUserDetailsService
-