public class JWTTokenService
extends java.lang.Object
UUToken instance. It provides support for handling token.| Modifier and Type | Class and Description |
|---|---|
private static class |
JWTTokenService.TokenHolder
Contains secured and plain form of UUToken.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
APPLICATION_NAME
Parameter name for Application URI used in custom claims.
|
private static java.lang.String |
BEARER_PREFIX
Prefix for authorization request header field.
|
private static java.lang.ThreadLocal<JWTTokenService.TokenHolder> |
ctxHolder
Security context holder.
|
static java.lang.String |
DEFAULT_CONFIG_PATH
Path where is stored configuration
|
private static java.lang.String |
DEFAULT_CREATOR_CLASS
Class name for default token creator.
|
private static java.lang.String |
DEFAULT_TIME_TOLERANCE
This value is used for ignoring small differences between system time on different computers.
|
private static java.util.logging.Logger |
LOGGER
Logger instance.
|
private static java.lang.String |
PAR_CREATOR_CLASS
Name for token verifier class name.
|
private static java.lang.String |
PAR_TIME_TOLERANCE
Name for time tolerance..
|
private static java.lang.String |
PARAM_CONFIG_PATH
Name of system property parameter which holds path to configuration.
|
private static JWTTokenService |
singleton
Singleton instance.
|
private static java.lang.Object |
SPACE
Space used as separator in Authorization header.
|
private long |
timeTolerance
Time tolerance.
|
private TokenCreator |
tokenCreator
Instance used for token validation.
|
| Modifier | Constructor and Description |
|---|---|
private |
JWTTokenService(java.util.Properties parameters)
Creates a new instance of UESFormTokenProviderImpl.
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
appendBearerPrefix(java.lang.String securedToken)
Add
JWTTokenService.BEARER_PREFIX to the given value. |
private java.lang.String |
getApplication(ReadOnlyJWTClaimsSet claimsSet)
Converts audience from the given claim set to string form.
|
private java.util.List<java.lang.String> |
getAudiences(UUToken token)
Constructs list of audiences for the specified form token.
|
private long |
getCurrentTime()
Returns current time.
|
java.lang.String |
getInitiator()
Returns initiator using JWT context stored in the thread security context holder.
|
private java.io.InputStream |
getInputStreamForConfiguration()
Returns input stream for configuration.
|
static JWTTokenService |
getInstance()
Returns instance of this class.
|
static JWTTokenService |
getInstance(java.util.Properties parameters)
Returns instance of this class.
|
java.lang.String |
getPrincipal()
Returns principal using JWT context stored in the thread security context holder.
|
java.lang.String |
getSecuredToken(UUToken token)
Converts UES form token to secured form.
|
java.lang.String |
getSecurityRealm()
Returns security realm using JWT context stored in the thread security context holder.
|
java.lang.String |
getToken()
Returns token using the thread security context holder.
|
private void |
initTimeTolerance(java.util.Properties conf)
Sets time tolerance attribute.
|
private void |
initTokenCreator(java.util.Properties conf)
Initializes token creator.
|
boolean |
isJWTToken(java.lang.String value)
Determines whether the passed string may be a JWT token (it checks expected token format but it doesn't parse the value).
|
private boolean |
isTokenValid(UUToken token)
Determines whether is the given secured token valid (i.e. it has not been modified and it is not expired).
|
private java.util.Properties |
loadConfiguration()
Loads configuration of this service.
|
UUToken |
parseSecuredToken(java.lang.String securedToken)
Parses secured token to an
UUToken instance. |
private java.lang.String |
removeBearerPrefix(java.lang.String token)
Removes
JWTTokenService.BEARER_PREFIX from the given value. |
void |
removeToken()
Removes token from the thread security context holder.
|
private void |
setApplicationName(JWTClaimsSet claimsSet,
Restores application name from custom claims if there is no application set in the given UUToken instance.
|
private void |
setCustomClaims(JWTClaimsSet claimsSet,
Sets custom claims to a UUToken.
|
private void |
setCustomClaims(UUToken token,
Sets additional claims to the given JWTClaimsSet instance.
|
void |
setToken(java.lang.String securedToken)
Sets token to using the thread security context holder.
|
parameters - Configuration parameters.conf - Properties with configuration.conf - Configuration.token - UES form token to be converted.JWTTokenServiceRTException - If the token cannot be converted.UUToken instance.token - Value to be parsed.null if the input value is null.JWTTokenServiceRTException - If the secured token cannot be parsed.claimsSet - Claims set.uuToken - UUToken instance where should be application name.securedToken - JWT token.value - Value to be surveyed.true if the value may be a JWT token, the value false otherwise.securedToken - Secured token.true if the secured token is valid; the value false otherwise.token - UES form token.JWTTokenService.BEARER_PREFIX to the given value.securedToken - Secured token.JWTTokenService.BEARER_PREFIX from the given value.token - UUToken value.claimsSet - Claim set.claimsSet - JWTClaimsSet instance.token - Token which contains additional claims.claimsSet - Claims set instance.result - UUToken instance.