java.lang.Object
io.helidon.security.jwt.JwtHeaders.Builder
- All Implemented Interfaces:
Builder<JwtHeaders.Builder,
,JwtHeaders> Supplier<JwtHeaders>
- Enclosing class:
- JwtHeaders
public static class JwtHeaders.Builder
extends Object
implements Builder<JwtHeaders.Builder,JwtHeaders>
Fluent API builder to create JWT Header.
-
Method Summary
Modifier and TypeMethodDescriptionaddHeaderAudience
(String audience) Audience identifies the expected recipients of this JWT (optional).addHeaderClaim
(String claim, Object value) Add a header claim.The "alg" claim is used to define the signature algorithm.build()
Build the instance from this builder.contentType
(String contentType) This header claim should only be used when nesting or encrypting JWT.encryption
(String encryption) Encryption algorithm to use.headerAudience
(List<String> audience) Audience identifies the expected recipients of this JWT (optional).headerIssuer
(String issuer) The issuer claim identifies the principal that issued the JWT.headerSubject
(String subject) Subject defines the principal this JWT was issued for (e.g.Key id to be used to sign/verify this JWT.Type of this JWT.
-
Method Details
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<JwtHeaders.Builder,
JwtHeaders> - Returns:
- instance of the built type
-
addHeaderClaim
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
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
Encryption algorithm to use.- Parameters:
encryption
- encryption to use- Returns:
- updated builder
-
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
Key id to be used to sign/verify this JWT.- Parameters:
keyId
- key id (pointing to a JWK)- Returns:
- updated builder instance
-
type
Type of this JWT.- Parameters:
type
- type definition (JWT, JWE)- Returns:
- updated builder instance
-
headerSubject
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
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
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
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
-