Class JwtClaims
java.lang.Object
com.revetsec.jose.JwtClaims
The claims of a validated JWT (RFC 7519 section 4). Only a validator creates them, after the token's signature
and claims passed.
The registered claims were checked for their types before this object existed: iss, sub and
jti are strings, aud is a string or a non-empty array of strings, and exp, nbf and
iat are NumericDates. So every getter is total: it returns the claim or reports it absent, and never
throws. getClaim(String) and toJsonObject() give every other claim as JSON.
Claims can carry personal data, so toString() shows none of them. Instances compare by reference, never
by content.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionReturns the audiences (aud).Returns a claim's JSON value, registered or not.Returns the names of every claim.Returns the expiration time (exp).Returns the issue time (iat).Returns the issuer (iss).getJwtId()Returns the JWT ID (jti).Returns the time before which the token is not valid (nbf).Returns the subject (sub).Returns every claim as a JSON object: the claims set as received, which can carry personal data.toString()Describes this object without any claim.
-
Method Details
-
getIssuer
-
getSubject
Returns the subject (sub).- Returns:
- the subject, or empty if absent
- Since:
- 1.0.0
-
getAudiences
Returns the audiences (aud).- Returns:
- an unmodifiable list: one element for a string
aud, the array's elements in order, or empty if absent - Since:
- 1.0.0
-
getExpiresAt
Returns the expiration time (exp).- Returns:
- the instant, or empty if absent
- Since:
- 1.0.0
-
getIssuedAt
Returns the issue time (iat).- Returns:
- the instant, or empty if absent
- Since:
- 1.0.0
-
getNotBefore
Returns the time before which the token is not valid (nbf).- Returns:
- the instant, or empty if absent
- Since:
- 1.0.0
-
getJwtId
-
getClaim
Returns a claim's JSON value, registered or not.- Parameters:
name- the claim name, compared exactly- Returns:
- the value, which may be JSON
null, or empty if there is no such claim - Throws:
NullPointerException- ifnameisnull- Since:
- 1.0.0
-
getClaimNames
Returns the names of every claim.- Returns:
- an unmodifiable set, in the order the claims appear in the token
- Since:
- 1.0.0
-
toJsonObject
Returns every claim as a JSON object: the claims set as received, which can carry personal data.- Returns:
- the claims set
- Since:
- 1.0.0
-
toString
-