| Modifier and Type | Field and Description |
|---|---|
static java.time.Instant |
NO_EXPIRE_DATE |
| Modifier and Type | Method and Description |
|---|---|
Token |
createToken()
Builds and signs the token using the the algorithm set via
withSignatureAlgorithm(JwtSignatureAlgorithm) and the given key. |
static JwtGenerator |
getInstance(Service service,
String clientId) |
JwtGenerator |
withClaimsFromFile(String claimsJsonFilePath)
This method will fill the token with all the claims that are defined inside
the given file.
|
JwtGenerator |
withClaimValue(String claimName,
JsonObject object)
Sets the claim with the given name to the given string value.
|
JwtGenerator |
withClaimValue(String claimName,
String value)
Sets the claim with the given name to the given string value.
|
JwtGenerator |
withClaimValues(String claimName,
String... values)
Sets the claim with the given name to the given string values.
|
JwtGenerator |
withExpiration(java.time.Instant expiration)
Sets the expiration claim (exp) of the token to the given moment in time.
|
JwtGenerator |
withHeaderParameter(String parameterName,
String value)
Sets the header parameter with the given name to the given string value.
|
JwtGenerator |
withPrivateKey(PrivateKey privateKey)
Sets the private key that is used to sign the token.
|
JwtGenerator |
withScopes(String... scopes)
Sets the roles as claim "scope" to the jwt.
|
JwtGenerator |
withSignatureAlgorithm(JwtSignatureAlgorithm signatureAlgorithm)
Sets the signature algorithm that is used to create the signature of the
token.
|
public static JwtGenerator getInstance(Service service, String clientId)
public JwtGenerator withHeaderParameter(String parameterName, String value)
parameterName - the name of the header parameter to be set.value - the string value of the header parameter to be set.public JwtGenerator withClaimValue(String claimName, String value)
claimName - the name of the claim to be set.value - the string value of the claim to be set.public JwtGenerator withClaimValue(String claimName, JsonObject object)
claimName - the name of the claim to be set.object - the string value of the claim to be set.JsonParsingException - if the given object does not contain valid json.public JwtGenerator withClaimValues(String claimName, String... values)
claimName - the name of the claim to be set.values - the string values of the claims to be set.public JwtGenerator withClaimsFromFile(String claimsJsonFilePath) throws IOException
claimsJsonFilePath - the file path to the file containing the claims in json format.JsonParsingException - if the file does not contain a valid json object.IOException - when the file cannot be read or does not exist.public JwtGenerator withExpiration(@Nonnull java.time.Instant expiration)
expiration - the moment in time when the token will be expired.public JwtGenerator withSignatureAlgorithm(JwtSignatureAlgorithm signatureAlgorithm)
signatureAlgorithm - the signature algorithm.public JwtGenerator withPrivateKey(PrivateKey privateKey)
privateKey - the private key.public JwtGenerator withScopes(String... scopes)
Service.XSUAA.scopes - the scopes that should be part of the tokenIllegalArgumentException - if service is not Service.XSUAApublic Token createToken()
withSignatureAlgorithm(JwtSignatureAlgorithm) and the given key. By
defaultJwtSignatureAlgorithm.RS256 is used.Copyright © 2020. All rights reserved.