StaticStorageKeyProvider
A StorageKeyProvider over keys the application already holds, for example keys it loaded from its own secret store, and for tests. loadOrCreateKey returns current and never creates a key; createKey only returns a key that was passed in. removeKey forgets the key in this instance; deleting its copy is up to the application. The keys only live in memory; this class is not secure key storage.
Functions
Creates key id for a storage key rotation and returns it once it is persisted and read back. If the provider already has key id, returns that key unchanged: a key is never overwritten or replaced, so a repeated or concurrent call yields the same key. Other keys are not touched. Throws StorageEncryptionException.KeyUnavailable if the provider holds no key yet (rotation needs provisioned storage) or its state cannot be read; nothing is changed then.
The key for storage that has no key bound yet: a new database, or a database from before record encryption that is about to be encrypted. Returns the provider's only key, or creates and persists key ID 1 if the provider has none. Throws StorageEncryptionException.KeyUnavailable if the provider holds several keys (its namespace belongs to a database in or after a storage key rotation) or no key can be provided.
Removes key id, for retiring a storage key after a rotation proved that no record uses it. Returns true if this call removed it and false if the provider did not have it. Other keys are not touched. Throws IllegalStateException and changes nothing if id is the provider's last key: a provider never removes all of its keys.