Package org.wildfly.security.http.oidc
Class JsonWebToken
java.lang.Object
org.wildfly.security.http.oidc.JsonWebToken
- Direct Known Subclasses:
AccessToken,IDToken
Representation of a JSON Web Token, as per RFC 7519.
- Author:
- Farah Juma
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the audience claim.Get the claim names.getClaimValue(String claimName) Get the value of the given claim.<T> TgetClaimValue(String claimName, Class<T> type) Get the value of the given claim.getClaimValueAsString(String claimName) Get the value of the given claim.getEmail()Get the email claim.Get the expiration claim.Get the family name claim.Get the given name claim.getID()Get the ID claim.Get the issued at claim.Get the issuer claim.Get the middle name claim.getName()Get the name claim.Get the nick name claim.Get the not before claim.Get the preferred username claim.getPrincipalName(OidcClientConfiguration deployment) Get the principal name.getStringListClaimValue(String claimName) Get the value of the given claim as a string list.Get the subject claim.booleanReturn whether this token has the given claim.booleanisActive()Checks that the token is not expired and isn't prior to the not before time.booleanReturn whether this JWT is expired.booleanReturn whether the current time is greater than or equal to the value of the not before claim.static jakarta.json.JsonObjectreplaceMap(Map<String, Object> map) static jakarta.json.JsonValue
-
Field Details
-
EMAIL
- See Also:
-
EXP
- See Also:
-
FAMILY_NAME
- See Also:
-
GIVEN_NAME
- See Also:
-
IAT
- See Also:
-
MIDDLE_NAME
- See Also:
-
NAME
- See Also:
-
NICKNAME
- See Also:
-
NBF
- See Also:
-
PREFERRED_USERNAME
- See Also:
-
SUB
- See Also:
-
-
Constructor Details
-
JsonWebToken
public JsonWebToken(org.jose4j.jwt.JwtClaims jwtClaims) Construct a new instance.- Parameters:
jwtClaims- the JWT claims for this instance (may not benull)
-
-
Method Details
-
getIssuer
Get the issuer claim.- Returns:
- the issuer claim
- Throws:
IllegalArgumentException- if the issuer claim is malformed
-
getSubject
Get the subject claim.- Returns:
- the subject claim
- Throws:
IllegalArgumentException- if the subject claim is malformed
-
getAudience
Get the audience claim.- Returns:
- the audience claim
- Throws:
IllegalArgumentException- if the audience claim is malformed
-
getExpiration
Get the expiration claim.- Returns:
- the expiration claim
- Throws:
IllegalArgumentException- if the expiration claim is malformed
-
isExpired
public boolean isExpired()Return whether this JWT is expired.- Returns:
trueif this JWT is expired andfalseotherwise- Throws:
IllegalArgumentException- if the issuer claim is malformed
-
getNotBefore
Get the not before claim.- Returns:
- the not before claim
- Throws:
IllegalArgumentException- if the not before claim is malformed
-
isNotBefore
public boolean isNotBefore()Return whether the current time is greater than or equal to the value of the not before claim.- Returns:
trueif the not before claim is null or if the current time is greater than or equal to the value of the not before claim andfalseotherwise- Throws:
IllegalArgumentException- if the not before claim is malformed
-
isActive
public boolean isActive()Checks that the token is not expired and isn't prior to the not before time.- Returns:
trueif the token is active andfalseotherwise
-
getIssuedAt
Get the issued at claim.- Returns:
- the issued at claim
- Throws:
IllegalArgumentException- if the issued at claim is malformed
-
getID
Get the ID claim.- Returns:
- the ID claim
- Throws:
IllegalArgumentException- if the ID claim is malformed
-
getClaimNames
Get the claim names.- Returns:
- the claim names
-
hasClaim
Return whether this token has the given claim.- Parameters:
claimName- the claim name to check- Returns:
trueif this token has the given claim andfalseotherwise
-
getClaimValue
Get the value of the given claim.- Parameters:
claimName- the claim to retrieve- Returns:
- the value of the given claim
-
getClaimValue
Get the value of the given claim.- Type Parameters:
T- the type of the value- Parameters:
claimName- the claim to retrievetype- the type that should be returned- Returns:
- the value of the given claim
- Throws:
IllegalArgumentException- if the claim is malformed
-
getClaimValueAsString
Get the value of the given claim.- Parameters:
claimName- the claim to retrieve- Returns:
- the value of the given claim as a string
-
getStringListClaimValue
Get the value of the given claim as a string list.- Parameters:
claimName- the claim to retrieve- Returns:
- the value of the given claim as a string list
-
getName
Get the name claim.- Returns:
- the name claim
-
getPrincipalName
Get the principal name.- Parameters:
deployment- the OIDC client configuration that should be used to determine the principal- Returns:
- the principal name
-
getGivenName
Get the given name claim.- Returns:
- the given name claim
-
getFamilyName
Get the family name claim.- Returns:
- the family name claim
-
getMiddleName
Get the middle name claim.- Returns:
- the middle name claim
-
getNickName
Get the nick name claim.- Returns:
- the nick name claim
-
getPreferredUsername
Get the preferred username claim.- Returns:
- the preferred username claim
-
getEmail
Get the email claim.- Returns:
- the email claim
-
wrapValue
-
replaceMap
-