Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public class InMemoryUserDetailsManager

  1. Object
  2. InMemoryUserDetailsManager

ImplementsUserDetailsManager, UserDetailsPasswordService, UserDetailsService

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.

Constructors

public InMemoryUserDetailsManager()
public InMemoryUserDetailsManager(UserDetails... users)
public InMemoryUserDetailsManager(Collection<UserDetails> users)

Methods

public synchronized void createUser(UserDetails user)
public synchronized void updateUser(UserDetails user)
public synchronized void deleteUser(String username)
public synchronized boolean userExists(String username)
public void changePassword(String oldPassword, String newPassword)Changes the password of the user the calling thread is authenticated as.
public synchronized UserDetails updatePassword(UserDetails user, String newPassword)Stores newPassword, which is already encoded, as user’s password, and returns the user as it now is.
public synchronized UserDetails loadUserByUsername(String username)The user of that name; never null.

Inherited methods

Constructor details

InMemoryUserDetailsManager

public InMemoryUserDetailsManager()

InMemoryUserDetailsManager

public InMemoryUserDetailsManager(UserDetails... users)

InMemoryUserDetailsManager

public InMemoryUserDetailsManager(Collection<UserDetails> users)

Method details

createUser

public synchronized void createUser(UserDetails user)

updateUser

public synchronized void updateUser(UserDetails user)

deleteUser

public synchronized void deleteUser(String username)

userExists

public synchronized boolean userExists(String username)

changePassword

public void changePassword(String oldPassword, String newPassword)
Changes the password of the user the calling thread is authenticated as. Both passwords are given as they would be stored.

updatePassword

public synchronized UserDetails updatePassword(UserDetails user, String newPassword)
Stores newPassword, which is already encoded, as user’s password, and returns the user as it now is.

loadUserByUsername

public synchronized UserDetails loadUserByUsername(String username)
The user of that name; never null.

Throws

UsernameNotFoundException
when there is none, or the user has no authority at all