Class PublishedJwk.Builder
java.lang.Object
com.revetsec.jose.PublishedJwk.Builder
- Enclosing class:
PublishedJwk
Configures an immutable published public key. Optional setters replace prior values;
null clears them.
Key parameters and certificate encodings are snapshotted before assignment.- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionalgorithm(@Nullable JwsAlgorithm algorithm) Replaces the optional algorithm restriction.build()Returns a published key with the builder's current public parameters and metadata.certificateChain(@Nullable List<@NonNull X509Certificate> certificateChain) Replaces the certificate chain with a checked snapshot, leaf first.Replaces the optional key identifier.
-
Method Details
-
keyId
Replaces the optional key identifier. It must contain 1–256 UTF-16 code units and valid Unicode.- Parameters:
keyId- the JWKkid, ornullto clear it- Returns:
- this builder
- Throws:
IllegalArgumentException- if the identifier is empty, too long or invalid Unicode- Since:
- 1.0.0
-
algorithm
@CanIgnoreReturnValue public @NonNull PublishedJwk.Builder algorithm(@Nullable JwsAlgorithm algorithm) Replaces the optional algorithm restriction. RSA supports RS256/384/512 and PS256/384/512; EC supports ES256, ES384 or ES512 on its corresponding curve; Ed25519 supports ED25519 and the legacy EDDSA name.- Parameters:
algorithm- the JWKalg, ornullto omit it- Returns:
- this builder
- Throws:
IllegalArgumentException- if the algorithm does not match the key, including every HMAC algorithm- Since:
- 1.0.0
-
certificateChain
@CanIgnoreReturnValue public @NonNull PublishedJwk.Builder certificateChain(@Nullable List<@NonNull X509Certificate> certificateChain) Replaces the certificate chain with a checked snapshot, leaf first. The leaf must match the public key and permit digital signatures when key usage is present. Each following certificate must be its predecessor's signing CA, with a matching issuer name and valid certificate signature. Duplicate certificates are refused. The chain need not end at a root; trust, validity periods and revocation are not evaluated.At most 16 certificates, 64 KiB per DER certificate and 128 KiB of total DER are accepted. The leaf's SHA-1 and SHA-256 thumbprints are derived for
x5tandx5t#S256; SHA-1 is only a certificate identifier.- Parameters:
certificateChain- the leaf-first chain, ornullor an empty list to clear certificate metadata- Returns:
- this builder
- Throws:
IllegalArgumentException- if the chain is oversized, malformed, inconsistent or mismatched- Since:
- 1.0.0
-
build
Returns a published key with the builder's current public parameters and metadata.- Returns:
- the immutable public signing key
- Since:
- 1.0.0
-