public interface JwtClaimsBuilder extends JwtSignature
JwtClaimsBuilder implementations must set the 'iat' (issued at time), 'exp' (expiration time) and 'jti' (unique token identifier) claims unless they have already been set. JwtClaimsBuilder must ensure a 'jti' claim value is unique when the same builder is used for building more than one token.
By default the 'iat' claim is set to the current time in seconds and the 'exp' claim is set by adding a default token lifespan value of 5 minutes to the 'iat' claim value. The 'smallrye.jwt.new-token.lifespan' property can be used to customize a new token lifespan and its 'exp' claim values.
The 'iss' (issuer) claim must be set if it has not already been set and the 'smallrye.jwt.new-token.issuer' property is set. The 'aud' (audience) claim must be set if it has not already been set and the 'smallrye.jwt.new-token.audience' property is set.
Note that 'smallrye.jwt.new-token.issuer' and 'smallrye.jwt.new-token.audience' property values, if set, will override the existing `iss` and `aud` claim values if the 'smallrye.jwt.new-token.override-matching-claims' is set to 'true'. For example, it can be useful when propagating a JWT token whose 'issuer' and/or `audience` properties have to be updated without using this interface.
Note that JwtClaimsBuilder implementations are not expected to be thread-safe.
| Modifier and Type | Method and Description |
|---|---|
JwtClaimsBuilder |
audience(Set<String> audiences)
Set a multiple value audience 'aud' claim
|
JwtClaimsBuilder |
audience(String audience)
Set a single value audience 'aud' claim
|
default JwtClaimsBuilder |
claim(org.eclipse.microprofile.jwt.Claims name,
Object value)
Set a claim.
|
JwtClaimsBuilder |
claim(String name,
Object value)
Set a claim.
|
default JwtClaimsBuilder |
expiresAt(Instant expiresAt)
Set an expiry 'exp' claim
|
JwtClaimsBuilder |
expiresAt(long expiresAt)
Set an expiry 'exp' claim
|
default JwtClaimsBuilder |
expiresIn(Duration expiresIn)
Set a relative expiry time.
|
JwtClaimsBuilder |
expiresIn(long expiresIn)
Set a relative expiry time.
|
JwtClaimsBuilder |
groups(Set<String> groups)
Set a multiple value 'groups' claim
|
JwtClaimsBuilder |
groups(String group)
Set a single value 'groups' claim
|
default JwtClaimsBuilder |
issuedAt(Instant issuedAt)
Set an issuedAt 'iat' claim
|
JwtClaimsBuilder |
issuedAt(long issuedAt)
Set an issuedAt 'iat' claim
|
JwtClaimsBuilder |
issuer(String issuer)
Set an issuer 'iss' claim
|
JwtEncryptionBuilder |
jwe()
Set JsonWebEncryption headers and encrypt the claims by moving to
JwtEncryptionBuilder |
JwtSignatureBuilder |
jws()
Set JsonWebSignature headers and sign the claims by moving to
JwtSignatureBuilder |
JwtClaimsBuilder |
preferredUserName(String preferredUserName)
Set a preferred user name 'preferred_username' claim
|
JwtClaimsBuilder |
subject(String subject)
Set a subject 'sub' claim
|
JwtClaimsBuilder |
upn(String upn)
Set a 'upn' claim
|
innerSign, innerSign, innerSign, innerSign, innerSignWithSecret, sign, sign, sign, sign, signWithSecretJwtClaimsBuilder issuer(String issuer)
issuer - the issuerJwtClaimsBuilder subject(String subject)
subject - the subjectJwtClaimsBuilder upn(String upn)
upn - the upnJwtClaimsBuilder preferredUserName(String preferredUserName)
preferredUserName - the preferred user nameJwtClaimsBuilder issuedAt(long issuedAt)
issuedAt - the issuedAt time in secondsdefault JwtClaimsBuilder issuedAt(Instant issuedAt)
issuedAt - the issuedAt time in secondsJwtClaimsBuilder expiresAt(long expiresAt)
expiresAt - the absolute expiry time in secondsdefault JwtClaimsBuilder expiresAt(Instant expiresAt)
expiresAt - the absolute expiry time in secondsJwtClaimsBuilder expiresIn(long expiresIn)
expiresIn - the relative expiry time in seconds which will be added to the 'iat' (issued at) claim value
to calculate the value of the 'exp' (expires at) claim.default JwtClaimsBuilder expiresIn(Duration expiresIn)
expiresIn - the relative expiry time in seconds which will be added to the 'iat' (issued at) claim value
to calculate the value of the 'exp' (expires at) claim.JwtClaimsBuilder groups(String group)
group - the groupsJwtClaimsBuilder groups(Set<String> groups)
groups - the groupsJwtClaimsBuilder audience(String audience)
audience - the audienceJwtClaimsBuilder audience(Set<String> audiences)
audiences - the audiencesdefault JwtClaimsBuilder claim(org.eclipse.microprofile.jwt.Claims name, Object value)
String unless it is an instance of Boolean, Number or
Instant. Instant values have their number of seconds from the epoch converted to long.
Array claims can be set as Collection or JsonArray and complex claims can be set as Map or
JsonObject. The members of the array claims can be complex claims.
Types of claims directly supported by this builder are enforced.
The 'iss' (issuer), 'sub' (subject), 'upn', 'preferred_username' and 'jti' (token identifier) claims must be of
String type.
The 'aud' (audience) and 'groups' claims must be either of String or Collection of String type.
The 'iat' (issued at) and 'exp' (expires at) claims must be either of long or Instant type.name - the claim namevalue - the claim valueIllegalArgumentException - - if the type of the claim directly supported by this builder is wrongJwtClaimsBuilder claim(String name, Object value)
String unless it is an instance of Boolean, Number or
Instant. Instant values have their number of seconds from the epoch converted to long.
Array claims can be set as Collection or JsonArray, complex claims can be set as Map or
JsonObject. The members of the array claims can be complex claims.
Types of the claims directly supported by this builder are enforced.
The 'iss' (issuer), 'sub' (subject), 'upn', 'preferred_username' and 'jti' (token identifier) claims must be of
String type.
The 'aud' (audience) and 'groups' claims must be either of String or Collection of String type.
The 'iat' (issued at) and 'exp' (expires at) claims must be either of long or Instant type.name - the claim namevalue - the claim valueIllegalArgumentException - - if the type of the claim directly supported by this builder is wrongJwtSignatureBuilder jws()
JwtSignatureBuilderJwtEncryptionBuilder jwe()
JwtEncryptionBuilderCopyright © 2018–2022. All rights reserved.