- java.lang.Object
-
- io.helidon.security.jwt.JwtHeaders.Builder
-
- All Implemented Interfaces:
Builder<JwtHeaders>
,Supplier<JwtHeaders>
- Enclosing class:
- JwtHeaders
public static class JwtHeaders.Builder extends Object implements Builder<JwtHeaders>
Fluent API builder to create JWT Header.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JwtHeaders.Builder
addHeaderAudience(String audience)
Audience identifies the expected recipients of this JWT (optional).JwtHeaders.Builder
addHeaderClaim(String claim, Object value)
Add a header claim.JwtHeaders.Builder
algorithm(String algorithm)
The "alg" claim is used to define the signature algorithm.JwtHeaders
build()
Build the instance from this builder.JwtHeaders.Builder
contentType(String contentType)
This header claim should only be used when nesting or encrypting JWT.JwtHeaders.Builder
encryption(String encryption)
Encryption algorithm to use.JwtHeaders.Builder
headerAudience(List<String> audience)
Audience identifies the expected recipients of this JWT (optional).JwtHeaders.Builder
headerIssuer(String issuer)
The issuer claim identifies the principal that issued the JWT.JwtHeaders.Builder
headerSubject(String subject)
Subject defines the principal this JWT was issued for (e.g.JwtHeaders.Builder
keyId(String keyId)
Key id to be used to sign/verify this JWT.JwtHeaders.Builder
type(String type)
Type of this JWT.
-
-
-
Method Detail
-
build
public JwtHeaders build()
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<JwtHeaders>
- Returns:
- instance of the built type
-
addHeaderClaim
public JwtHeaders.Builder addHeaderClaim(String claim, Object value)
Add a header claim.- Parameters:
claim
- name of the claimvalue
- claim value, must be of expected type- Returns:
- updated builder
- Throws:
IllegalArgumentException
- if a known header (such asiss
,aud
) is set to a non-string type
-
algorithm
public JwtHeaders.Builder algorithm(String algorithm)
The "alg" claim is used to define the signature algorithm. Note that this algorithm should be the same as is supported by the JWK used to sign (or verify) the JWT.- Parameters:
algorithm
- algorithm to use,Jwk.ALG_NONE
for none- Returns:
- updated builder instance
-
encryption
public JwtHeaders.Builder encryption(String encryption)
Encryption algorithm to use.- Parameters:
encryption
- encryption to use- Returns:
- updated builder
-
contentType
public JwtHeaders.Builder contentType(String contentType)
This header claim should only be used when nesting or encrypting JWT. See RFC 7519, section 5.2.- Parameters:
contentType
- content type to use, use "JWT" if nested- Returns:
- updated builder instance
-
keyId
public JwtHeaders.Builder keyId(String keyId)
Key id to be used to sign/verify this JWT.- Parameters:
keyId
- key id (pointing to a JWK)- Returns:
- updated builder instance
-
type
public JwtHeaders.Builder type(String type)
Type of this JWT.- Parameters:
type
- type definition (JWT, JWE)- Returns:
- updated builder instance
-
headerSubject
public JwtHeaders.Builder headerSubject(String subject)
Subject defines the principal this JWT was issued for (e.g. user id). This configures subject in header claims (usually it is part of payload). See RFC 7519, section 4.1.2.- Parameters:
subject
- subject of this JWt- Returns:
- updated builder instance
-
headerIssuer
public JwtHeaders.Builder headerIssuer(String issuer)
The issuer claim identifies the principal that issued the JWT. This configures issuer in header claims (usually it is part of payload). See RFC 7519, section 4.1.1.- Parameters:
issuer
- issuer name or URL- Returns:
- updated builder instance
-
addHeaderAudience
public JwtHeaders.Builder addHeaderAudience(String audience)
Audience identifies the expected recipients of this JWT (optional). Multiple audience may be added. This configures audience in header claims, usually this is defined in payload. See RFC 7519, section 4.1.3.- Parameters:
audience
- audience of this JWT- Returns:
- updated builder instance
- See Also:
headerAudience(java.util.List)
-
headerAudience
public JwtHeaders.Builder headerAudience(List<String> audience)
Audience identifies the expected recipients of this JWT (optional). Replaces existing configured audiences. This configures audience in header claims, usually this is defined in payload. See RFC 7519, section 4.1.3.- Parameters:
audience
- audience of this JWT- Returns:
- updated builder instance
-
-