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 void
addExtraData(String key, String value)
Adds additional data to the Access Token.protected long
defaultExpireTime()
String
getAuditTrackingId()
Gets the audit id.AuditConstants.TrackingIdKey
getAuditTrackingIdKey()
Get the audit tracking ID key for this token.long
getAuthTimeSeconds()
Gets the end user's authentication time in seconds.String
getClientId()
Gets the client's id.org.forgerock.json.JsonValue
getConfirmationKey()
Get's the tokens confirmation claim.long
getExpiryTime()
Gets the token's expiry time.String
getGrantType()
Gets the grant type.String
getNonce()
Gets the nonce.String
getRealm()
Gets the realm.String
getResourceOwnerId()
Gets the resource owner's id.protected String
getResourceString(String s)
Gets the display String for the given String.Set<String>
getScope()
Gets the scope.String
getSessionId()
Gets the session id used to create the authorisation codeString
getTokenId()
Gets the token's identifier.Map<String,Object>
getTokenInfo()
Gets the token's information.String
getTokenName()
Gets the token's name.String
getTokenType()
Gets the token type.protected void
setAuditTrackingId(String auditId)
Sets the audit id.protected void
setAuthorizationCode(String authorizationCode)
Sets the authorization code.protected void
setAuthTime(long authTime)
Sets the end user's original authentication time in seconds since epoch.void
setClaims(String claims)
protected void
setClientId(String clientId)
Sets the client's id.protected void
setConfirmationKey(org.forgerock.json.JsonValue confirmationKey)
Sets the confirmation key.protected void
setExpiryTime(long expiryTime)
Sets the expiry time.protected void
setGrantType(String grantType)
Sets the grant type.protected void
setId(String id)
Sets the token id.protected void
setNonce(String nonce)
Sets the nonce.protected void
setRedirectUri(String redirectUri)
Sets the redirect uri.protected void
setRefreshTokenId(String refreshTokenId)
Sets the refresh token id.protected void
setResourceOwnerId(String resourceOwnerId)
Sets the resource owner's id.protected void
setScope(Set<String> scope)
Sets the scope.protected void
setTokenName(String tokenName)
Sets the token name.protected void
setTokenType(String tokenType)
Sets the token type.Map<String,Object>
toMap()
Converts the token into aMap
of its key data.String
toString()
-
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 InvalidGrantException
Constructs 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 InvalidGrantException
Constructs 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:
setId
in classStatefulToken
- Parameters:
id
- The token id.
-
setResourceOwnerId
protected void setResourceOwnerId(String resourceOwnerId)
Sets the resource owner's id.- Overrides:
setResourceOwnerId
in classStatefulToken
- Parameters:
resourceOwnerId
- The resource owner's id.
-
setClientId
protected void setClientId(String clientId)
Sets the client's id.- Overrides:
setClientId
in classStatefulToken
- Parameters:
clientId
- The client's id.
-
setRedirectUri
protected void setRedirectUri(String redirectUri)
Sets the redirect uri.- Overrides:
setRedirectUri
in classStatefulToken
- Parameters:
redirectUri
- The redirect uri.
-
setScope
protected void setScope(Set<String> scope)
Sets the scope.- Overrides:
setScope
in classStatefulToken
- Parameters:
scope
- The scope.
-
setExpiryTime
protected void setExpiryTime(long expiryTime)
Sets the expiry time.- Overrides:
setExpiryTime
in classStatefulToken
- Parameters:
expiryTime
- The expiry time.
-
setTokenType
protected void setTokenType(String tokenType)
Sets the token type.- Overrides:
setTokenType
in classStatefulToken
- Parameters:
tokenType
- The token type.
-
setTokenName
protected void setTokenName(String tokenName)
Sets the token name.- Overrides:
setTokenName
in classStatefulToken
- Parameters:
tokenName
- The token name.
-
setGrantType
protected void setGrantType(String grantType)
Sets the grant type.- Overrides:
setGrantType
in classStatefulToken
- Parameters:
grantType
- The grant type.
-
getResourceString
protected String getResourceString(String s)
Gets the display String for the given String.- Overrides:
getResourceString
in classStatefulToken
- Parameters:
s
- The String.- Returns:
- The display String.
-
getScope
public Set<String> getScope()
Gets the scope.- Specified by:
getScope
in interfaceIntrospectableToken
- Overrides:
getScope
in classStatefulToken
- Returns:
- The scope.
-
getClientId
public String getClientId()
Gets the client's id.- Specified by:
getClientId
in interfaceIntrospectableToken
- Overrides:
getClientId
in classStatefulToken
- Returns:
- The client's id.
-
getResourceOwnerId
public String getResourceOwnerId()
Gets the resource owner's id.- Specified by:
getResourceOwnerId
in interfaceIntrospectableToken
- Overrides:
getResourceOwnerId
in classStatefulToken
- Returns:
- The resource owner's id.
-
getTokenId
public String getTokenId()
Gets the token's identifier.- Specified by:
getTokenId
in interfaceAccessToken
- Specified by:
getTokenId
in interfaceToken
- Overrides:
getTokenId
in classStatefulToken
- Returns:
- The token's id.
-
getRealm
public String getRealm()
Gets the realm.- Specified by:
getRealm
in interfaceIntrospectableToken
- Overrides:
getRealm
in classStatefulToken
- Returns:
- The realm.
-
getTokenName
public String getTokenName()
Gets the token's name.- Specified by:
getTokenName
in interfaceToken
- Overrides:
getTokenName
in classStatefulToken
- Returns:
- The token's name.
-
getExpiryTime
public long getExpiryTime()
Gets the token's expiry time.- Specified by:
getExpiryTime
in interfaceIntrospectableToken
- Overrides:
getExpiryTime
in classStatefulToken
- Returns:
- The token's expiry time.
-
getTokenType
public String getTokenType()
Gets the token type.- Specified by:
getTokenType
in interfaceAccessToken
- Overrides:
getTokenType
in 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:
getNonce
in interfaceAccessToken
- Returns:
- The nonce.
-
getSessionId
public String getSessionId()
Gets the session id used to create the authorisation code- Specified by:
getSessionId
in interfaceAccessToken
- Returns:
- The session id.
-
defaultExpireTime
protected long defaultExpireTime()
- Specified by:
defaultExpireTime
in classStatefulToken
-
getGrantType
public String getGrantType()
Gets the grant type.- Specified by:
getGrantType
in interfaceAccessToken
- Returns:
- The grant type.
-
getConfirmationKey
public org.forgerock.json.JsonValue getConfirmationKey()
Description copied from interface:AccessToken
Get's the tokens confirmation claim.- Specified by:
getConfirmationKey
in 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:Token
Converts the token into aMap
of its key data.- Specified by:
toMap
in interfaceAccessToken
- Specified by:
toMap
in interfaceToken
- Returns:
- A
Map
of the token's key data.
-
getTokenInfo
public Map<String,Object> getTokenInfo()
Description copied from interface:Token
Gets the token's information.- Specified by:
getTokenInfo
in interfaceToken
- Returns:
- A
Map
of the token's information.
-
getAuditTrackingIdKey
public AuditConstants.TrackingIdKey getAuditTrackingIdKey()
Description copied from interface:Token
Get the audit tracking ID key for this token.- Specified by:
getAuditTrackingIdKey
in 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
null
then this method will ensure that the key is not present in the map.- Specified by:
addExtraData
in 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:
getAuditTrackingId
in interfaceAccessToken
- Specified by:
getAuditTrackingId
in interfaceToken
- Overrides:
getAuditTrackingId
in classStatefulToken
- Returns:
- The audit id.
-
setAuthTime
protected void setAuthTime(long authTime)
Sets the end user's original authentication time in seconds since epoch.- Overrides:
setAuthTime
in classStatefulToken
- Parameters:
authTime
- The authentication time.
-
getAuthTimeSeconds
public long getAuthTimeSeconds()
Gets the end user's authentication time in seconds.- Specified by:
getAuthTimeSeconds
in interfaceIntrospectableToken
- Overrides:
getAuthTimeSeconds
in classStatefulToken
- Returns:
- The authentication time.
-
toString
public String toString()
- Overrides:
toString
in classorg.forgerock.json.JsonValue
-
-