Class DirectDataKeyStrategy

java.lang.Object
org.jwcarman.codec.crypto.DirectDataKeyStrategy
All Implemented Interfaces:
DataKeyStrategy

public final class DirectDataKeyStrategy extends Object implements 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 Details

    • DirectDataKeyStrategy

      public DirectDataKeyStrategy()
      Creates the strategy.
  • Method Details

    • acquire

      public DataKey acquire(DataKeyProvider provider)
      Description copied from interface: DataKeyStrategy
      Acquires the data key to use for the next message, consulting the given provider as needed.
      Specified by:
      acquire in interface DataKeyStrategy
      Parameters:
      provider - the provider to acquire a fresh data key from, if required
      Returns:
      the DataKey to use