public interface Claims extends java.util.Map<java.lang.String,java.lang.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.
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
AUDIENCE
JWT
Audience claims parameter name: "aud" |
static java.lang.String |
DESCRIPTION |
static java.lang.String |
EXPIRATION
JWT
Expiration claims parameter name: "exp" |
static java.lang.String |
ID
JWT
JWT ID claims parameter name: "jti" |
static java.lang.String |
ISSUED_AT
JWT
Issued At claims parameter name: "iat" |
static java.lang.String |
ISSUER
JWT
Issuer claims parameter name: "iss" |
static java.lang.String |
NOT_BEFORE
JWT
Not Before claims parameter name: "nbf" |
static java.lang.String |
SUBJECT
JWT
Subject claims parameter name: "sub" |
| 限定符和类型 | 方法和说明 |
|---|---|
<T> T |
get(java.lang.String claimName,
java.lang.Class<T> requiredType) |
java.lang.String |
getAudience()
Returns the JWT
aud (audience) value or null if not present. |
java.lang.String |
getDescription() |
java.util.Date |
getExpiration()
Returns the JWT
exp (expiration) timestamp or null if not present. |
java.lang.String |
getId()
Returns the JWTs
jti (JWT ID) value or null if not present. |
java.util.Date |
getIssuedAt()
Returns the JWT
iat (issued at) timestamp or null if not present. |
java.lang.String |
getIssuer()
Returns the JWT
iss (issuer) value or null if not present. |
java.util.Date |
getNotBefore()
Returns the JWT
nbf (not before) timestamp or null if not present. |
java.lang.String |
getSubject()
Returns the JWT
sub (subject) value or null if not present. |
Claims |
setAudience(java.lang.String aud)
Sets the JWT
aud (audience) value. |
Claims |
setDescription(java.lang.String description) |
Claims |
setExpiration(java.util.Date exp)
Sets the JWT
exp (expiration) timestamp. |
Claims |
setId(java.lang.String jti)
Sets the JWT
jti (JWT ID) value. |
Claims |
setIssuedAt(java.util.Date iat)
Sets the JWT
iat (issued at) timestamp. |
Claims |
setIssuer(java.lang.String iss)
Sets the JWT
iss (issuer) value. |
Claims |
setNotBefore(java.util.Date nbf)
Sets the JWT
nbf (not before) timestamp. |
Claims |
setSubject(java.lang.String sub)
Sets the JWT
sub (subject) value. |
static final java.lang.String ISSUER
Issuer claims parameter name: "iss"static final java.lang.String SUBJECT
Subject claims parameter name: "sub"static final java.lang.String AUDIENCE
Audience claims parameter name: "aud"static final java.lang.String EXPIRATION
Expiration claims parameter name: "exp"static final java.lang.String NOT_BEFORE
Not Before claims parameter name: "nbf"static final java.lang.String ISSUED_AT
Issued At claims parameter name: "iat"static final java.lang.String ID
JWT ID claims parameter name: "jti"static final java.lang.String DESCRIPTION
java.lang.String getIssuer()
iss (issuer) value or null if not present.iss value or null if not present.Claims setIssuer(java.lang.String iss)
iss (issuer) value. A null value will remove the property from the JSON map.setIssuer 在接口中 ClaimsMutator<Claims>iss - the JWT iss value or null to remove the property from the JSON map.Claims instance for method chaining.java.lang.String getSubject()
sub (subject) value or null if not present.sub value or null if not present.Claims setSubject(java.lang.String sub)
sub (subject) value. A null value will remove the property from the JSON map.setSubject 在接口中 ClaimsMutator<Claims>sub - the JWT sub value or null to remove the property from the JSON map.Claims instance for method chaining.java.lang.String getAudience()
aud (audience) value or null if not present.aud value or null if not present.Claims setAudience(java.lang.String aud)
aud (audience) value. A null value will remove the property from the JSON map.setAudience 在接口中 ClaimsMutator<Claims>aud - the JWT aud value or null to remove the property from the JSON map.Claims instance for method chaining.java.util.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(java.util.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 在接口中 ClaimsMutator<Claims>exp - the JWT exp value or null to remove the property from the JSON map.Claims instance for method chaining.java.util.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(java.util.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 在接口中 ClaimsMutator<Claims>nbf - the JWT nbf value or null to remove the property from the JSON map.Claims instance for method chaining.java.util.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(java.util.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 在接口中 ClaimsMutator<Claims>iat - the JWT iat value or null to remove the property from the JSON map.Claims instance for method chaining.java.lang.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(java.lang.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 在接口中 ClaimsMutator<Claims>jti - the JWT jti value or null to remove the property from the JSON map.Claims instance for method chaining.java.lang.String getDescription()
Claims setDescription(java.lang.String description)
setDescription 在接口中 ClaimsMutator<Claims><T> T get(java.lang.String claimName,
java.lang.Class<T> requiredType)