R - the generic typeT - the generic type@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
| Modifier and Type | Field and Description |
|---|---|
protected AclEntryPersistence |
aclEntryRepository
The acl entry repository.
|
static org.slf4j.Logger |
LOG
The Constant LOG.
|
protected org.springframework.security.crypto.password.PasswordEncoder |
passwordEncoder
The password encoder.
|
SYSTEM_ADMIN| Constructor and Description |
|---|
BasicUserServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
assureGoodPassword(String password)
Test if password passes the password policy (if set).
|
T |
changePassword(T user,
String password)
Change password.
|
protected abstract T |
createSystemAdministrator(String username)
Implementations must create a user with specified username with ADMINISTRATOR
role and account type
BasicUser.AccountType.SYSTEM. |
T |
deepLoad(T user)
Deep load.
|
void |
deleteUser(T user)
Try to delete user.
|
abstract Collection<R> |
getDefaultUserRoles()
Get default roles assigned to users.
|
protected abstract Set<String> |
getRuntimeAuthorities(T user)
Allow the application to register additional authorities.
|
T |
getUser(long id)
Get User by id.
|
protected abstract org.springframework.data.jpa.repository.JpaRepository<T,Long> |
getUserRepository()
Gets the user repository.
|
abstract List<R> |
listAvailableRoles()
List available roles.
|
org.springframework.security.core.userdetails.UserDetails |
loadUserByUsername(String username) |
void |
setAccountLock(long userId,
boolean locked)
Sets the account lock.
|
void |
setAccountLockLocal(long userId,
boolean locked)
For internal use only.
|
void |
setAccountLockoutTime(long accountLockoutTime)
Sets the account lockout time.
|
T |
setAccountType(T user,
BasicUser.AccountType accountType)
Sets the account type.
|
protected void |
setPassword(T user,
String password)
Sets the password.
|
T |
setRoles(T user,
Set<R> newRoles)
Grant specified roles to user.
|
void |
updateLastLogin(String userName)
Update user's last login date.
|
T |
updateUser(T user,
String email,
String fullName)
Update user information.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateUser, getUserByEmailpublic static final org.slf4j.Logger LOG
@Autowired protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
@Autowired(required=false) protected AclEntryPersistence aclEntryRepository
@Transactional
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionprotected abstract org.springframework.data.jpa.repository.JpaRepository<T,Long> getUserRepository()
protected abstract T createSystemAdministrator(String username) throws UserException
BasicUser.AccountType.SYSTEM.username - Generally SYSTEM_ADMINUserException - the user exceptionpublic void setAccountLockoutTime(long accountLockoutTime)
accountLockoutTime - the new account lockout timepublic abstract Collection<R> getDefaultUserRoles()
BasicUserServicegetDefaultUserRoles in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>public abstract List<R> listAvailableRoles()
BasicUserServicelistAvailableRoles in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username) throws org.springframework.security.core.userdetails.UsernameNotFoundException
loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsServiceorg.springframework.security.core.userdetails.UsernameNotFoundExceptionprotected abstract Set<String> getRuntimeAuthorities(T user)
user - the userpublic T getUser(long id)
BasicUserService@Transactional @PreAuthorize(value="hasRole(\'ADMINISTRATOR\') || principal.id == #user.id") public T updateUser(T user, String email, String fullName) throws NotUniqueUserException, UserException
BasicUserServiceupdateUser in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>user - the useremail - new email addressfullName - new fullNameNotUniqueUserException - when email address is already registeredUserException - a generic user service exception@Transactional @PreAuthorize(value="hasRole(\'ADMINISTRATOR\')") public void deleteUser(T user)
BasicUserServicedeleteUser in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>user - user to delete@Transactional public T setRoles(T user, Set<R> newRoles)
BasicUserServiceBasicUserService.getDefaultUserRoles() will not be
persisted.@Transactional @PreAuthorize(value="hasRole(\'ADMINISTRATOR\') || principal.id == #user.id") public T changePassword(T user, String password) throws PasswordPolicy.PasswordPolicyException
BasicUserServicechangePassword in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>user - the userpassword - new passwordPasswordPolicy.PasswordPolicyException - the password policy exceptionprotected final void setPassword(T user, String password) throws PasswordPolicy.PasswordPolicyException
user - the userpassword - the passwordPasswordPolicy.PasswordPolicyException - the password policy exceptionpublic void assureGoodPassword(String password) throws PasswordPolicy.PasswordPolicyException
password - candidate passwordPasswordPolicy.PasswordPolicyException - if password does not match policy@Transactional
public void setAccountLockLocal(long userId,
boolean locked)
throws NoUserFoundException
setAccountLockLocal in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>userId - the user idlocked - the lockedNoUserFoundException - the no user found exception@Transactional
@PreAuthorize(value="hasRole(\'ADMINISTRATOR\')")
public void setAccountLock(long userId,
boolean locked)
throws NoUserFoundException
BasicUserServicesetAccountLock in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>userId - the user idlocked - the lockedNoUserFoundException - the no user found exception@Transactional public T setAccountType(T user, BasicUser.AccountType accountType)
BasicUserServicesetAccountType in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>user - the useraccountType - the account type@Transactional public void updateLastLogin(String userName) throws NoUserFoundException
BasicUserServiceupdateLastLogin in interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>userName - the user nameNoUserFoundException - if username not found in the systemCopyright © 2020 Global Crop Diversity Trust. All rights reserved.