Class IDTokenClaimsSet
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.claims.ClaimsSet
-
- com.nimbusds.openid.connect.sdk.claims.IDTokenClaimsSet
-
- All Implemented Interfaces:
net.minidev.json.JSONAware
public class IDTokenClaimsSet extends ClaimsSet
ID token claims set, serialisable to a JSON object.Example ID token claims set:
{ "iss" : "https://server.example.com", "sub" : "24400320", "aud" : "s6BhdRkqt3", "nonce" : "n-0S6_WzA2Mj", "exp" : 1311281970, "iat" : 1311280970, "auth_time" : 1311280969, "acr" : "urn:mace:incommon:iap:silver", "at_hash" : "MTIzNDU2Nzg5MDEyMzQ1Ng" }Related specifications:
- OpenID Connect Core 1.0, section 2.
- OpenID Connect Front-Channel Logout 1.0, section 3 (draft 02).
- Financial Services – Financial API - Part 2: Read and Write API Security Profile, section 5.1.
-
-
Field Summary
Fields Modifier and Type Field Description static StringACR_CLAIM_NAMEThe ACR claim name.static StringAMR_CLAIM_NAMEThe AMRs claim name.static StringAT_HASH_CLAIM_NAMEThe access token hash claim name.static StringAUD_CLAIM_NAMEThe audience claim name.static StringAUTH_TIME_CLAIM_NAMEThe subject authentication time claim name.static StringAZP_CLAIM_NAMEThe authorised party claim name.static StringC_HASH_CLAIM_NAMEThe authorisation code hash claim name.static StringEXP_CLAIM_NAMEThe expiration time claim name.static StringIAT_CLAIM_NAMEThe issue time claim name.static StringISS_CLAIM_NAMEThe issuer claim name.static StringNONCE_CLAIM_NAMEThe nonce claim name.static StringS_HASH_CLAIM_NAMEThe state hash claim name.static StringSID_CLAIM_NAMEThe session identifier claim name.static StringSUB_CLAIM_NAMEThe subject claim name.static StringSUB_JWK_CLAIM_NAMEThe subject JWK claim name.
-
Constructor Summary
Constructors Constructor Description IDTokenClaimsSet(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet)Creates a new ID token claims set from the specified JSON Web Token (JWT) claims set.IDTokenClaimsSet(Issuer iss, Subject sub, List<Audience> aud, Date exp, Date iat)Creates a new minimal ID token claims set.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AccessTokenHashgetAccessTokenHash()Gets the access token hash.ACRgetACR()Gets the Authentication Context Class Reference (ACR).List<AMR>getAMR()Gets the Authentication Methods References (AMRs).List<Audience>getAudience()Gets the audience.DategetAuthenticationTime()Gets the subject authentication time.AuthorizedPartygetAuthorizedParty()Gets the authorised party for the ID token.CodeHashgetCodeHash()Gets the authorisation code hash.DategetExpirationTime()Gets the ID token expiration time.IssuergetIssuer()Gets the issuer.DategetIssueTime()Gets the issue time.NoncegetNonce()Gets the ID token nonce.SessionIDgetSessionID()Gets the session ID.static Set<String>getStandardClaimNames()Gets the names of the standard top-level ID token claims.StateHashgetStateHash()Gets the state hash.SubjectgetSubject()Gets the subject.com.nimbusds.jose.jwk.JWKgetSubjectJWK()Gets the subject's JSON Web Key (JWK) for a self-issued OpenID Connect provider.booleanhasRequiredClaims(ResponseType responseType)Deprecated.booleanhasRequiredClaims(ResponseType responseType, boolean iatAuthzEndpoint)Checks if this ID token claims set contains all required claims for the specified OpenID Connect response type.static IDTokenClaimsSetparse(String json)Parses an ID token claims set from the specified JSON object string.static IDTokenClaimsSetparse(net.minidev.json.JSONObject jsonObject)Parses an ID token claims set from the specified JSON object.voidsetAccessTokenHash(AccessTokenHash atHash)Sets the access token hash.voidsetACR(ACR acr)Sets the Authentication Context Class Reference (ACR).voidsetAMR(List<AMR> amr)Sets the Authentication Methods References (AMRs).voidsetAuthenticationTime(Date authTime)Sets the subject authentication time.voidsetAuthorizedParty(AuthorizedParty azp)Sets the authorised party for the ID token.voidsetCodeHash(CodeHash cHash)Sets the authorisation code hash.voidsetNonce(Nonce nonce)Sets the ID token nonce.voidsetSessionID(SessionID sid)Sets the session ID.voidsetStateHash(StateHash sHash)Sets the state hash.voidsetSubjectJWK(com.nimbusds.jose.jwk.JWK subJWK)Sets the subject's JSON Web Key (JWK) for a self-issued OpenID Connect provider.-
Methods inherited from class com.nimbusds.openid.connect.sdk.claims.ClaimsSet
getBooleanClaim, getClaim, getClaim, getDateClaim, getEmailClaim, getLangTaggedClaim, getNumberClaim, getStringClaim, getStringClaim, getStringListClaim, getURIClaim, getURLClaim, putAll, putAll, setAudience, setAudience, setClaim, setClaim, setDateClaim, setEmailClaim, setIssuer, setURIClaim, setURLClaim, toJSONObject, toJSONString, toJWTClaimsSet
-
-
-
-
Field Detail
-
EXP_CLAIM_NAME
public static final String EXP_CLAIM_NAME
The expiration time claim name.- See Also:
- Constant Field Values
-
AUTH_TIME_CLAIM_NAME
public static final String AUTH_TIME_CLAIM_NAME
The subject authentication time claim name.- See Also:
- Constant Field Values
-
NONCE_CLAIM_NAME
public static final String NONCE_CLAIM_NAME
The nonce claim name.- See Also:
- Constant Field Values
-
AT_HASH_CLAIM_NAME
public static final String AT_HASH_CLAIM_NAME
The access token hash claim name.- See Also:
- Constant Field Values
-
C_HASH_CLAIM_NAME
public static final String C_HASH_CLAIM_NAME
The authorisation code hash claim name.- See Also:
- Constant Field Values
-
S_HASH_CLAIM_NAME
public static final String S_HASH_CLAIM_NAME
The state hash claim name.- See Also:
- Constant Field Values
-
ACR_CLAIM_NAME
public static final String ACR_CLAIM_NAME
The ACR claim name.- See Also:
- Constant Field Values
-
AMR_CLAIM_NAME
public static final String AMR_CLAIM_NAME
The AMRs claim name.- See Also:
- Constant Field Values
-
AZP_CLAIM_NAME
public static final String AZP_CLAIM_NAME
The authorised party claim name.- See Also:
- Constant Field Values
-
SUB_JWK_CLAIM_NAME
public static final String SUB_JWK_CLAIM_NAME
The subject JWK claim name.- See Also:
- Constant Field Values
-
ISS_CLAIM_NAME
public static final String ISS_CLAIM_NAME
The issuer claim name.- See Also:
- Constant Field Values
-
SUB_CLAIM_NAME
public static final String SUB_CLAIM_NAME
The subject claim name.- See Also:
- Constant Field Values
-
AUD_CLAIM_NAME
public static final String AUD_CLAIM_NAME
The audience claim name.- See Also:
- Constant Field Values
-
IAT_CLAIM_NAME
public static final String IAT_CLAIM_NAME
The issue time claim name.- See Also:
- Constant Field Values
-
SID_CLAIM_NAME
public static final String SID_CLAIM_NAME
The session identifier claim name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IDTokenClaimsSet
public IDTokenClaimsSet(Issuer iss, Subject sub, List<Audience> aud, Date exp, Date iat)
Creates a new minimal ID token claims set. Note that the ID token may require additional claims to be present depending on the original OpenID Connect authorisation request.- Parameters:
iss- The issuer. Must not benull.sub- The subject. Must not benull.aud- The audience. Must not benull.exp- The expiration time. Must not benull.iat- The issue time. Must not benull.
-
IDTokenClaimsSet
public IDTokenClaimsSet(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet) throws ParseException
Creates a new ID token claims set from the specified JSON Web Token (JWT) claims set.- Parameters:
jwtClaimsSet- The JWT claims set. Must not benull.- Throws:
ParseException- If the JWT claims set doesn't represent a valid ID token claims set.
-
-
Method Detail
-
getStandardClaimNames
public static Set<String> getStandardClaimNames()
Gets the names of the standard top-level ID token claims.- Returns:
- The names of the standard top-level ID token claims (read-only set).
-
hasRequiredClaims
public boolean hasRequiredClaims(ResponseType responseType, boolean iatAuthzEndpoint)
Checks if this ID token claims set contains all required claims for the specified OpenID Connect response type.- Parameters:
responseType- The OpenID Connect response type. Must not benull.iatAuthzEndpoint- Specifies the endpoint where the ID token was issued (required for hybrid flow).trueif the ID token was issued at the authorisation endpoint,falseif the ID token was issued at the token endpoint.- Returns:
trueif the required claims are contained, elsefalse.
-
hasRequiredClaims
@Deprecated public boolean hasRequiredClaims(ResponseType responseType)
Deprecated.UsehasRequiredClaims(ResponseType, boolean)instead.- Parameters:
responseType- The OpenID Connect response type. Must not benull.- Returns:
trueif the required claims are contained, elsefalse.
-
getExpirationTime
public Date getExpirationTime()
Gets the ID token expiration time. Corresponds to theexpclaim.- Returns:
- The expiration time.
-
getAuthenticationTime
public Date getAuthenticationTime()
Gets the subject authentication time. Corresponds to theauth_timeclaim.- Returns:
- The authentication time,
nullif not specified or parsing failed.
-
setAuthenticationTime
public void setAuthenticationTime(Date authTime)
Sets the subject authentication time. Corresponds to theauth_timeclaim.- Parameters:
authTime- The authentication time,nullif not specified.
-
getNonce
public Nonce getNonce()
Gets the ID token nonce. Corresponds to thenonceclaim.- Returns:
- The nonce,
nullif not specified or parsing failed.
-
setNonce
public void setNonce(Nonce nonce)
Sets the ID token nonce. Corresponds to thenonceclaim.- Parameters:
nonce- The nonce,nullif not specified.
-
getAccessTokenHash
public AccessTokenHash getAccessTokenHash()
Gets the access token hash. Corresponds to theat_hashclaim.- Returns:
- The access token hash,
nullif not specified or parsing failed.
-
setAccessTokenHash
public void setAccessTokenHash(AccessTokenHash atHash)
Sets the access token hash. Corresponds to theat_hashclaim.- Parameters:
atHash- The access token hash,nullif not specified.
-
getCodeHash
public CodeHash getCodeHash()
Gets the authorisation code hash. Corresponds to thec_hashclaim.- Returns:
- The authorisation code hash,
nullif not specified or parsing failed.
-
setCodeHash
public void setCodeHash(CodeHash cHash)
Sets the authorisation code hash. Corresponds to thec_hashclaim.- Parameters:
cHash- The authorisation code hash,nullif not specified.
-
getStateHash
public StateHash getStateHash()
Gets the state hash. Corresponds to thes_hashclaim.- Returns:
- The state hash,
nullif not specified or parsing failed.
-
setStateHash
public void setStateHash(StateHash sHash)
Sets the state hash. Corresponds to thes_hashclaim.- Parameters:
sHash- The state hash,nullif not specified.
-
getACR
public ACR getACR()
Gets the Authentication Context Class Reference (ACR). Corresponds to theacrclaim.- Returns:
- The Authentication Context Class Reference (ACR),
nullif not specified or parsing failed.
-
setACR
public void setACR(ACR acr)
Sets the Authentication Context Class Reference (ACR). Corresponds to theacrclaim.- Parameters:
acr- The Authentication Context Class Reference (ACR),nullif not specified.
-
getAMR
public List<AMR> getAMR()
Gets the Authentication Methods References (AMRs). Corresponds to theamrclaim.- Returns:
- The Authentication Methods Reference (AMR) list,
nullif not specified or parsing failed.
-
setAMR
public void setAMR(List<AMR> amr)
Sets the Authentication Methods References (AMRs). Corresponds to theamrclaim.- Parameters:
amr- The Authentication Methods Reference (AMR) list,nullif not specified.
-
getAuthorizedParty
public AuthorizedParty getAuthorizedParty()
Gets the authorised party for the ID token. Corresponds to theazpclaim.- Returns:
- The authorised party,
nullif not specified or parsing failed.
-
setAuthorizedParty
public void setAuthorizedParty(AuthorizedParty azp)
Sets the authorised party for the ID token. Corresponds to theazpclaim.- Parameters:
azp- The authorised party,nullif not specified.
-
getSubjectJWK
public com.nimbusds.jose.jwk.JWK getSubjectJWK()
Gets the subject's JSON Web Key (JWK) for a self-issued OpenID Connect provider. Corresponds to thesub_jwkclaim.- Returns:
- The subject's JWK,
nullif not specified or parsing failed.
-
setSubjectJWK
public void setSubjectJWK(com.nimbusds.jose.jwk.JWK subJWK)
Sets the subject's JSON Web Key (JWK) for a self-issued OpenID Connect provider. Corresponds to thesub_jwkclaim.- Parameters:
subJWK- The subject's JWK (must be public),nullif not specified.
-
parse
public static IDTokenClaimsSet parse(net.minidev.json.JSONObject jsonObject) throws ParseException
Parses an ID token claims set from the specified JSON object.- Parameters:
jsonObject- The JSON object to parse. Must not benull.- Returns:
- The ID token claims set.
- Throws:
ParseException- If parsing failed.
-
parse
public static IDTokenClaimsSet parse(String json) throws ParseException
Parses an ID token claims set from the specified JSON object string.- Parameters:
json- The JSON object string to parse. Must not benull.- Returns:
- The ID token claims set.
- Throws:
ParseException- If parsing failed.
-
getIssuer
public Issuer getIssuer()
Gets the issuer. Corresponds to theissclaim.
-
getSubject
public Subject getSubject()
Gets the subject. Corresponds to thesubclaim.- Returns:
- The subject.
-
getAudience
public List<Audience> getAudience()
Gets the audience. Corresponds to theaudclaim.- Overrides:
getAudiencein classClaimsSet- Returns:
- The audience,
nullif not specified.
-
getIssueTime
public Date getIssueTime()
Gets the issue time. Corresponds to theissclaim.- Returns:
- The issue time,
nullif not specified.
-
getSessionID
public SessionID getSessionID()
Gets the session ID. Corresponds to thesidclaim.- Returns:
- The session ID,
nullif not specified.
-
setSessionID
public void setSessionID(SessionID sid)
Sets the session ID. Corresponds to thesidclaim.- Parameters:
sid- The session ID,nullif not specified.
-
-