Class JwtHeaderBuilder<T extends JwtBuilder,​B extends 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 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.
      • 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.