Class StaticKeyProvider
java.lang.Object
org.apache.juneau.rest.server.mcp.v20260728.StaticKeyProvider
- All Implemented Interfaces:
KeyProvider
Built-in, immutable, static-at-startup
KeyProvider: an operator-supplied keyring of one or more AES
keys, one of which is designated the current sealing key. Unlike EphemeralKeyProvider, the keyring is
fixed at construction time (via StaticKeyProvider.Builder or of(String, SecretKey)) rather than generated
randomly, so it can be shared across process instances — the fix for horizontally-scaled MRTR RESUME
(see AeadRequestStateCodec).
Example:
KeyProvider
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SecretKeyaesKey(byte[] value) Builds an AESSecretKeyfrom raw key bytes.static SecretKeyBuilds an AESSecretKeyfrom base64-encoded key bytes.static StaticKeyProvider.Buildercreate()Creates a newStaticKeyProvider.Builder.The key to seal new tokens with, together with its identifier.static StaticKeyProviderOne-liner for the common single-shared-key case: a provider with exactly one key, designated current.resolveKey(String keyId) Resolves akeyIdseen on an incoming token to the key that sealed it.
-
Method Details
-
create
Creates a newStaticKeyProvider.Builder.- Returns:
- A new builder. Never
null .
-
of
One-liner for the common single-shared-key case: a provider with exactly one key, designated current.- Parameters:
keyId- The key's identifier. Must not benull or blank.key- The key material. Must not benull .- Returns:
- A new, immutable
StaticKeyProviderholding just this one key. Nevernull . - Throws:
IllegalArgumentException- IfkeyIdisnull /blank orkeyisnull .
-
aesKey
Builds an AESSecretKeyfrom raw key bytes.- Parameters:
value- The raw AES key bytes (16/24/32 bytes for AES-128/192/256). Must not benull .- Returns:
- A new AES
SecretKeywrappingvalue. Nevernull .
-
aesKey
Builds an AESSecretKeyfrom base64-encoded key bytes.- Parameters:
base64- The base64-encoded AES key bytes. Must not benull or blank.- Returns:
- A new AES
SecretKeywrapping the decoded bytes. Nevernull .
-
currentKey
Description copied from interface:KeyProviderThe 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.- Specified by:
currentKeyin interfaceKeyProvider- Returns:
- The current sealing key. Never
null .
-
resolveKey
Description copied from interface:KeyProviderResolves akeyIdseen on an incoming token to the key that sealed it.- Specified by:
resolveKeyin interfaceKeyProvider- 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.
-