Class JwtSigningHeader

java.lang.Object
com.revetsec.jose.JwtSigningHeader

@Immutable public final class JwtSigningHeader extends Object
Immutable protected-header metadata for signing a JWT: its required type and optional key identifier and SHA-256 certificate thumbprint. The alg header comes from the JwsSigner; callers cannot configure a conflicting algorithm here.

Arrays are defensively copied. String rendering never exposes configured identifiers or certificate digests.

Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • withType

      @CheckReturnValue public static @NonNull JwtSigningHeader.Builder withType(@NonNull JwtType type)
      Starts a header builder with the required token type.
      Parameters:
      type - the protected-header token type
      Returns:
      the builder
      Throws:
      NullPointerException - if type is null
      Since:
      1.0.0
    • fromType

      @CheckReturnValue public static @NonNull JwtSigningHeader fromType(@NonNull JwtType type)
      Returns a header with the required token type and no key identifier or certificate thumbprint. Equivalent to withType(type).build().
      Parameters:
      type - the protected-header token type
      Returns:
      the immutable header
      Throws:
      NullPointerException - if type is null
      Since:
      1.0.0
    • getType

      Returns the required protected-header typ selection.
      Returns:
      the token type
      Since:
      1.0.0
    • getKeyId

      Returns the optional protected-header kid value.
      Returns:
      the key identifier when configured
      Since:
      1.0.0
    • getCertificateSha256Thumbprint

      Returns a copy of the optional SHA-256 digest of a DER certificate, serialized as x5t#S256 when signing.
      Returns:
      a copy of the certificate digest when configured
      Since:
      1.0.0
    • toString

      Returns a description without configured identifiers or certificate digests.
      Overrides:
      toString in class Object
      Returns:
      the redacted description
      Since:
      1.0.0