public abstract static class ActAAAService.Base<USER_TYPE> extends act.util.LogSupport implements ActAAAService
ActAAAService.Base<USER_TYPE>| Modifier and Type | Field and Description |
|---|---|
protected act.db.Dao<?,USER_TYPE,?> |
userDao
The user model DAO class
|
protected Class<USER_TYPE> |
userType
The user model class
|
| Modifier and Type | Method and Description |
|---|---|
org.osgl.aaa.Principal |
authenticate(String username,
char[] password)
Authenticate a username against a password, return a
Principal instance if authenticated, or null if failed to authenticate. |
org.osgl.aaa.Principal |
authenticate(String username,
String password)
Authenticate a username against a password, return a
Principal instance if authenticated, or null if failed to authenticate. |
org.osgl.aaa.Principal |
findByName(String identifier)
Find a principal from data store by user identifier.
|
protected USER_TYPE |
findUser(String identifier) |
protected USER_TYPE |
findUser(String key,
String value)
Sub class can overwrite this method to return a User entity by field name and field value.
|
protected void |
initUserDao(Class<USER_TYPE> userType) |
protected void |
initUserType(Class<USER_TYPE> userType) |
protected String |
nameOf(USER_TYPE user)
Deprecated.
|
protected Set<String> |
permissionsOf(USER_TYPE user)
Returns direct permission names of specified user
|
protected org.osgl.aaa.Principal |
principalOf(USER_TYPE user)
Get
Principal instance from a user instance. |
protected Integer |
privilegeOf(USER_TYPE user)
Returns the privilege level of a user.
|
void |
removeAllPrincipals()
Remove all principals from data store.
|
protected Set<String> |
rolesOf(USER_TYPE user)
Returns role names of specified user
|
void |
save(org.osgl.aaa.Principal principal)
Save an new principal into data store
|
protected void |
setPrincipalProperties(org.osgl.aaa.Principal principal,
USER_TYPE user)
Sub class can overwrite this method to store any user data (can be serialised to a String) into principal’s property.
|
protected String |
userKey()
Return the key name used to find out the user entity from data store.
|
protected String |
username(USER_TYPE user)
Get username of the user passed in.
|
protected String |
usernameField()
Return the username field name used to find out the user entity from data store.
|
protected abstract boolean |
verifyPassword(USER_TYPE user,
char[] password)
Sub class must overwrite this method to implement password verification logic.
|
protected act.db.Dao<?,USER_TYPE,?> userDao
The user model DAO class
public void save(org.osgl.aaa.Principal principal)
Save an new principal into data store
Called when there are principals defined in the _act.yml file
The default implementation is to throw out UnsupportedException
save in interface ActAAAServiceprincipal - the principal instance defined in _act.yml filepublic void removeAllPrincipals()
Remove all principals from data store.
Called when loading yaml content and the aaa.ddl.delete configuration is enabled.
The default implementation is to throw out UnsupportedException
removeAllPrincipals in interface ActAAAServicepublic org.osgl.aaa.Principal findByName(String identifier)
Find a principal from data store by user identifier.
findByName in interface ActAAAServiceidentifier - the user identifier, could be id, username, email, depends on how AAAConfig.user.key is configured.public org.osgl.aaa.Principal authenticate(String username, String password)
Authenticate a username against a password, return a Principal instance if authenticated, or null if failed to authenticate.
Sub class can (but not required to) overwrite this method
authenticate in interface org.osgl.aaa.AuthenticationServiceusername - the usernamepassword - the passwordnull if failed to authenticatepublic org.osgl.aaa.Principal authenticate(String username, char[] password)
Authenticate a username against a password, return a Principal instance if authenticated, or null if failed to authenticate.
Sub class can (but not required to) overwrite this method
authenticate in interface org.osgl.aaa.AuthenticationServiceusername - the usernamepassword - the passwordnull if failed to authenticateprotected String userKey()
Return the key name used to find out the user entity from data store.
The default implementation returns null, meaning AAA will use the aaa.user.key configuration as the userKey
protected String usernameField()
Return the username field name used to find out the user entity from data store.
The default implementation returns null, meaning AAA will use the aaa.user.username configuration as the usernameField
protected org.osgl.aaa.Principal principalOf(USER_TYPE user)
Get Principal instance from a user instance.
user - the user instanceprotected String username(USER_TYPE user)
Get username of the user passed in.
This method will use reflection to find the username by _userKey(). However sub class can overwrite this method to provide fast implementation
user - the user instance@Deprecated protected String nameOf(USER_TYPE user)
Get username of the user passed in
This method is deprecated. Please use username(Object) instead
user - the user instanceprotected Integer privilegeOf(USER_TYPE user)
Returns the privilege level of a user.
If not overwritten by sub class, this method will return null, meaning there is no privilege granted to the user
user - the user instanceprotected Set<String> rolesOf(USER_TYPE user)
Returns role names of specified user
If not overwritten by sub class, this method returns an empty set
user - the user instanceprotected Set<String> permissionsOf(USER_TYPE user)
Returns direct permission names of specified user
If not overwritten by sub class, this method returns an empty set. If sub class overwrite this method, it shall not return permissions inferred by roles
user - the user instanceprotected void setPrincipalProperties(org.osgl.aaa.Principal principal,
USER_TYPE user)
Sub class can overwrite this method to store any user data (can be serialised to a String) into principal’s property. For example user’s account ID
Default implementation is empty
principal - the principal instanceuser - the user instanceprotected abstract boolean verifyPassword(USER_TYPE user, char[] password)
Sub class must overwrite this method to implement password verification logic.
Normally it should be something like:
return Act.crypto().verifyPassword(password, user.getPassword());
user - the user instancepassword - password suppliedtrue if password matches or false otherwiseprotected USER_TYPE findUser(String key, String value)
Sub class can overwrite this method to return a User entity by field name and field value.
key - the field name, e.g. “email” or “username” etcvalue - the field valueCopyright © 2015–2019 ActFramework. All rights reserved.