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

    Modifier and Type
    Method
    Description
    alg(Algorithm algorithm)
    Sets the algorithm used to perform cryptographic signing and/or encryption on the JWT.
    protected abstract JwtHeader
    Creates a JwtHeader instance from the header parameters set in this builder.
    Marks the end to the building of the JWT header.
    protected Map<String,Object>
    Gets the header parameters for the JWT.
    header(String key, Object value)
    Adds a custom header parameter to the JWT header.
    Adds a customer header parameter to the JWT header if the value is not null.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 Details

    • 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:
    • 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:
    • 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.