Package org.forgerock.json.jose.builders
Class JwtHeaderBuilder<T extends JwtBuilder,B extends JwtHeaderBuilder<T,B>>
java.lang.Object
org.forgerock.json.jose.builders.JwtHeaderBuilder<T,B>
- Type Parameters:
T
- the type of JwtBuilder that parents this JwtHeaderBuilder.B
- the type of this JwtHeaderBuilder
- Direct Known Subclasses:
JwtSecureHeaderBuilder
public abstract class JwtHeaderBuilder<T extends JwtBuilder,B extends JwtHeaderBuilder<T,B>>
extends Object
A base implementation of a JWT header builder that provides a fluent builder pattern to creating JWT headers.
See JwtHeader
for information on the JwtHeader object that this builder creates.
- Since:
- 2.0.0
-
Constructor Summary
ConstructorDescriptionJwtHeaderBuilder
(T jwtBuilder) Constructs a new JwtHeaderBuilder, parented by the given JwtBuilder. -
Method Summary
Modifier and TypeMethodDescriptionSets the algorithm used to perform cryptographic signing and/or encryption on the JWT.protected abstract JwtHeader
build()
Creates a JwtHeader instance from the header parameters set in this builder.done()
Marks the end to the building of the JWT header.Gets the header parameters for the JWT.Adds a custom header parameter to the JWT header.headerIfNotNull
(String key, Object value) Adds a customer header parameter to the JWT header if the value is not null.
-
Constructor Details
-
JwtHeaderBuilder
Constructs a new JwtHeaderBuilder, parented by the given JwtBuilder.- Parameters:
jwtBuilder
- The JwtBuilder instance that this JwtHeaderBuilder is a child of.
-
-
Method Details
-
header
Adds a custom header parameter to the JWT header.- Parameters:
key
- The header parameter key.value
- The header parameter value.- Returns:
- This JwtHeaderBuilder.
- See Also:
-
headerIfNotNull
Adds a customer header parameter to the JWT header if the value is not null.- Parameters:
key
- The header parameter key.value
- The header parameter value, or null if not specified.- Returns:
- This JwtHeaderBuilder.
-
alg
Sets the algorithm used to perform cryptographic signing and/or encryption on the JWT.- Parameters:
algorithm
- The algorithm.- Returns:
- This JwtHeaderBuilder.
- See Also:
-
done
Marks the end to the building of the JWT header.- Returns:
- The parent JwtBuilder for this JwtHeaderBuilder instance.
-
getHeaders
Gets the header parameters for the JWT.- Returns:
- The JWT's header parameters.
-
build
Creates a JwtHeader instance from the header parameters set in this builder.- Returns:
- A JwtHeader instance.
-