Package in.eko.exprutils
Class JWT
- java.lang.Object
-
- in.eko.exprutils.JWT
-
public class JWT extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description JWT()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
generate(java.lang.String secretKey, java.lang.String algo, java.lang.String data, java.lang.String issuer, java.lang.String audience, java.lang.String subject, java.lang.String jwtid, long expiresInSeconds)
Generate JWT (token) with the given configuration.static java.lang.String
generate(java.lang.String secretKey, java.lang.String algo, org.json.JSONObject data, java.lang.String issuer, java.lang.String audience, java.lang.String subject, java.lang.String jwtid, long expiresInSeconds)
Generate JWT (token) with the given configuration.static java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim>
parse(java.lang.String token, java.lang.String secretKey, java.lang.String algo)
Validates and parses a JWT (token).
-
-
-
Method Detail
-
generate
public static java.lang.String generate(java.lang.String secretKey, java.lang.String algo, java.lang.String data, java.lang.String issuer, java.lang.String audience, java.lang.String subject, java.lang.String jwtid, long expiresInSeconds)
Generate JWT (token) with the given configuration. Using java-jwt library (https://github.com/auth0/java-jwt)- Parameters:
secretKey
- The secure key used to encrypt the payload (if an encryption algorithm is selected)algo
- The encryption algorithm to use (defaults to NONE). Currently supported: HS256, HS384, HS512, NONEdata
- The additional claim (key-value pairs) as serialized JSON object (String).issuer
- The token issueraudience
- The intended audience of the tokensubject
- An optional subject for the tokenjwtid
- An optional JWT-IDexpiresInSeconds
- Number of seconds after which the token expires- Returns:
- The generated token
- Throws:
java.lang.IllegalArgumentException
- if `data` is not a valid JSON Object
-
generate
public static java.lang.String generate(java.lang.String secretKey, java.lang.String algo, org.json.JSONObject data, java.lang.String issuer, java.lang.String audience, java.lang.String subject, java.lang.String jwtid, long expiresInSeconds)
Generate JWT (token) with the given configuration. Using java-jwt library (https://github.com/auth0/java-jwt)- Parameters:
secretKey
- The secure key used to encrypt the payload (if an encryption algorithm is selected)algo
- The encryption algorithm to use (defaults to NONE). Currently supported: HMAC256, HMAC384, HMAC512, NONEdata
- The JSONObject with key-value pairs of the additional claim/data.issuer
- The token issueraudience
- The intended audience of the tokensubject
- An optional subject for the tokenjwtid
- An optional JWT-IDexpiresInSeconds
- Number of seconds after which the token expires- Returns:
- The generated token
-
parse
public static java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim> parse(java.lang.String token, java.lang.String secretKey, java.lang.String algo) throws com.auth0.jwt.exceptions.JWTVerificationException
Validates and parses a JWT (token). If valid, returns a Map of key-value pairs of the claims.- Parameters:
token
- The JWT to parse.secretKey
- The secure key that was used to encrypt the tokenalgo
- The encryption algorithm used to generate the token- Returns:
- The Map of claim (payload) key-value pairs.
- Throws:
com.auth0.jwt.exceptions.JWTVerificationException
- if the token cannot be verified
-
-