Package org.forgerock.oauth2.core
Class StatefulAccessToken
- java.lang.Object
-
- org.forgerock.json.JsonValue
-
- org.forgerock.oauth2.core.StatefulToken
-
- org.forgerock.oauth2.core.StatefulAccessToken
-
- All Implemented Interfaces:
Cloneable,Iterable<org.forgerock.json.JsonValue>,AccessToken,IntrospectableToken,Token
public class StatefulAccessToken extends StatefulToken implements AccessToken
Models a OAuth2 access token.- Since:
- 12.0.0
-
-
Constructor Summary
Constructors Constructor Description StatefulAccessToken(String id, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, long expiryTime, RefreshToken refreshToken, String tokenName, String grantType, String nonce, String realm, String claims, String auditTrackingId, long authTime, org.forgerock.json.JsonValue confirmationKey)Constructs a new AccessToken.StatefulAccessToken(String id, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, long expiryTime, RefreshToken refreshToken, String tokenName, String grantType, String nonce, String realm, String claims, String auditTrackingId, org.forgerock.json.JsonValue confirmationKey)Constructs a new AccessToken.StatefulAccessToken(org.forgerock.json.JsonValue token)Constructs a new AccessToken backed with the data in the specified JsonValue.StatefulAccessToken(org.forgerock.json.JsonValue token, String tokenName, String tokenId)Constructs a new AccessToken backed with the data in the specified JsonValue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtraData(String key, String value)Adds additional data to the Access Token.protected longdefaultExpireTime()StringgetAuditTrackingId()Gets the audit id.AuditConstants.TrackingIdKeygetAuditTrackingIdKey()Get the audit tracking ID key for this token.longgetAuthTimeSeconds()Gets the end user's authentication time in seconds.StringgetClientId()Gets the client's id.org.forgerock.json.JsonValuegetConfirmationKey()Get's the tokens confirmation claim.longgetExpiryTime()Gets the token's expiry time.StringgetGrantType()Gets the grant type.StringgetNonce()Gets the nonce.StringgetRealm()Gets the realm.StringgetResourceOwnerId()Gets the resource owner's id.protected StringgetResourceString(String s)Gets the display String for the given String.Set<String>getScope()Gets the scope.StringgetSessionId()Gets the session id used to create the authorisation codeStringgetTokenId()Gets the token's identifier.Map<String,Object>getTokenInfo()Gets the token's information.StringgetTokenName()Gets the token's name.StringgetTokenType()Gets the token type.protected voidsetAuditTrackingId(String auditId)Sets the audit id.protected voidsetAuthorizationCode(String authorizationCode)Sets the authorization code.protected voidsetAuthTime(long authTime)Sets the end user's original authentication time in seconds since epoch.voidsetClaims(String claims)protected voidsetClientId(String clientId)Sets the client's id.protected voidsetConfirmationKey(org.forgerock.json.JsonValue confirmationKey)Sets the confirmation key.protected voidsetExpiryTime(long expiryTime)Sets the expiry time.protected voidsetGrantType(String grantType)Sets the grant type.protected voidsetId(String id)Sets the token id.protected voidsetNonce(String nonce)Sets the nonce.protected voidsetRedirectUri(String redirectUri)Sets the redirect uri.protected voidsetRefreshTokenId(String refreshTokenId)Sets the refresh token id.protected voidsetResourceOwnerId(String resourceOwnerId)Sets the resource owner's id.protected voidsetScope(Set<String> scope)Sets the scope.protected voidsetTokenName(String tokenName)Sets the token name.protected voidsetTokenType(String tokenType)Sets the token type.Map<String,Object>toMap()Converts the token into aMapof its key data.StringtoString()-
Methods inherited from class org.forgerock.oauth2.core.StatefulToken
getClaims, getSetProperty, getStringProperty, getTimeLeft, isExpired, setAuthGrantId, setStringProperty, toJsonValue
-
Methods inherited from class org.forgerock.json.JsonValue
add, add, add, add, addPermissive, array, as, asBigDecimal, asBoolean, asCollection, asCollection, asDouble, asEnum, asInteger, asList, asList, asLong, asMap, asMap, asMapOfList, asNumber, asSet, asSet, asString, asURI, clear, clone, contains, copy, defaultTo, diff, expect, field, fieldIfNotNull, get, get, get, getObject, getPointer, isBoolean, isCollection, isDefined, isEqualTo, isList, isMap, isNotNull, isNull, isNumber, isSet, isString, iterator, json, keys, object, object, patch, put, put, put, putPermissive, remove, remove, remove, required, set, setObject, size, toIndex
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.forgerock.oauth2.core.AccessToken
getClaims
-
Methods inherited from interface org.forgerock.oauth2.core.IntrospectableToken
isExpired
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.forgerock.oauth2.core.Token
toJsonValue
-
-
-
-
Constructor Detail
-
StatefulAccessToken
public StatefulAccessToken(org.forgerock.json.JsonValue token) throws InvalidGrantExceptionConstructs a new AccessToken backed with the data in the specified JsonValue.- Parameters:
token- The JsonValue of the token.- Throws:
InvalidGrantException- If the given token is not an Access Token.
-
StatefulAccessToken
public StatefulAccessToken(org.forgerock.json.JsonValue token, String tokenName, String tokenId) throws InvalidGrantExceptionConstructs a new AccessToken backed with the data in the specified JsonValue.- Parameters:
token- The JsonValue of the token.tokenName- The token name.tokenId- The token identifier.- Throws:
InvalidGrantException- If the given token is not an Access Token.
-
StatefulAccessToken
public StatefulAccessToken(String id, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, long expiryTime, RefreshToken refreshToken, String tokenName, String grantType, String nonce, String realm, String claims, String auditTrackingId, org.forgerock.json.JsonValue confirmationKey)
Constructs a new AccessToken.- Parameters:
id- The token id.authorizationCode- The authorization code.resourceOwnerId- The resource owner's id.clientId- The client's id.redirectUri- The redirect uri.scope- The scope.expiryTime- The expiry time.refreshToken- The refresh token.tokenName- The token name.grantType- The grant type.nonce- The nonce.realm- The realm.claims- The requested claims.auditTrackingId- The tracking ID, used for tracking tokens throughout the audit logs.confirmationKey- JSON confirmation key
-
StatefulAccessToken
public StatefulAccessToken(String id, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, long expiryTime, RefreshToken refreshToken, String tokenName, String grantType, String nonce, String realm, String claims, String auditTrackingId, long authTime, org.forgerock.json.JsonValue confirmationKey)
Constructs a new AccessToken.- Parameters:
id- The token id.authorizationCode- The authorization code.resourceOwnerId- The resource owner's id.clientId- The client's id.redirectUri- The redirect uri.scope- The scope.expiryTime- The expiry time.refreshToken- The refresh token.tokenName- The token name.grantType- The grant type.nonce- The nonce.realm- The realm.claims- The requested claims.auditTrackingId- The tracking ID, used for tracking tokens throughout the audit logs.authTime- The end user's original auth time.confirmationKey- JSON confirmation key
-
-
Method Detail
-
setClaims
public void setClaims(String claims)
-
setId
protected void setId(String id)
Sets the token id.- Overrides:
setIdin classStatefulToken- Parameters:
id- The token id.
-
setResourceOwnerId
protected void setResourceOwnerId(String resourceOwnerId)
Sets the resource owner's id.- Overrides:
setResourceOwnerIdin classStatefulToken- Parameters:
resourceOwnerId- The resource owner's id.
-
setClientId
protected void setClientId(String clientId)
Sets the client's id.- Overrides:
setClientIdin classStatefulToken- Parameters:
clientId- The client's id.
-
setRedirectUri
protected void setRedirectUri(String redirectUri)
Sets the redirect uri.- Overrides:
setRedirectUriin classStatefulToken- Parameters:
redirectUri- The redirect uri.
-
setScope
protected void setScope(Set<String> scope)
Sets the scope.- Overrides:
setScopein classStatefulToken- Parameters:
scope- The scope.
-
setExpiryTime
protected void setExpiryTime(long expiryTime)
Sets the expiry time.- Overrides:
setExpiryTimein classStatefulToken- Parameters:
expiryTime- The expiry time.
-
setTokenType
protected void setTokenType(String tokenType)
Sets the token type.- Overrides:
setTokenTypein classStatefulToken- Parameters:
tokenType- The token type.
-
setTokenName
protected void setTokenName(String tokenName)
Sets the token name.- Overrides:
setTokenNamein classStatefulToken- Parameters:
tokenName- The token name.
-
setGrantType
protected void setGrantType(String grantType)
Sets the grant type.- Overrides:
setGrantTypein classStatefulToken- Parameters:
grantType- The grant type.
-
getResourceString
protected String getResourceString(String s)
Gets the display String for the given String.- Overrides:
getResourceStringin classStatefulToken- Parameters:
s- The String.- Returns:
- The display String.
-
getScope
public Set<String> getScope()
Gets the scope.- Specified by:
getScopein interfaceIntrospectableToken- Overrides:
getScopein classStatefulToken- Returns:
- The scope.
-
getClientId
public String getClientId()
Gets the client's id.- Specified by:
getClientIdin interfaceIntrospectableToken- Overrides:
getClientIdin classStatefulToken- Returns:
- The client's id.
-
getResourceOwnerId
public String getResourceOwnerId()
Gets the resource owner's id.- Specified by:
getResourceOwnerIdin interfaceIntrospectableToken- Overrides:
getResourceOwnerIdin classStatefulToken- Returns:
- The resource owner's id.
-
getTokenId
public String getTokenId()
Gets the token's identifier.- Specified by:
getTokenIdin interfaceAccessToken- Specified by:
getTokenIdin interfaceToken- Overrides:
getTokenIdin classStatefulToken- Returns:
- The token's id.
-
getRealm
public String getRealm()
Gets the realm.- Specified by:
getRealmin interfaceIntrospectableToken- Overrides:
getRealmin classStatefulToken- Returns:
- The realm.
-
getTokenName
public String getTokenName()
Gets the token's name.- Specified by:
getTokenNamein interfaceToken- Overrides:
getTokenNamein classStatefulToken- Returns:
- The token's name.
-
getExpiryTime
public long getExpiryTime()
Gets the token's expiry time.- Specified by:
getExpiryTimein interfaceIntrospectableToken- Overrides:
getExpiryTimein classStatefulToken- Returns:
- The token's expiry time.
-
getTokenType
public String getTokenType()
Gets the token type.- Specified by:
getTokenTypein interfaceAccessToken- Overrides:
getTokenTypein classStatefulToken- Returns:
- The token type.
-
setAuthorizationCode
protected void setAuthorizationCode(String authorizationCode)
Sets the authorization code.- Parameters:
authorizationCode- The authorization code.
-
setRefreshTokenId
protected void setRefreshTokenId(String refreshTokenId)
Sets the refresh token id.- Parameters:
refreshTokenId- The refresh token id.
-
setNonce
protected void setNonce(String nonce)
Sets the nonce.- Parameters:
nonce- The nonce.
-
getNonce
public String getNonce()
Gets the nonce.- Specified by:
getNoncein interfaceAccessToken- Returns:
- The nonce.
-
getSessionId
public String getSessionId()
Gets the session id used to create the authorisation code- Specified by:
getSessionIdin interfaceAccessToken- Returns:
- The session id.
-
defaultExpireTime
protected long defaultExpireTime()
- Specified by:
defaultExpireTimein classStatefulToken
-
getGrantType
public String getGrantType()
Gets the grant type.- Specified by:
getGrantTypein interfaceAccessToken- Returns:
- The grant type.
-
getConfirmationKey
public org.forgerock.json.JsonValue getConfirmationKey()
Description copied from interface:AccessTokenGet's the tokens confirmation claim.- Specified by:
getConfirmationKeyin interfaceAccessToken- Returns:
- the JSON confirmation key
-
setConfirmationKey
protected void setConfirmationKey(org.forgerock.json.JsonValue confirmationKey)
Sets the confirmation key.- Parameters:
confirmationKey- the non-null JSON confirmation key
-
toMap
public Map<String,Object> toMap()
Description copied from interface:TokenConverts the token into aMapof its key data.- Specified by:
toMapin interfaceAccessToken- Specified by:
toMapin interfaceToken- Returns:
- A
Mapof the token's key data.
-
getTokenInfo
public Map<String,Object> getTokenInfo()
Description copied from interface:TokenGets the token's information.- Specified by:
getTokenInfoin interfaceToken- Returns:
- A
Mapof the token's information.
-
getAuditTrackingIdKey
public AuditConstants.TrackingIdKey getAuditTrackingIdKey()
Description copied from interface:TokenGet the audit tracking ID key for this token.- Specified by:
getAuditTrackingIdKeyin interfaceToken- Returns:
- The tracking ID key.
-
addExtraData
public void addExtraData(String key, String value)
Adds additional data to the Access Token.
If the value is
nullthen this method will ensure that the key is not present in the map.- Specified by:
addExtraDatain interfaceAccessToken- Parameters:
key- The key.value- The value.
-
setAuditTrackingId
protected void setAuditTrackingId(String auditId)
Sets the audit id.- Parameters:
auditId- The audit id.
-
getAuditTrackingId
public String getAuditTrackingId()
Gets the audit id.- Specified by:
getAuditTrackingIdin interfaceAccessToken- Specified by:
getAuditTrackingIdin interfaceToken- Overrides:
getAuditTrackingIdin classStatefulToken- Returns:
- The audit id.
-
setAuthTime
protected void setAuthTime(long authTime)
Sets the end user's original authentication time in seconds since epoch.- Overrides:
setAuthTimein classStatefulToken- Parameters:
authTime- The authentication time.
-
getAuthTimeSeconds
public long getAuthTimeSeconds()
Gets the end user's authentication time in seconds.- Specified by:
getAuthTimeSecondsin interfaceIntrospectableToken- Overrides:
getAuthTimeSecondsin classStatefulToken- Returns:
- The authentication time.
-
toString
public String toString()
- Overrides:
toStringin classorg.forgerock.json.JsonValue
-
-