Class TokenClaimsSet
- java.lang.Object
-
- net.shibboleth.idp.plugin.oidc.op.token.support.TokenClaimsSet
-
- Direct Known Subclasses:
AccessTokenClaimsSet,AuthorizeCodeClaimsSet,RefreshTokenClaimsSet
@NotThreadSafe public class TokenClaimsSet extends Object
Class to extend for token claims sets. Offers the base functionality to Authorize Code, Refresh Token and Access Token.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTokenClaimsSet.Builder<T extends TokenClaimsSet>Abstract builder to extend builders from that are instantiating claims sets extending TokenClaimsSet.
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_AC_IDIdentifier for the token.static StringKEY_ACRAuthentication context class reference value of the performed authentication.static StringKEY_AUDIENCEAudiences of the token request.static StringKEY_AUTH_TIMEAuthentication time of the performed authentication.static StringKEY_CLAIMSClaims request of the original authentication request.static StringKEY_CLIENTIDClient id of the rp the token is generated for.static StringKEY_CODE_CHALLENGECode Challenge.static StringKEY_CONSENT_ENABLEDWhether consent has been enabled.static StringKEY_CONSENTED_CLAIMSClaims/Attributes having consent.static StringKEY_DELIVERY_CLAIMSClaims set for token delivery.static StringKEY_DELIVERY_CLAIMS_IDTOKENClaims set for token delivery, id token only.static StringKEY_DELIVERY_CLAIMS_USERINFOClaims set for token delivery, user info only.static StringKEY_EXPIRATION_TIMEExpiration time of the token.static StringKEY_ISSUED_ATIssue time of the token.static StringKEY_ISSUEROP issuer.static StringKEY_LEGACY_CLIENTIDClient id of the rp the token is generated for (old constant).static StringKEY_NONCENonce of the original authentication request.static StringKEY_NOTBEFORE_TIMENot before time of the token.static StringKEY_REDIRECT_URIRedirect uri of the original authentication request.static StringKEY_ROOT_JTIIdentifier for the root token in the chain.static StringKEY_SCOPEScope of the token request.static StringKEY_SEALED_FOR_OPCustom claim name for sealed claims embedded inside JWT.static StringKEY_SESSION_IDIdentifier for the session id.static StringKEY_SUBJECTSubject of the user.static StringKEY_TYPEType of the token.static StringKEY_USER_PRINCIPALUser principal representing authenticated user.private org.slf4j.LoggerlogClass logger.private com.nimbusds.jwt.JWTClaimsSettokenClaimsSetClaims set for the claim.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTokenClaimsSet()Default constructor for some subclasses.protectedTokenClaimsSet(com.nimbusds.jwt.JWTClaimsSet jwt)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetACR()Get acr of the performed authentication.List<String>getAudience()Get audience of the token.InstantgetAuthenticationTime()Get auth time of the user.com.nimbusds.openid.connect.sdk.OIDCClaimsRequestgetClaimsRequest()Get claims request of the authentication request.com.nimbusds.jwt.JWTClaimsSetgetClaimsSet()Get the token claims set.com.nimbusds.oauth2.sdk.id.ClientIDgetClientID()Get Client ID of the token.StringgetCodeChallenge()Get code challenge of the authentication request.List<Object>getConsentedClaims()Get consented claims.com.nimbusds.openid.connect.sdk.claims.ClaimsSetgetDeliveryClaims()Get token delivery claims.InstantgetExp()Get expiration time of the token.StringgetID()Get the id of the token.com.nimbusds.openid.connect.sdk.claims.ClaimsSetgetIDTokenDeliveryClaims()Get id token token delivery claims.InstantgetIssuedAt()Get issuance time of the token.StringgetIssuer()Get the issuer.com.nimbusds.openid.connect.sdk.NoncegetNonce()Get nonce of the authentication request.InstantgetNotBefore()Get not before time of the token, if any.StringgetPrincipal()Get principal of the user.URIgetRedirectURI()Get redirect uri of the request.StringgetRootTokenIdentifier()Get the root token identifier.com.nimbusds.oauth2.sdk.ScopegetScope()Get scope of the token.StringgetSessionIdentifier()Get the session identifier.StringgetSubject()Get subject claim.StringgetType()Get type of the claims set.com.nimbusds.openid.connect.sdk.claims.ClaimsSetgetUserinfoDeliveryClaims()Get user info response token delivery claims.booleanisConsentEnabled()Get whether consent has been enabled.booleanisExpired()Deprecated, for removal: This API element is subject to removal in a future version.booleanisTimeValid()Check if the token is valid with respect to expiration and not before limits.Stringserialize()Serialize the token as JSON String.Stringserialize(DataSealer dataSealer)Serialize the token as JSON String wrapped with sealer.voidsetClaimsSet(com.nimbusds.jwt.JWTClaimsSet claimsSet)Set the token claims set.protected static voidverifyParsedClaims(String tokenType, com.nimbusds.jwt.JWTClaimsSet tokenClaimsSet)Helper to verify parsed claims are what is expected.
-
-
-
Field Detail
-
KEY_AC_ID
@Nonnull @NotEmpty public static final String KEY_AC_ID
Identifier for the token.- See Also:
- Constant Field Values
-
KEY_TYPE
@Nonnull @NotEmpty public static final String KEY_TYPE
Type of the token.- See Also:
- Constant Field Values
-
KEY_ISSUER
@Nonnull @NotEmpty public static final String KEY_ISSUER
OP issuer.- See Also:
- Constant Field Values
-
KEY_USER_PRINCIPAL
@Nonnull @NotEmpty public static final String KEY_USER_PRINCIPAL
User principal representing authenticated user.- See Also:
- Constant Field Values
-
KEY_SUBJECT
@Nonnull @NotEmpty public static final String KEY_SUBJECT
Subject of the user.- See Also:
- Constant Field Values
-
KEY_CLIENTID
@Nonnull @NotEmpty public static final String KEY_CLIENTID
Client id of the rp the token is generated for.- See Also:
- Constant Field Values
-
KEY_LEGACY_CLIENTID
@Nonnull @NotEmpty public static final String KEY_LEGACY_CLIENTID
Client id of the rp the token is generated for (old constant).- See Also:
- Constant Field Values
-
KEY_EXPIRATION_TIME
@Nonnull @NotEmpty public static final String KEY_EXPIRATION_TIME
Expiration time of the token.- See Also:
- Constant Field Values
-
KEY_NOTBEFORE_TIME
@Nonnull @NotEmpty public static final String KEY_NOTBEFORE_TIME
Not before time of the token.- See Also:
- Constant Field Values
-
KEY_ISSUED_AT
@Nonnull @NotEmpty public static final String KEY_ISSUED_AT
Issue time of the token.- See Also:
- Constant Field Values
-
KEY_ACR
@Nonnull @NotEmpty public static final String KEY_ACR
Authentication context class reference value of the performed authentication.- See Also:
- Constant Field Values
-
KEY_NONCE
@Nonnull @NotEmpty public static final String KEY_NONCE
Nonce of the original authentication request.- See Also:
- Constant Field Values
-
KEY_AUTH_TIME
@Nonnull @NotEmpty public static final String KEY_AUTH_TIME
Authentication time of the performed authentication.- See Also:
- Constant Field Values
-
KEY_REDIRECT_URI
@Nonnull @NotEmpty public static final String KEY_REDIRECT_URI
Redirect uri of the original authentication request.- See Also:
- Constant Field Values
-
KEY_SCOPE
@Nonnull @NotEmpty public static final String KEY_SCOPE
Scope of the token request.- See Also:
- Constant Field Values
-
KEY_AUDIENCE
@Nonnull @NotEmpty public static final String KEY_AUDIENCE
Audiences of the token request.- See Also:
- Constant Field Values
-
KEY_CLAIMS
@Nonnull @NotEmpty public static final String KEY_CLAIMS
Claims request of the original authentication request.- See Also:
- Constant Field Values
-
KEY_DELIVERY_CLAIMS
@Nonnull @NotEmpty public static final String KEY_DELIVERY_CLAIMS
Claims set for token delivery.- See Also:
- Constant Field Values
-
KEY_DELIVERY_CLAIMS_IDTOKEN
@Nonnull @NotEmpty public static final String KEY_DELIVERY_CLAIMS_IDTOKEN
Claims set for token delivery, id token only.- See Also:
- Constant Field Values
-
KEY_DELIVERY_CLAIMS_USERINFO
@Nonnull @NotEmpty public static final String KEY_DELIVERY_CLAIMS_USERINFO
Claims set for token delivery, user info only.- See Also:
- Constant Field Values
-
KEY_CONSENTED_CLAIMS
@Nonnull @NotEmpty public static final String KEY_CONSENTED_CLAIMS
Claims/Attributes having consent.- See Also:
- Constant Field Values
-
KEY_CONSENT_ENABLED
@Nonnull @NotEmpty public static final String KEY_CONSENT_ENABLED
Whether consent has been enabled.- See Also:
- Constant Field Values
-
KEY_CODE_CHALLENGE
@Nonnull @NotEmpty public static final String KEY_CODE_CHALLENGE
Code Challenge.- See Also:
- Constant Field Values
-
KEY_SEALED_FOR_OP
@Nonnull @NotEmpty public static final String KEY_SEALED_FOR_OP
Custom claim name for sealed claims embedded inside JWT.- See Also:
- Constant Field Values
-
KEY_ROOT_JTI
@Nonnull @NotEmpty public static final String KEY_ROOT_JTI
Identifier for the root token in the chain.- See Also:
- Constant Field Values
-
KEY_SESSION_ID
@Nonnull @NotEmpty public static final String KEY_SESSION_ID
Identifier for the session id.- See Also:
- Constant Field Values
-
tokenClaimsSet
@Nullable private com.nimbusds.jwt.JWTClaimsSet tokenClaimsSet
Claims set for the claim.
-
log
@Nonnull private org.slf4j.Logger log
Class logger.
-
-
Method Detail
-
verifyParsedClaims
protected static void verifyParsedClaims(@Nonnull @NotEmpty String tokenType, @Nonnull com.nimbusds.jwt.JWTClaimsSet tokenClaimsSet) throws ParseException
Helper to verify parsed claims are what is expected.- Parameters:
tokenType- The type of the expected tokentokenClaimsSet- token claims set- Throws:
ParseException- if claims set is not expected one.
-
serialize
@Nonnull @NotEmpty public String serialize()
Serialize the token as JSON String.- Returns:
- token as JSON String
-
serialize
@Nonnull public String serialize(@Nonnull DataSealer dataSealer) throws DataSealerException
Serialize the token as JSON String wrapped with sealer.- Parameters:
dataSealer- data sealer to wrap the JSON serialization- Returns:
- token as JSON String wrapped with sealer
- Throws:
DataSealerException- is thrown if unwrapping fails
-
setClaimsSet
public void setClaimsSet(@Nonnull com.nimbusds.jwt.JWTClaimsSet claimsSet)Set the token claims set.- Parameters:
claimsSet- What to set
-
getClaimsSet
@Nullable public com.nimbusds.jwt.JWTClaimsSet getClaimsSet()
Get the token claims set.- Returns:
- token claims set
-
getIssuedAt
@Nonnull public Instant getIssuedAt()
Get issuance time of the token.- Returns:
- issuance time
- Since:
- 3.1.0
-
getExp
@Nonnull public Instant getExp()
Get expiration time of the token.- Returns:
- expiration time of the token
-
getNotBefore
@Nullable public Instant getNotBefore()
Get not before time of the token, if any.- Returns:
- not before time of the token
- Since:
- 3.1.0
-
isExpired
@Deprecated(since="3.1.0", forRemoval=true) public boolean isExpired()
Deprecated, for removal: This API element is subject to removal in a future version.Check if the token is expired.Replaced by
isTimeValid()method that enforces both bounds.- Returns:
- true if the token is expired, otherwise false
-
isTimeValid
public boolean isTimeValid()
Check if the token is valid with respect to expiration and not before limits.- Returns:
- true iff token is time valid
- Since:
- 3.1.0
-
getRedirectURI
@Nullable public URI getRedirectURI()
Get redirect uri of the request.- Returns:
- redirect uri of the request, null if not located.
-
getACR
@Nullable public String getACR()
Get acr of the performed authentication.- Returns:
- acr of the performed authentication.
-
getType
@Nullable public String getType()
Get type of the claims set.- Returns:
- Type of the claims set.
-
getPrincipal
@Nullable public String getPrincipal()
Get principal of the user.- Returns:
- principal of the user.
-
getSubject
@Nullable public String getSubject()
Get subject claim.- Returns:
- subject claim
- Since:
- 3.1.0
-
getAuthenticationTime
@Nullable public Instant getAuthenticationTime()
Get auth time of the user.- Returns:
- auth time of the user.
-
getNonce
@Nullable public com.nimbusds.openid.connect.sdk.Nonce getNonce()
Get nonce of the authentication request.- Returns:
- nonce of the authentication request.
-
getClaimsRequest
@Nullable public com.nimbusds.openid.connect.sdk.OIDCClaimsRequest getClaimsRequest()
Get claims request of the authentication request.- Returns:
- claims request in authentication request, null if not existing.
-
getDeliveryClaims
@Nullable public com.nimbusds.openid.connect.sdk.claims.ClaimsSet getDeliveryClaims()
Get token delivery claims.- Returns:
- token delivery claims
-
getIDTokenDeliveryClaims
@Nullable public com.nimbusds.openid.connect.sdk.claims.ClaimsSet getIDTokenDeliveryClaims()
Get id token token delivery claims.- Returns:
- id token token delivery claims
-
getUserinfoDeliveryClaims
@Nullable public com.nimbusds.openid.connect.sdk.claims.ClaimsSet getUserinfoDeliveryClaims()
Get user info response token delivery claims.- Returns:
- user info response token delivery claims
-
getConsentedClaims
@Nullable @NonnullElements public List<Object> getConsentedClaims()
Get consented claims.- Returns:
- consented claims
-
isConsentEnabled
public boolean isConsentEnabled()
Get whether consent has been enabled.- Returns:
- whether consent has been enabled
-
getScope
@Nullable public com.nimbusds.oauth2.sdk.Scope getScope()
Get scope of the token.- Returns:
- scope of the token
-
getAudience
@Nonnull @NonnullElements @NotLive @Unmodifiable public List<String> getAudience()
Get audience of the token.- Returns:
- audience of the token
- Since:
- 3.1.0
-
getCodeChallenge
@Nullable public String getCodeChallenge()
Get code challenge of the authentication request.- Returns:
- code challenge of the authentication request.
-
getID
@Nullable public String getID()
Get the id of the token.- Returns:
- id of the token
-
getClientID
@Nullable public com.nimbusds.oauth2.sdk.id.ClientID getClientID()
Get Client ID of the token.- Returns:
- Client ID of the token
-
getRootTokenIdentifier
@Nullable public String getRootTokenIdentifier()
Get the root token identifier.- Returns:
- the root token identifier.
- Since:
- 3.2.0
-
getSessionIdentifier
@Nullable public String getSessionIdentifier()
Get the session identifier.- Returns:
- the session identifier.
- Since:
- 3.3.0
-
-