public static class JWTCreator.Builder
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
sign(Algorithm algorithm)
Creates a new JWT and signs is with the given algorithm
|
JWTCreator.Builder |
withArrayClaim(java.lang.String name,
java.lang.Integer[] items)
Add a custom Array Claim with the given items.
|
JWTCreator.Builder |
withArrayClaim(java.lang.String name,
java.lang.Long[] items)
Add a custom Array Claim with the given items.
|
JWTCreator.Builder |
withArrayClaim(java.lang.String name,
java.lang.String[] items)
Add a custom Array Claim with the given items.
|
JWTCreator.Builder |
withAudience(java.lang.String... audience)
Add a specific Audience ("aud") claim to the Payload.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.lang.Boolean value)
Add a custom Claim value.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.util.Date value)
Add a custom Claim value.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.lang.Double value)
Add a custom Claim value.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.lang.Integer value)
Add a custom Claim value.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.lang.Long value)
Add a custom Claim value.
|
JWTCreator.Builder |
withClaim(java.lang.String name,
java.lang.String value)
Add a custom Claim value.
|
JWTCreator.Builder |
withExpiresAt(java.util.Date expiresAt)
Add a specific Expires At ("exp") claim to the Payload.
|
JWTCreator.Builder |
withHeader(java.util.Map<java.lang.String,java.lang.Object> headerClaims)
Add specific Claims to set as the Header.
|
JWTCreator.Builder |
withIssuedAt(java.util.Date issuedAt)
Add a specific Issued At ("iat") claim to the Payload.
|
JWTCreator.Builder |
withIssuer(java.lang.String issuer)
Add a specific Issuer ("iss") claim to the Payload.
|
JWTCreator.Builder |
withJWTId(java.lang.String jwtId)
Add a specific JWT Id ("jti") claim to the Payload.
|
JWTCreator.Builder |
withKeyId(java.lang.String keyId)
Add a specific Key Id ("kid") claim to the Header.
|
JWTCreator.Builder |
withNotBefore(java.util.Date notBefore)
Add a specific Not Before ("nbf") claim to the Payload.
|
JWTCreator.Builder |
withSubject(java.lang.String subject)
Add a specific Subject ("sub") claim to the Payload.
|
public JWTCreator.Builder withHeader(java.util.Map<java.lang.String,java.lang.Object> headerClaims)
headerClaims - the values to use as Claims in the token's Header.public JWTCreator.Builder withKeyId(java.lang.String keyId)
Algorithm used to sign this token was instantiated with a KeyProvider, the 'kid' value will be taken from that provider and this one will be ignored.keyId - the Key Id value.public JWTCreator.Builder withIssuer(java.lang.String issuer)
issuer - the Issuer value.public JWTCreator.Builder withSubject(java.lang.String subject)
subject - the Subject value.public JWTCreator.Builder withAudience(java.lang.String... audience)
audience - the Audience value.public JWTCreator.Builder withExpiresAt(java.util.Date expiresAt)
expiresAt - the Expires At value.public JWTCreator.Builder withNotBefore(java.util.Date notBefore)
notBefore - the Not Before value.public JWTCreator.Builder withIssuedAt(java.util.Date issuedAt)
issuedAt - the Issued At value.public JWTCreator.Builder withJWTId(java.lang.String jwtId)
jwtId - the Token Id value.public JWTCreator.Builder withClaim(java.lang.String name, java.lang.Boolean value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withClaim(java.lang.String name, java.lang.Integer value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withClaim(java.lang.String name, java.lang.Long value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withClaim(java.lang.String name, java.lang.Double value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withClaim(java.lang.String name, java.lang.String value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withClaim(java.lang.String name, java.util.Date value) throws java.lang.IllegalArgumentException
name - the Claim's name.value - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withArrayClaim(java.lang.String name, java.lang.String[] items) throws java.lang.IllegalArgumentException
name - the Claim's name.items - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withArrayClaim(java.lang.String name, java.lang.Integer[] items) throws java.lang.IllegalArgumentException
name - the Claim's name.items - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public JWTCreator.Builder withArrayClaim(java.lang.String name, java.lang.Long[] items) throws java.lang.IllegalArgumentException
name - the Claim's name.items - the Claim's value.java.lang.IllegalArgumentException - if the name is null.public java.lang.String sign(Algorithm algorithm) throws java.lang.IllegalArgumentException, JWTCreationException
algorithm - used to sign the JWTjava.lang.IllegalArgumentException - if the provided algorithm is null.JWTCreationException - if the claims could not be converted to a valid JSON or there was a problem with the signing key.