Interface KeyProvider
- All Known Implementing Classes:
EphemeralKeyProvider,StaticKeyProvider
requestState continuation tokens (see
AeadRequestStateCodec).
A dedicated abstraction beneath the AEAD codec so an operator can supply a stable, shared sealing key (fixing
horizontally-scaled RESUME behind a load balancer) and rotate keys via a keyId, while the codec's
zero-config default (EphemeralKeyProvider) keeps today's per-process ephemeral-key behavior unchanged.
Thread-safety. A single provider instance is shared across all requests against a binding (the codec
is per-binding), so implementations must be safe for concurrent calls to both currentKey() and
resolveKey(String).
Never-throw contract. resolveKey(String) is called on the unseal path with an untrusted,
client-supplied keyId. Implementations must treat any unknown or retired keyId as
Optional.empty() and must never throw — the caller (AeadRequestStateCodec#unseal) has no
exception-handling path for this call.
Not annotated @FunctionalInterface: unlike single-method SPIs such as
ApiKeyStore, this SPI declares two abstract methods.
See Also:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionThe key to seal new tokens with, together with its identifier.resolveKey(String keyId) Resolves akeyIdseen on an incoming token to the key that sealed it.
-
Method Details
-
currentKey
The key to seal new tokens with, together with its identifier.May return a different value over time — a changing return value is the sanctioned mechanism for live runtime key rotation in a custom provider. Built-in providers (
EphemeralKeyProvider,StaticKeyProvider) return a fixed value for the lifetime of the instance.- Returns:
- The current sealing key. Never
null .
-
resolveKey
Resolves akeyIdseen on an incoming token to the key that sealed it.- Parameters:
keyId- The key identifier read from the untrusted, client-supplied token, before decryption. Nevernull .- Returns:
- The resolved key, or
Optional.empty()ifkeyIdis unknown or retired. Never throws.
-