Package org.forgerock.openig.tools
Class JwtUtil
- java.lang.Object
-
- org.forgerock.openig.tools.JwtUtil
-
public final class JwtUtil extends Object
Utility methods supporting JWTs.
-
-
Field Summary
Fields Modifier and Type Field Description static String
GRANT_TYPE
Claim-set grant_type key - not available in JwtClaimsSetKey.static String
NONCE
Claim-set nonce key - not available in JwtClaimsSetKey.static JsonPointer
PTR_AUD
Claim-set audience JSON pointer.static JsonPointer
PTR_EXP
Claim-set expiry JSON pointer.static JsonPointer
PTR_ISS
Claim-set issuer JSON pointer.static JsonPointer
PTR_NONCE
Claim-set nonce JSON pointer.static JsonPointer
PTR_TOKEN_NAME
Claim-set tokenName JSON pointer.static String
REALM
Claim-set realm key - not available in JwtClaimsSetKey.static String
SCOPE
Claim-set scope key - not available in JwtClaimsSetKey.static String
TOKEN_NAME
Claim-set token name key - not available in JwtClaimsSetKey.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>
getCookieJwt(Request request, String name)
Get a JWT from a request, with a given cookie name.static Promise<Optional<String>,NeverThrowsException>
getFormJwt(Request request, String param)
Get the JWT from a request form parameter.static Optional<String>
getValue(JwtClaimsSet claimsSet, JsonPointer ptr)
Return a value from it's well-known location on the OAuth2 authorization JWT.static <T extends Jwt>
TreconstructJwt(String jwt, Class<T> jwtClass)
Reconstruct a JWT from a {code String} representation.
-
-
-
Field Detail
-
GRANT_TYPE
public static final String GRANT_TYPE
Claim-set grant_type key - not available in JwtClaimsSetKey.- See Also:
- Constant Field Values
-
NONCE
public static final String NONCE
Claim-set nonce key - not available in JwtClaimsSetKey.- See Also:
- Constant Field Values
-
REALM
public static final String REALM
Claim-set realm key - not available in JwtClaimsSetKey.- See Also:
- Constant Field Values
-
SCOPE
public static final String SCOPE
Claim-set scope key - not available in JwtClaimsSetKey.- See Also:
- Constant Field Values
-
TOKEN_NAME
public static final String TOKEN_NAME
Claim-set token name key - not available in JwtClaimsSetKey.- See Also:
- Constant Field Values
-
PTR_AUD
public static final JsonPointer PTR_AUD
Claim-set audience JSON pointer.
-
PTR_EXP
public static final JsonPointer PTR_EXP
Claim-set expiry JSON pointer.
-
PTR_ISS
public static final JsonPointer PTR_ISS
Claim-set issuer JSON pointer.
-
PTR_NONCE
public static final JsonPointer PTR_NONCE
Claim-set nonce JSON pointer.
-
PTR_TOKEN_NAME
public static final JsonPointer PTR_TOKEN_NAME
Claim-set tokenName JSON pointer.
-
-
Method Detail
-
getCookieJwt
public static Optional<String> getCookieJwt(Request request, String name)
Get a JWT from a request, with a given cookie name.- Parameters:
request
- The request from which to obtain the JWT.name
- The name of the cookie storing the JWT.- Returns:
- Optional JWT
String
representation
-
getFormJwt
public static Promise<Optional<String>,NeverThrowsException> getFormJwt(Request request, String param)
Get the JWT from a request form parameter.- Parameters:
request
- The request from which to obtain the JWT.param
- The name of the parameter holding the JWT.- Returns:
- a
Promise
of an optionalString
JWT representation
-
reconstructJwt
public static <T extends Jwt> T reconstructJwt(String jwt, Class<T> jwtClass)
Reconstruct a JWT from a {code String} representation.- Type Parameters:
T
- type ofJWT
to construct.- Parameters:
jwt
- The JWT String representation.jwtClass
- The JWT class type to construct.- Returns:
- JWT} subtype
-
getValue
public static Optional<String> getValue(JwtClaimsSet claimsSet, JsonPointer ptr)
Return a value from it's well-known location on the OAuth2 authorization JWT.- Parameters:
claimsSet
- The JWT claims set.ptr
-JsonPointer
referencing claim.- Returns:
- Optional
String
containing value
-
-