Package com.bastiaanjansen.jwt
Class JWT
java.lang.Object
com.bastiaanjansen.jwt.JWT
public class JWT extends Object
This object represents a JSON Web Token
- Author:
- Bastiaan Jansen
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJWT.Builder -
Constructor Summary
-
Method Summary
Modifier and Type Method Description static JWTfromRawJWT(Algorithm algorithm, String jwt)Create a new JWT instance based on a raw JWTAlgorithmgetAlgorithm()HeadergetHeader()PayloadgetPayload()StringgetSignature()Stringsign()Create a new JWTvoidvalidate()Checks whether the JWT is valid or not with the default JWT validatorvoidvalidate(JWTValidator validator)Checks whether the JWT is valid or not with a custom validator
-
Constructor Details
-
JWT
- Throws:
JWTCreationException
-
-
Method Details
-
fromRawJWT
public static JWT fromRawJWT(Algorithm algorithm, String jwt) throws JWTDecodeException, JWTCreationExceptionCreate a new JWT instance based on a raw JWT- Parameters:
algorithm- algorithm to use when signing JWTjwt- Raw JWT- Returns:
- Newly created JWT instance
- Throws:
JWTDecodeException- When the raw JWT could not be decodedJWTCreationException
-
validate
Checks whether the JWT is valid or not with a custom validator- Parameters:
validator- JWT Validator- Throws:
JWTValidationException- when JWT is not valid
-
validate
Checks whether the JWT is valid or not with the default JWT validator- Throws:
JWTValidationException- when JWT is not valid
-
getAlgorithm
-
getPayload
-
getHeader
-
getSignature
-
sign
Create a new JWT- Returns:
- A new JWT
- Throws:
JWTCreationException- when JWT could not be created
-