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
Constructors Constructor Description JwtHeaderBuilder(T jwtBuilder)
Constructs a new JwtHeaderBuilder, parented by the given JwtBuilder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description B
alg(Algorithm algorithm)
Sets 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.T
done()
Marks the end to the building of the JWT header.protected Map<String,Object>
getHeaders()
Gets the header parameters for the JWT.B
header(String key, Object value)
Adds a custom header parameter to the JWT header.B
headerIfNotNull(String key, Object value)
Adds a customer header parameter to the JWT header if the value is not null.
-
-
-
Constructor Detail
-
JwtHeaderBuilder
public JwtHeaderBuilder(T jwtBuilder)
Constructs a new JwtHeaderBuilder, parented by the given JwtBuilder.- Parameters:
jwtBuilder
- The JwtBuilder instance that this JwtHeaderBuilder is a child of.
-
-
Method Detail
-
header
public B header(String key, Object value)
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:
JwtHeader.setParameter(String, Object)
-
headerIfNotNull
public B headerIfNotNull(String key, Object value)
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
public B alg(Algorithm algorithm)
Sets the algorithm used to perform cryptographic signing and/or encryption on the JWT.- Parameters:
algorithm
- The algorithm.- Returns:
- This JwtHeaderBuilder.
- See Also:
JwtHeader.setAlgorithm(org.forgerock.json.jose.jwt.Algorithm)
-
done
public T done()
Marks the end to the building of the JWT header.- Returns:
- The parent JwtBuilder for this JwtHeaderBuilder instance.
-
getHeaders
protected Map<String,Object> getHeaders()
Gets the header parameters for the JWT.- Returns:
- The JWT's header parameters.
-
build
protected abstract JwtHeader build()
Creates a JwtHeader instance from the header parameters set in this builder.- Returns:
- A JwtHeader instance.
-
-