Class BasicUserServiceImpl<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>

  • Type Parameters:
    R - the generic type
    T - the generic type
    All Implemented Interfaces:
    BasicUserService<R,​T>, org.springframework.beans.factory.InitializingBean, org.springframework.security.core.userdetails.UserDetailsService

    @Transactional(readOnly=true)
    public abstract class BasicUserServiceImpl<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>
    extends Object
    implements BasicUserService<R,​T>, org.springframework.beans.factory.InitializingBean
    The Class BasicUserServiceImpl.
    • Field Detail

      • LOG

        public static final org.slf4j.Logger LOG
        The Constant LOG.
      • passwordEncoder

        @Autowired
        protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
        The password encoder.
      • aclEntryRepository

        @Autowired(required=false)
        protected AclEntryPersistence aclEntryRepository
        The acl entry repository.
    • Constructor Detail

      • BasicUserServiceImpl

        public BasicUserServiceImpl()
    • Method Detail

      • afterPropertiesSet

        @Transactional
        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • getUserRepository

        protected abstract org.springframework.data.jpa.repository.JpaRepository<T,​Long> getUserRepository()
        Gets the user repository.
        Returns:
        the user repository
      • createSystemAdministrator

        protected abstract T createSystemAdministrator​(String username)
                                                throws UserException
        Implementations must create a user with specified username with ADMINISTRATOR role and account type BasicUser.AccountType.SYSTEM.
        Parameters:
        username - Generally SYSTEM_ADMIN
        Returns:
        user instance with ADMINISTRATOR role
        Throws:
        UserException - the user exception
      • setAccountLockoutTime

        public void setAccountLockoutTime​(long accountLockoutTime)
        Sets the account lockout time.
        Parameters:
        accountLockoutTime - the new account lockout time
      • getDefaultUserRoles

        public abstract List<R> getDefaultUserRoles()
        Description copied from interface: BasicUserService
        Get default roles assigned to users. These are transient and not persisted to the database.
        Specified by:
        getDefaultUserRoles in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>
        Returns:
        collection of roles assigned to all users
      • loadUserByUsername

        public org.springframework.security.core.userdetails.UserDetails 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
      • getDynamicAuthorities

        protected abstract Set<org.springframework.security.core.GrantedAuthority> getDynamicAuthorities​(T user)
        Allow the application to register additional authorities.
        Parameters:
        user - the user
        Returns:
        the same object
      • getUser

        public T getUser​(long id)
        Description copied from interface: BasicUserService
        Get User by id.
        Specified by:
        getUser in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>
        Parameters:
        id - the id
        Returns:
        the user or null
      • deepLoad

        public T deepLoad​(T user)
        Deep load.
        Parameters:
        user - the user
        Returns:
        the t
      • deleteUser

        @Transactional
        @PreAuthorize("hasRole(\'ADMINISTRATOR\')")
        public void deleteUser​(T user)
        Description copied from interface: BasicUserService
        Try to delete user.
        Specified by:
        deleteUser in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>
        Parameters:
        user - user to delete
      • setAccountLock

        @Transactional
        @PreAuthorize("hasRole(\'ADMINISTRATOR\')")
        public void setAccountLock​(long userId,
                                   boolean locked)
                            throws NoUserFoundException
        Description copied from interface: BasicUserService
        Sets the account lock.
        Specified by:
        setAccountLock in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,​T extends BasicUser<R>>
        Parameters:
        userId - the user id
        locked - the locked
        Throws:
        NoUserFoundException - the no user found exception