Class PlainHeader.Builder

  • Enclosing class:
    PlainHeader

    public static class PlainHeader.Builder
    extends Object
    Builder for constructing unsecured (plain) headers.

    Example usage:

     PlainHeader header = new PlainHeader.Builder().
                          contentType("text/plain").
                          customParam("exp", new Date().getTime()).
                          build();
     
    • Constructor Detail

      • Builder

        public Builder()
        Creates a new unsecured (plain) header builder.
      • Builder

        public Builder​(PlainHeader plainHeader)
        Creates a new unsecured (plain) header builder with the parameters from the specified header.
        Parameters:
        plainHeader - The unsecured header to use. Must not be null.
    • Method Detail

      • contentType

        public PlainHeader.Builder contentType​(String cty)
        Sets the content type (cty) parameter.
        Parameters:
        cty - The content type parameter, null if not specified.
        Returns:
        This builder.
      • criticalParams

        public PlainHeader.Builder criticalParams​(Set<String> crit)
        Sets the critical header parameters (crit) parameter.
        Parameters:
        crit - The names of the critical header parameters, empty set or null if none.
        Returns:
        This builder.
      • customParam

        public PlainHeader.Builder customParam​(String name,
                                               Object value)
        Sets a custom (non-registered) parameter.
        Parameters:
        name - The name of the custom parameter. Must not match a registered parameter name and must not be null.
        value - The value of the custom parameter, should map to a valid JSON entity, null if not specified.
        Returns:
        This builder.
        Throws:
        IllegalArgumentException - If the specified parameter name matches a registered parameter name.
      • customParams

        public PlainHeader.Builder customParams​(Map<String,​Object> customParameters)
        Sets the custom (non-registered) parameters. The values must be serialisable to a JSON entity, otherwise will be ignored.
        Parameters:
        customParameters - The custom parameters, empty map or null if none.
        Returns:
        This builder.
      • parsedBase64URL

        public PlainHeader.Builder parsedBase64URL​(Base64URL base64URL)
        Sets the parsed Base64URL.
        Parameters:
        base64URL - The parsed Base64URL, null if the header is created from scratch.
        Returns:
        This builder.
      • build

        public PlainHeader build()
        Builds a new unsecured (plain) header.
        Returns:
        The unsecured header.