public class JWT extends Object
This class represents a JSON Web Token, providing the standard claims set defined by its specification. It is a representation of the claims to be transferred between two parties.
Instances must be created by their corresponding JWTBuilder
. Once created, instances are immutable.
The JSON representation of a token is obtained via toString()
method.
Modifier | Constructor and Description |
---|---|
protected |
JWT(javax.json.JsonObject headers,
javax.json.JsonObject claims)
Creates a new instance using the claims set and values from the given
JsonObject . |
Modifier and Type | Method and Description |
---|---|
String |
encode()
Ecodes the JSON representation of a JWT according with the specification.
|
List<String> |
getAudience()
Identifies the audience that the JWT is intended for.
|
String |
getClaim(String name)
Returns a claim given its name.
|
javax.json.JsonObject |
getClaims()
Subclasses can obtain from this method a
JsonObject instance containing the claims set and their
respective values. |
List<String> |
getClaimValues(String name)
Returns a claim given its name.
|
String |
getContentType()
Used by this specification to convey structural information about the JWT.
|
Integer |
getExpiration()
The expiration time on or after which the token MUST NOT be accepted for processing.
|
Date |
getExpirationDate()
Returns a
Date representation of the getExpiration() . |
String |
getHeader(String name)
Returns a header given its name.
|
javax.json.JsonObject |
getHeaders()
Subclasses can obtain from this method a
JsonObject instance containing headers and their respective
values. |
List<String> |
getHeaderValues(String name)
Returns a header given its name.
|
String |
getId()
The unique identifier for a JWT.
|
Integer |
getIssuedAt()
The time at which the JWT was issued.
|
Date |
getIssuedAtDate()
Returns a
Date representation of the getIssuedAt() . |
String |
getIssuer()
The principal that issued the JWT.
|
Integer |
getNotBefore()
The time before which the token MUST NOT be accepted for processing
|
Date |
getNotBeforeDate()
Returns a
Date representation of the getNotBeforeDate() . |
String |
getSubject()
Identifies the principal that is the subject of the JWT.
|
String |
geType()
Declares the MIME Media Type [IANA.MediaTypes] of this complete JWT in contexts where this is useful to the application.
|
String |
toString() |
protected JWT(javax.json.JsonObject headers, javax.json.JsonObject claims)
Creates a new instance using the claims set and values from the given JsonObject
.
claims
- The claims set and their respective values.public String encode()
Ecodes the JSON representation of a JWT according with the specification.
In order to decode, refer to the corresponding JWTBuilder
of this class.
public String geType()
Declares the MIME Media Type [IANA.MediaTypes] of this complete JWT in contexts where this is useful to the application.
public String getContentType()
Used by this specification to convey structural information about the JWT.
public String getId()
The unique identifier for a JWT.
public String getIssuer()
The principal that issued the JWT.
public List<String> getAudience()
Identifies the audience that the JWT is intended for.
public String getSubject()
Identifies the principal that is the subject of the JWT.
public Integer getIssuedAt()
The time at which the JWT was issued.
public Date getIssuedAtDate()
Returns a Date
representation of the getIssuedAt()
.
public Integer getExpiration()
The expiration time on or after which the token MUST NOT be accepted for processing.
public Date getExpirationDate()
Returns a Date
representation of the getExpiration()
.
public Integer getNotBefore()
The time before which the token MUST NOT be accepted for processing
public Date getNotBeforeDate()
Returns a Date
representation of the getNotBeforeDate()
.
public javax.json.JsonObject getClaims()
Subclasses can obtain from this method a JsonObject
instance containing the claims set and their
respective values.
public javax.json.JsonObject getHeaders()
Subclasses can obtain from this method a JsonObject
instance containing headers and their respective
values.
public String getClaim(String name)
Returns a claim given its name. If the claim represents an array, only the first value is returned.
name
- public List<String> getClaimValues(String name)
Returns a claim given its name.
name
- public String getHeader(String name)
Returns a header given its name. If the header represents an array, only the first value is returned.
name
- Copyright © 2018. All rights reserved.