public class JWT extends Object
From RFC 7519 Section 1. Introduction: The suggested pronunciation of JWT is the same as the English word "jot".The JWT is not Thread-Safe and should not be re-used.
Modifier and Type | Field and Description |
---|---|
Object |
audience
Registered Claim
aud as defined by RFC 7519 Section 4.1.3. |
java.time.ZonedDateTime |
expiration
Registered Claim
exp as defined by RFC 7519 Section 4.1.4. |
java.time.ZonedDateTime |
issuedAt
Registered Claim
iat as defined by RFC 7519 Section 4.1.6. |
String |
issuer
Registered Claim
iss as defined by RFC 7519 Section 4.1.1. |
java.time.ZonedDateTime |
notBefore
Registered Claim
nbf as defined by RFC 7519 Section 4.1.5. |
Map<String,Object> |
otherClaims
This Map will contain all the claims that aren't specifically defined in the specification.
|
String |
subject
Registered Claim
sub as defined by RFC 7519 Section 4.1.2. |
String |
uniqueId
Registered Claim
jti as defined by RFC 7519 Section 4.1.7. |
Constructor and Description |
---|
JWT() |
Modifier and Type | Method and Description |
---|---|
JWT |
addClaim(String name,
Object value)
Add a claim to this JWT.
|
boolean |
equals(Object o) |
Map<String,Object> |
getAllClaims() |
BigDecimal |
getBigDecimal(String key) |
BigInteger |
getBigInteger(String key) |
Boolean |
getBoolean(String key) |
static JWTDecoder |
getDecoder()
Return an instance of the JWT Decoder.
|
Double |
getDouble(String key) |
static JWTEncoder |
getEncoder()
Return an instance of the JWT encoder.
|
Float |
getFloat(String key) |
Integer |
getInteger(String key) |
List<Object> |
getList(String key) |
Long |
getLong(String key) |
Map<String,Object> |
getMap(String key) |
Number |
getNumber(String key) |
Object |
getObject(String key) |
Map<String,Object> |
getOtherClaims() |
Map<String,Object> |
getRawClaims() |
String |
getString(String key) |
static JWTDecoder |
getTimeMachineDecoder(java.time.ZonedDateTime now)
Return a JWT Decoder that allows you to go back or of forward in time.
|
int |
hashCode() |
boolean |
isExpired()
Return true if this JWT is expired.
|
boolean |
isExpired(java.time.ZonedDateTime now)
Return true if this JWT is expired.
|
boolean |
isUnavailableForProcessing()
Return true if this JWT is un-available for processing.
|
boolean |
isUnavailableForProcessing(java.time.ZonedDateTime now)
Return true if this JWT is un-available for processing.
|
JWT |
setAudience(Object audience) |
JWT |
setExpiration(java.time.ZonedDateTime expiration) |
JWT |
setIssuedAt(java.time.ZonedDateTime issuedAt) |
JWT |
setIssuer(String issuer) |
JWT |
setNotBefore(java.time.ZonedDateTime notBefore) |
JWT |
setSubject(String subject) |
JWT |
setUniqueId(String uniqueId) |
String |
toString() |
public Object audience
aud
as defined by RFC 7519 Section 4.1.3. Use of this claim is OPTIONAL.
The audience claim identifies the recipients that the JWT is intended for. This may be an array of strings or a
single string, in either case if the string value contains a :
it must be a URI.
public java.time.ZonedDateTime expiration
exp
as defined by RFC 7519 Section 4.1.4. Use of this claim is OPTIONAL.
The expiration time claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. The expiration time is expected to provided in UNIX time, or the number of seconds since Epoch.
public java.time.ZonedDateTime issuedAt
iat
as defined by RFC 7519 Section 4.1.6. Use of this claim is OPTIONAL.
The issued at claim identifies the time at which the JWT was issued. The issued at time is expected to provided in UNIX time, or the number of seconds since Epoch.
public String issuer
iss
as defined by RFC 7519 Section 4.1.1. Use of this claim is OPTIONAL.
The issuer claim identifies the principal that issued the JWT. If the value contains a :
it must be a
URI.
public java.time.ZonedDateTime notBefore
nbf
as defined by RFC 7519 Section 4.1.5. Use of this claim is OPTIONAL.
This claim identifies the time before which the JWT MUST NOT be accepted for processing. The not before value is expected to provided in UNIX time, or the number of seconds since Epoch.
public Map<String,Object> otherClaims
public String subject
sub
as defined by RFC 7519 Section 4.1.2. Use of this claim is OPTIONAL.
The subject claim identifies the principal that is the subject of the JWT. If the value contains a :
it must be a URI.
public String uniqueId
jti
as defined by RFC 7519 Section 4.1.7. Use of this claim is OPTIONAL.
The JWT unique ID claim provides a unique identifier for the JWT.
public static JWTDecoder getDecoder()
public static JWTDecoder getTimeMachineDecoder(java.time.ZonedDateTime now)
Generally speaking, there should not be a use for this in production code since 'now' should always be 'now', but it may come in handy in a test.
now
- a 'now' that can be in the past, present or future.public static JWTEncoder getEncoder()
public JWT addClaim(String name, Object value)
name
- The name of the JWT claim.value
- The value of the JWT claim. This value is an object and is expected to properly serialize.public Map<String,Object> getAllClaims()
public BigDecimal getBigDecimal(String key)
public BigInteger getBigInteger(String key)
public Map<String,Object> getRawClaims()
public boolean isExpired()
public boolean isExpired(java.time.ZonedDateTime now)
now
- the 'now' you wish to use.public boolean isUnavailableForProcessing(java.time.ZonedDateTime now)
now
- the 'now' you wish to use.public boolean isUnavailableForProcessing()
public JWT setExpiration(java.time.ZonedDateTime expiration)
public JWT setIssuedAt(java.time.ZonedDateTime issuedAt)
public JWT setNotBefore(java.time.ZonedDateTime notBefore)
Copyright © 2021. All rights reserved.