Package org.yamcs.http.auth
Class JwtHelper
- java.lang.Object
-
- org.yamcs.http.auth.JwtHelper
-
public class JwtHelper extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JwtHelper.JwtDecodeException
-
Constructor Summary
Constructors Constructor Description JwtHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.gson.JsonObject
decode(String token, byte[] secret)
static com.google.gson.JsonObject
decodeUnverified(String token)
static String
generateHS256Token(com.google.gson.JsonObject claims, byte[] secret)
Generates a signed JSON Web Token appended with a signature which can be used to validate the JWT by whoever knows the specified secret.static String
generateHS256Token(String issuer, String subject, byte[] secret, int ttl)
Generates a signed JSON Web Token appended with a signature which can be used to validate the JWT by whoever knows the specified secret.static String
generateUnsignedToken(com.google.gson.JsonObject claims)
Generates an unsigned JSON Web Token using fully custom claims.static String
generateUnsignedToken(String issuer, String subject, int ttl)
Generates an unsigned JSON Web Token using default claims iss, sub, iat and exp
-
-
-
Method Detail
-
generateUnsignedToken
public static String generateUnsignedToken(String issuer, String subject, int ttl)
Generates an unsigned JSON Web Token using default claims iss, sub, iat and exp
-
generateUnsignedToken
public static String generateUnsignedToken(com.google.gson.JsonObject claims)
Generates an unsigned JSON Web Token using fully custom claims.
-
generateHS256Token
public static String generateHS256Token(String issuer, String subject, byte[] secret, int ttl) throws InvalidKeyException, NoSuchAlgorithmException
Generates a signed JSON Web Token appended with a signature which can be used to validate the JWT by whoever knows the specified secret.
-
generateHS256Token
public static String generateHS256Token(com.google.gson.JsonObject claims, byte[] secret) throws InvalidKeyException, NoSuchAlgorithmException
Generates a signed JSON Web Token appended with a signature which can be used to validate the JWT by whoever knows the specified secret.
-
decodeUnverified
public static com.google.gson.JsonObject decodeUnverified(String token) throws JwtHelper.JwtDecodeException
- Throws:
JwtHelper.JwtDecodeException
-
decode
public static com.google.gson.JsonObject decode(String token, byte[] secret) throws JwtHelper.JwtDecodeException, InvalidKeyException, NoSuchAlgorithmException
-
-