public class JwtGenerator<U extends CommonProfile> extends Object
Modifier and Type | Field and Description |
---|---|
static String |
INTERNAL_PERMISSIONS |
static String |
INTERNAL_ROLES |
protected org.slf4j.Logger |
logger |
Constructor and Description |
---|
JwtGenerator(String secret) |
JwtGenerator(String secret,
boolean encrypted) |
JwtGenerator(String signingSecret,
String encryptionSecret)
Initializes the generator that will create JWT tokens that is signed and optionally encrypted.
|
Modifier and Type | Method and Description |
---|---|
protected com.nimbusds.jwt.JWTClaimsSet |
buildJwtClaimsSet(U profile) |
protected String |
encryptJwt(com.nimbusds.jwt.SignedJWT signedJWT) |
String |
generate(U profile)
Generates a JWT from a user profile.
|
String |
generate(U profile,
com.nimbusds.jose.JWSSigner signer,
com.nimbusds.jose.JWSAlgorithm jwsAlgorithm)
Generates a JWT from a user profile.
|
com.nimbusds.jose.EncryptionMethod |
getEncryptionMethod() |
String |
getEncryptionSecret() |
com.nimbusds.jose.JWEAlgorithm |
getJweAlgorithm() |
com.nimbusds.jose.JWSAlgorithm |
getJwsAlgorithm() |
String |
getSigningSecret() |
void |
setEncryptionMethod(com.nimbusds.jose.EncryptionMethod encryptionMethod) |
void |
setEncryptionSecret(String encryptionSecret) |
void |
setJweAlgorithm(com.nimbusds.jose.JWEAlgorithm jweAlgorithm) |
void |
setJwsAlgorithm(com.nimbusds.jose.JWSAlgorithm jwsAlgorithm)
Only the HS256, HS384 and HS512 are currently supported.
|
void |
setSigningSecret(String signingSecret) |
protected com.nimbusds.jwt.SignedJWT |
signJwt(com.nimbusds.jwt.JWTClaimsSet claims,
com.nimbusds.jose.JWSSigner signer,
com.nimbusds.jose.JWSAlgorithm jwsAlgorithm) |
public static final String INTERNAL_ROLES
public static final String INTERNAL_PERMISSIONS
protected final org.slf4j.Logger logger
public JwtGenerator(String secret)
public JwtGenerator(String secret, boolean encrypted)
public JwtGenerator(String signingSecret, String encryptionSecret)
signingSecret
- The signingSecret. Must be at least 256 bits long and not null
encryptionSecret
- The encryptionSecret. Must be at least 256 bits long and not null
if you want encryptionpublic String generate(U profile)
profile
- the given user profilepublic String generate(U profile, com.nimbusds.jose.JWSSigner signer, com.nimbusds.jose.JWSAlgorithm jwsAlgorithm)
profile
- the given user profilesigner
- the given user profilejwsAlgorithm
- the signing algorithmprotected String encryptJwt(com.nimbusds.jwt.SignedJWT signedJWT) throws Exception
Exception
protected com.nimbusds.jwt.SignedJWT signJwt(com.nimbusds.jwt.JWTClaimsSet claims, com.nimbusds.jose.JWSSigner signer, com.nimbusds.jose.JWSAlgorithm jwsAlgorithm) throws com.nimbusds.jose.JOSEException
com.nimbusds.jose.JOSEException
protected com.nimbusds.jwt.JWTClaimsSet buildJwtClaimsSet(U profile)
public String getSigningSecret()
public void setSigningSecret(String signingSecret)
public String getEncryptionSecret()
public void setEncryptionSecret(String encryptionSecret)
public com.nimbusds.jose.JWSAlgorithm getJwsAlgorithm()
public void setJwsAlgorithm(com.nimbusds.jose.JWSAlgorithm jwsAlgorithm)
jwsAlgorithm
- the signing algorithmpublic com.nimbusds.jose.JWEAlgorithm getJweAlgorithm()
public void setJweAlgorithm(com.nimbusds.jose.JWEAlgorithm jweAlgorithm)
public com.nimbusds.jose.EncryptionMethod getEncryptionMethod()
public void setEncryptionMethod(com.nimbusds.jose.EncryptionMethod encryptionMethod)
Copyright © 2016. All rights reserved.