public class JWT
extends java.lang.Object
implements android.os.Parcelable
| Modifier and Type | Field and Description |
|---|---|
static android.os.Parcelable.Creator<JWT> |
CREATOR |
| Constructor and Description |
|---|
JWT(java.lang.String token)
Decode a given string JWT token.
|
| Modifier and Type | Method and Description |
|---|---|
int |
describeContents() |
java.util.List<java.lang.String> |
getAudience()
Get the value of the "aud" claim, or an empty list if it's not available.
|
Claim |
getClaim(java.lang.String name)
Get a Claim given it's name.
|
java.util.Map<java.lang.String,Claim> |
getClaims()
Get all the Claims.
|
java.util.Date |
getExpiresAt()
Get the value of the "exp" claim, or null if it's not available.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeader()
Get the Header values from this JWT as a Map of Strings.
|
java.lang.String |
getId()
Get the value of the "jti" claim, or null if it's not available.
|
java.util.Date |
getIssuedAt()
Get the value of the "iat" claim, or null if it's not available.
|
java.lang.String |
getIssuer()
Get the value of the "iss" claim, or null if it's not available.
|
java.util.Date |
getNotBefore()
Get the value of the "nbf" claim, or null if it's not available.
|
java.lang.String |
getSignature()
Get the Signature from this JWT as a Base64 encoded String.
|
java.lang.String |
getSubject()
Get the value of the "sub" claim, or null if it's not available.
|
boolean |
isExpired(long leeway)
Validates that this JWT was issued in the past and hasn't expired yet.
|
java.lang.String |
toString()
Returns the String representation of this JWT.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<JWT> CREATOR
public JWT(@NonNull
java.lang.String token)
token - the string JWT token.DecodeException - if the token cannot be decoded@NonNull public java.util.Map<java.lang.String,java.lang.String> getHeader()
@NonNull public java.lang.String getSignature()
@Nullable public java.lang.String getIssuer()
@Nullable public java.lang.String getSubject()
@Nullable public java.util.List<java.lang.String> getAudience()
@Nullable public java.util.Date getExpiresAt()
@Nullable public java.util.Date getNotBefore()
@Nullable public java.util.Date getIssuedAt()
@Nullable public java.lang.String getId()
@NonNull public Claim getClaim(@NonNull java.lang.String name)
name - the name of the Claim to retrieve.@NonNull public java.util.Map<java.lang.String,Claim> getClaims()
public boolean isExpired(long leeway)
leeway - the time leeway in seconds in which the token should still be considered valid.public java.lang.String toString()
toString in class java.lang.Objectpublic int describeContents()
describeContents in interface android.os.Parcelablepublic void writeToParcel(android.os.Parcel dest,
int flags)
writeToParcel in interface android.os.Parcelable