public class JWTTokenManager extends Object
Modifier and Type | Field and Description |
---|---|
static String |
JWT_CLAIM_PERMISSIONS |
static String |
JWT_CLAIM_RANDOM_STRING |
static String |
JWT_TOKEN_SESSION_RANDOM_STRING |
Constructor and Description |
---|
JWTTokenManager() |
Modifier and Type | Method and Description |
---|---|
String |
generateToken(String subject)
Generates a JWT token to the user with adding his permissions, token expiration time
|
String |
getIssuer() |
long |
getLifeTime() |
com.nimbusds.jwt.SignedJWT |
parse(String authHeader)
Parse a string to generate a SignedJWT
|
void |
setIssuer(String issuer) |
void |
setLifeTime(long lifeTime) |
boolean |
verify(com.nimbusds.jwt.SignedJWT signedJWT)
This will verify the token sent with the request.
|
public static final String JWT_CLAIM_PERMISSIONS
public static final String JWT_CLAIM_RANDOM_STRING
public static final String JWT_TOKEN_SESSION_RANDOM_STRING
public String generateToken(String subject) throws ManagementServiceException
subject
- Subject to whom the token should be issued.ManagementServiceException
- in case of a failure to generate the tokenpublic boolean verify(com.nimbusds.jwt.SignedJWT signedJWT) throws ParseException, com.nimbusds.jose.JOSEException
signedJWT
- the signed JWT token to be verifiedParseException
- in case of a failure to parse the tokencom.nimbusds.jose.JOSEException
- in case of a failure in verification of the tokenpublic com.nimbusds.jwt.SignedJWT parse(String authHeader) throws ParseException
authHeader
- decrypted authentication headerParseException
- if fails to parse the tokenpublic String getIssuer()
public void setIssuer(String issuer)
public long getLifeTime()
public void setLifeTime(long lifeTime)
Copyright © 2016–2019 AdroitLogic. All rights reserved.