public class TokenAuthenticationServiceImpl extends Object implements TokenAuthenticationService
TokenAuthenticationService
.
The token is generated by the UUID.randomUUID()
method which guarantees its uniqueness. The storage back-end
is a SQL Directory.
Modifier and Type | Field and Description |
---|---|
protected static String |
APPLICATION_NAME_FIELD |
protected static String |
CREATION_DATE_FIELD |
protected static String |
DEVICE_DESCRIPTION_FIELD |
protected static String |
DEVICE_ID_FIELD |
protected static String |
DIRECTORY_NAME |
protected static String |
DIRECTORY_SCHEMA |
protected static String |
PERMISSION_FIELD |
protected static String |
TOKEN_FIELD |
protected static String |
USERNAME_FIELD |
Constructor and Description |
---|
TokenAuthenticationServiceImpl() |
Modifier and Type | Method and Description |
---|---|
String |
acquireToken(javax.servlet.http.HttpServletRequest request)
Acquires a unique token for the specified request.
|
String |
acquireToken(String userName,
String applicationName,
String deviceId,
String deviceDescription,
String permission)
Acquires a unique token for the specified user, application, and device.
|
protected DocumentModel |
getBareAuthTokenModel(DirectoryService directoryService) |
String |
getToken(String userName,
String applicationName,
String deviceId)
Gets the token for the specified user, application, and device.
|
DocumentModelList |
getTokenBindings(String userName)
Gets the token bindings for the specified user.
|
DocumentModelList |
getTokenBindings(String userName,
String applicationName)
Gets the token bindings for the specified user and application.
|
String |
getUserName(String token)
Gets the user name bound to the specified token.
|
void |
revokeToken(String token)
Removes the token from the back-end.
|
protected static final String DIRECTORY_NAME
protected static final String DIRECTORY_SCHEMA
protected static final String USERNAME_FIELD
protected static final String TOKEN_FIELD
protected static final String APPLICATION_NAME_FIELD
protected static final String DEVICE_ID_FIELD
protected static final String DEVICE_DESCRIPTION_FIELD
protected static final String PERMISSION_FIELD
protected static final String CREATION_DATE_FIELD
public TokenAuthenticationServiceImpl()
public String acquireToken(String userName, String applicationName, String deviceId, String deviceDescription, String permission) throws TokenAuthenticationException
TokenAuthenticationService
If such a token exist in the back-end for the specified (userName, applicationName, deviceId) triplet, just returns it, else generates it and stores it in the back-end with the triplet attributes, the specified device description and permission.
acquireToken
in interface TokenAuthenticationService
TokenAuthenticationException
- if one of the required parameters is null or empty (all parameters are
required except for the device description)public String acquireToken(javax.servlet.http.HttpServletRequest request) throws TokenAuthenticationException
TokenAuthenticationService
Parameters needed (applicationName, deviceId, deviceDescription, permission) to acquire the token are extracted from the request itself.
If such a token exist in the back-end for the specified (userName, applicationName, deviceId) triplet, just returns it, else generates it and stores it in the back-end with the triplet attributes, the specified device description and permission.
acquireToken
in interface TokenAuthenticationService
TokenAuthenticationException
- if one of the required parameters is null or empty (all parameters are
required except for the device description)public String getToken(String userName, String applicationName, String deviceId) throws TokenAuthenticationException
TokenAuthenticationService
getToken
in interface TokenAuthenticationService
TokenAuthenticationException
- if one of the required parameters is null or empty (all parameters are
required except for the device description)public String getUserName(String token)
TokenAuthenticationService
getUserName
in interface TokenAuthenticationService
public void revokeToken(String token)
TokenAuthenticationService
revokeToken
in interface TokenAuthenticationService
public DocumentModelList getTokenBindings(String userName)
TokenAuthenticationService
getTokenBindings
in interface TokenAuthenticationService
public DocumentModelList getTokenBindings(String userName, String applicationName)
TokenAuthenticationService
getTokenBindings
in interface TokenAuthenticationService
protected DocumentModel getBareAuthTokenModel(DirectoryService directoryService)
Copyright © 2018 Nuxeo. All rights reserved.