Class PublishedJwk

java.lang.Object
com.revetsec.jose.PublishedJwk

@Immutable public final class PublishedJwk extends Object
An immutable public signing key for publication in a JSON Web Key Set (RFC 7517). RSA, EC on P-256, P-384 or P-521, and Ed25519 public keys are supported; shared secrets and private keys cannot be published here.

RSA publication requires generic RSA key material with algorithm RSA and no key-level PSS parameters. RSASSA-PSS containers/restricted keys are outside this publication profile, even when a selected PSS signer can use them. Publication does not erase or reinterpret key restrictions.

Only the public key is required. The key identifier, algorithm and certificate chain are optional. No algorithm is inferred when it is absent. Every key advertises use=sig.

Public parameters are copied when the builder starts, and certificate DER is copied and checked when its setter is called. Neither the builder nor the built key retains caller-owned key or certificate objects. A certificate chain supplies x5c, x5t and x5t#S256; certificate trust and validity periods are the application's responsibility.

Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • withPublicKey

      @CheckReturnValue public static @NonNull PublishedJwk.Builder withPublicKey(@NonNull PublicKey publicKey)
      Starts a builder with a checked snapshot of a public key.
      Parameters:
      publicKey - the public signing key
      Returns:
      the builder
      Throws:
      NullPointerException - if publicKey is null
      IllegalArgumentException - if the key is unsupported, malformed or refused by Revetsec's key policy
      Since:
      1.0.0
    • fromPublicKey

      @CheckReturnValue public static @NonNull PublishedJwk fromPublicKey(@NonNull PublicKey publicKey)
      Returns a public signing key without optional metadata; equivalent to withPublicKey(publicKey).build().
      Parameters:
      publicKey - the public signing key
      Returns:
      the immutable published key
      Throws:
      NullPointerException - if publicKey is null
      IllegalArgumentException - if the key is unsupported, malformed or refused by Revetsec's key policy
      Since:
      1.0.0
    • getKeyId

      Returns the optional JWK kid value.
      Returns:
      the configured key identifier, or empty
      Since:
      1.0.0
    • getAlgorithm

      Returns the optional JWK alg value. No algorithm is inferred from the public key.
      Returns:
      the configured algorithm, or empty
      Since:
      1.0.0
    • toJson

      Serializes this key's public JWK representation, including optional certificate metadata, to JSON text.
      Returns:
      the JWK JSON text; no private or symmetric key parameters are included
      Since:
      1.0.0
    • toJsonObject

      Returns this key's immutable public JWK representation, including optional certificate metadata.
      Returns:
      the JWK; no private or symmetric key parameters are included
      Since:
      1.0.0
    • toString

      Describes this object without configured key identifiers, key parameters or certificate material.
      Overrides:
      toString in class Object
      Returns:
      the description
      Since:
      1.0.0