Class AbstractDatabaseUserRepository<T extends org.springframework.security.core.userdetails.UserDetails>

java.lang.Object
io.jmix.securitydata.user.AbstractDatabaseUserRepository<T>
Type Parameters:
T - type of entity representing users
All Implemented Interfaces:
UserManager, UserRepository, org.springframework.security.core.userdetails.UserDetailsService

public abstract class AbstractDatabaseUserRepository<T extends org.springframework.security.core.userdetails.UserDetails> extends Object implements UserRepository, UserManager
Base implementation of UserRepository that loads users from the database. The type of entity representing users is specified in the getUserClass() method.
  • Field Details

    • eventPublisher

      @Autowired protected org.springframework.context.ApplicationEventPublisher eventPublisher
  • Constructor Details

    • AbstractDatabaseUserRepository

      public AbstractDatabaseUserRepository()
  • Method Details

    • getUserClass

      protected abstract Class<T> getUserClass()
      Returns the class of a JPA entity representing users in the application.
    • createSystemUser

      protected T createSystemUser()
      Creates the built-in 'system' user.
    • initSystemUser

      protected void initSystemUser(T systemUser)
      Initializes the built-in 'system' user. Override in the application to grant authorities or initialize attributes.
    • createAnonymousUser

      protected T createAnonymousUser()
      Creates the built-in 'anonymous' user.
    • initAnonymousUser

      protected void initAnonymousUser(T anonymousUser)
      Initializes the built-in 'anonymous' user. Override in the application to grant authorities or initialize attributes.
    • getSystemUser

      public T getSystemUser()
      Description copied from interface: UserRepository
      Returns the built-in 'system' user.
      Specified by:
      getSystemUser in interface UserRepository
    • getAnonymousUser

      public T getAnonymousUser()
      Description copied from interface: UserRepository
      Returns the built-in 'anonymous' user.
      Specified by:
      getAnonymousUser in interface UserRepository
    • getByUsernameLike

      public List<T> getByUsernameLike(String substring)
      Description copied from interface: UserRepository
      Returns the list of users whose username contains the given substring.
      Specified by:
      getByUsernameLike in interface UserRepository
    • loadUserByUsername

      public T loadUserByUsername(String username) throws org.springframework.security.core.userdetails.UsernameNotFoundException
      Specified by:
      loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsService
      Throws:
      org.springframework.security.core.userdetails.UsernameNotFoundException
    • changePassword

      public void changePassword(String userName, @Nullable String oldPassword, @Nullable String newPassword) throws PasswordNotMatchException
      Description copied from interface: UserManager
      Changes the password for the specific user.
      Specified by:
      changePassword in interface UserManager
      Parameters:
      userName - - users login
      oldPassword - - non encoded old users password
      newPassword - - non encoded new users password
      Throws:
      PasswordNotMatchException - if the oldPassword is not null and the oldPassword does not equal to the current password or if the oldPassword is null and the newPassword does equal the current password
    • resetPasswords

      public Map<org.springframework.security.core.userdetails.UserDetails,String> resetPasswords(Set<org.springframework.security.core.userdetails.UserDetails> users)
      Description copied from interface: UserManager
      Changes the password for the specific user.
      Specified by:
      resetPasswords in interface UserManager
      Parameters:
      users - - users which need reset passwords
      Returns:
      map which contains new password for specific user
    • resetRememberMe

      public void resetRememberMe(Collection<org.springframework.security.core.userdetails.UserDetails> users)
      Description copied from interface: UserManager
      Resets 'remember me' token for the specific user.
      Specified by:
      resetRememberMe in interface UserManager
      Parameters:
      users - - users which need reset 'remember me' token
    • getGrantedAuthoritiesBuilder

      protected AbstractDatabaseUserRepository<T>.GrantedAuthoritiesBuilder getGrantedAuthoritiesBuilder()
      Returns a builder that helps create authorities from roles.
    • isUserDisabled

      protected boolean isUserDisabled(EntityChangedEvent<? extends org.springframework.security.core.userdetails.UserDetails> event)