public interface Claims extends Map<String,Object>, ClaimsMutator<Claims>
This is ultimately a JSON map and any values can be added to it, but JWT standard names are provided as type-safe getters and setters for convenience.
Because this interface extends Map<String, Object>, if you would like to add your own properties,
you simply use map methods, for example:
claims.put("someKey", "someValue");
It is easiest to create a Claims instance by calling one of the
JWTs.claims() factory methods.
| Modifier and Type | Field and Description |
|---|---|
static String |
AUDIENCE
JWT
Audience claims parameter name: "aud" |
static String |
EXPIRATION
JWT
Expiration claims parameter name: "exp" |
static String |
ID
JWT
JWT ID claims parameter name: "jti" |
static String |
ISSUED_AT
JWT
Issued At claims parameter name: "iat" |
static String |
ISSUER
JWT
Issuer claims parameter name: "iss" |
static String |
NOT_BEFORE
JWT
Not Before claims parameter name: "nbf" |
static String |
SUBJECT
JWT
Subject claims parameter name: "sub" |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
get(String claimName,
Class<T> requiredType) |
String |
getAudience()
Returns the JWT
aud (audience) value or null if not present. |
Date |
getExpiration()
Returns the JWT
exp (expiration) timestamp or null if not present. |
String |
getId()
Returns the JWTs
jti (JWT ID) value or null if not present. |
Date |
getIssuedAt()
Returns the JWT
iat (issued at) timestamp or null if not present. |
String |
getIssuer()
Returns the JWT
iss (issuer) value or null if not present. |
Date |
getNotBefore()
Returns the JWT
nbf (not before) timestamp or null if not present. |
String |
getSubject()
Returns the JWT
sub (subject) value or null if not present. |
Claims |
setAudience(String aud)
Sets the JWT
aud (audience) value. |
Claims |
setExpiration(Date exp)
Sets the JWT
exp (expiration) timestamp. |
Claims |
setId(String jti)
Sets the JWT
jti (JWT ID) value. |
Claims |
setIssuedAt(Date iat)
Sets the JWT
iat (issued at) timestamp. |
Claims |
setIssuer(String iss)
Sets the JWT
iss (issuer) value. |
Claims |
setNotBefore(Date nbf)
Sets the JWT
nbf (not before) timestamp. |
Claims |
setSubject(String sub)
Sets the JWT
sub (subject) value. |
static final String ISSUER
Issuer claims parameter name: "iss"static final String SUBJECT
Subject claims parameter name: "sub"static final String AUDIENCE
Audience claims parameter name: "aud"static final String EXPIRATION
Expiration claims parameter name: "exp"static final String NOT_BEFORE
Not Before claims parameter name: "nbf"static final String ISSUED_AT
Issued At claims parameter name: "iat"static final String ID
JWT ID claims parameter name: "jti"String getIssuer()
iss (issuer) value or null if not present.iss value or null if not present.Claims setIssuer(String iss)
iss (issuer) value. A null value will remove the property from the JSON map.setIssuer in interface ClaimsMutator<Claims>iss - the JWT iss value or null to remove the property from the JSON map.Claims instance for method chaining.String getSubject()
sub (subject) value or null if not present.sub value or null if not present.Claims setSubject(String sub)
sub (subject) value. A null value will remove the property from the JSON map.setSubject in interface ClaimsMutator<Claims>sub - the JWT sub value or null to remove the property from the JSON map.Claims instance for method chaining.String getAudience()
aud (audience) value or null if not present.aud value or null if not present.Claims setAudience(String aud)
aud (audience) value. A null value will remove the property from the JSON map.setAudience in interface ClaimsMutator<Claims>aud - the JWT aud value or null to remove the property from the JSON map.Claims instance for method chaining.Date getExpiration()
exp (expiration) timestamp or null if not present.
A JWT obtained after this timestamp should not be used.
exp value or null if not present.Claims setExpiration(Date exp)
exp (expiration) timestamp. A null value will remove the property from the JSON map.
A JWT obtained after this timestamp should not be used.
setExpiration in interface ClaimsMutator<Claims>exp - the JWT exp value or null to remove the property from the JSON map.Claims instance for method chaining.Date getNotBefore()
nbf (not before) timestamp or null if not present.
A JWT obtained before this timestamp should not be used.
nbf value or null if not present.Claims setNotBefore(Date nbf)
nbf (not before) timestamp. A null value will remove the property from the JSON map.
A JWT obtained before this timestamp should not be used.
setNotBefore in interface ClaimsMutator<Claims>nbf - the JWT nbf value or null to remove the property from the JSON map.Claims instance for method chaining.Date getIssuedAt()
iat (issued at) timestamp or null if not present.
If present, this value is the timestamp when the JWT was created.
nbf value or null if not present.Claims setIssuedAt(Date iat)
iat (issued at) timestamp. A null value will remove the property from the JSON map.
The value is the timestamp when the JWT was created.
setIssuedAt in interface ClaimsMutator<Claims>iat - the JWT iat value or null to remove the property from the JSON map.Claims instance for method chaining.String getId()
jti (JWT ID) value or null if not present.
This value is a CaSe-SenSiTiVe unique identifier for the JWT. If available, this value is expected to be assigned in a manner that ensures that there is a negligible probability that the same value will be accidentally assigned to a different data object. The ID can be used to prevent the JWT from being replayed.
jti value or null if not present.Claims setId(String jti)
jti (JWT ID) value. A null value will remove the property from the JSON map.
This value is a CaSe-SenSiTiVe unique identifier for the JWT. If specified, this value MUST be assigned in a manner that ensures that there is a negligible probability that the same value will be accidentally assigned to a different data object. The ID can be used to prevent the JWT from being replayed.
setId in interface ClaimsMutator<Claims>jti - the JWT jti value or null to remove the property from the JSON map.Claims instance for method chaining.Copyright © 2018. All rights reserved.