Class DirectDataKeyStrategy
java.lang.Object
org.jwcarman.codec.crypto.DirectDataKeyStrategy
- All Implemented Interfaces:
DataKeyStrategy
Default
DataKeyStrategy: acquires a fresh data-encryption key per message.
Stateless, and therefore trivially thread-safe. Because every message gets its own DEK, this strategy is nonce-misuse-immune by construction — there is no shared key under which two nonces could ever collide. This makes it the right default for an in-process JCE provider and the conservative choice for a remote KMS provider as well, at the cost of one network round trip per encoded message when the provider is backed by a KMS. Consumers who need to amortize that cost across multiple messages should use a bounded, caching strategy instead.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquire(DataKeyProvider provider) Acquires the data key to use for the next message, consulting the given provider as needed.
-
Constructor Details
-
DirectDataKeyStrategy
public DirectDataKeyStrategy()Creates the strategy.
-
-
Method Details
-
acquire
Description copied from interface:DataKeyStrategyAcquires the data key to use for the next message, consulting the given provider as needed.- Specified by:
acquirein interfaceDataKeyStrategy- Parameters:
provider- the provider to acquire a fresh data key from, if required- Returns:
- the
DataKeyto use
-