Interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>>
-
- Type Parameters:
R- the generic typeT- the generic type
- All Superinterfaces:
org.springframework.security.core.userdetails.UserDetailsService
- All Known Implementing Classes:
BasicUserServiceImpl
public interface BasicUserService<R extends org.springframework.security.core.GrantedAuthority,T extends BasicUser<R>> extends org.springframework.security.core.userdetails.UserDetailsServiceThe Interface BasicUserService.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSYSTEM_ADMINThe system admin.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TchangePassword(T user, String password)Change password.TcreateUser(String email, String fullName, String password, BasicUser.AccountType accountType)Create a new user account.voiddeleteUser(T user)Try to delete user.Collection<R>getDefaultUserRoles()Get default roles assigned to users.TgetUser(long id)Get User by id.TgetUserByEmail(String email)Get User by email.List<R>listAvailableRoles()List available roles.voidsetAccountLock(long userId, boolean locked)Sets the account lock.voidsetAccountLockLocal(long userId, boolean locked)Lock user account.TsetAccountType(T user, BasicUser.AccountType accountType)Sets the account type.TsetRoles(T user, Set<R> roles)Grant specified roles to user.voidupdateLastLogin(String userName)Update user's last login timestamp on successful login.TupdateUser(T user, String email, String fullName)Update user information.
-
-
-
Field Detail
-
SYSTEM_ADMIN
static final String SYSTEM_ADMIN
The system admin.- See Also:
- Constant Field Values
-
-
Method Detail
-
getUser
T getUser(long id)
Get User by id.- Parameters:
id- the id- Returns:
- the user or
null
-
getUserByEmail
T getUserByEmail(String email)
Get User by email.- Parameters:
email- the email- Returns:
- the user
-
createUser
T createUser(String email, String fullName, String password, BasicUser.AccountType accountType) throws NotUniqueUserException, PasswordPolicy.PasswordPolicyException, UserException
Create a new user account.- Parameters:
email- unique email addressfullName- Full namepassword- initial account passwordaccountType- account type- Returns:
- the new user
- Throws:
NotUniqueUserException- user is not unique in the systemPasswordPolicy.PasswordPolicyException- password violates current password policyUserException- any other exception
-
setRoles
T setRoles(T user, Set<R> roles)
Grant specified roles to user. ThegetDefaultUserRoles()will not be persisted.- Parameters:
user- the userroles- the roles- Returns:
- the updated user
-
updateUser
T updateUser(T user, String email, String fullName) throws NotUniqueUserException, UserException
Update user information.- Parameters:
user- the useremail- new email addressfullName- new fullName- Returns:
- the updated user
- Throws:
NotUniqueUserException- when email address is already registeredUserException- a generic user service exception
-
changePassword
T changePassword(T user, String password) throws PasswordPolicy.PasswordPolicyException
Change password.- Parameters:
user- the userpassword- new password- Returns:
- the updated user
- Throws:
PasswordPolicy.PasswordPolicyException- the password policy exception
-
deleteUser
void deleteUser(T user)
Try to delete user.- Parameters:
user- user to delete
-
setAccountLockLocal
void setAccountLockLocal(long userId, boolean locked) throws NoUserFoundExceptionLock user account.- Parameters:
userId- the user idlocked- Is account locked- Throws:
NoUserFoundException- the no user found exception
-
setAccountLock
void setAccountLock(long userId, boolean locked) throws NoUserFoundExceptionSets the account lock.- Parameters:
userId- the user idlocked- the locked- Throws:
NoUserFoundException- the no user found exception
-
getDefaultUserRoles
Collection<R> getDefaultUserRoles()
Get default roles assigned to users. These are transient and not persisted to the database.- Returns:
- collection of roles assigned to all users
- Since:
- 1.4
-
setAccountType
T setAccountType(T user, BasicUser.AccountType accountType)
Sets the account type.- Parameters:
user- the useraccountType- the account type- Returns:
- the t
-
updateLastLogin
void updateLastLogin(String userName) throws NoUserFoundException
Update user's last login timestamp on successful login.- Parameters:
userName- the user name- Throws:
NoUserFoundException- if username not found in the system
-
-