Interface EncryptionStorageManager
- All Superinterfaces:
AutoCloseable, SafeCloseable
- All Known Implementing Classes:
NoopEncryptionStorageManager
Manages the storage of encrypted data at rest.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCurrentDekListener(String projectName, String repoName, Consumer<SecretKeyWithVersion> listener) Adds a listener that is called when the current DEK for a repository is updated or removed.voidaddSessionKeyListener(Consumer<SessionKey> listener) Adds a listener that is called when a new session key is stored.booleancontainsMetadata(byte[] key) Returnstrueif the specified key exists.voiddeleteObjectId(byte[] metadataKey, byte[] key) Deletes the specified keys.voiddeleteRepositoryData(String projectName, String repoName) Deletes all data related to the specified project and repository.booleanenabled()Returnstrueif the encryption is enabled.booleanReturnstrueif the session cookie should be encrypted.generateSessionMasterKey(int version) Generates a new session master key.Generates a new data encryption key (DEK) and wraps it.Deprecated.Do not use this method for production code as it may return a large amount of data.getCurrentDek(String projectName, String repoName) Returns the current wrapped data encryption key (WDEK) for the specified project and repository.Returns the current session key that is derived from the current session master key.Returns the current session master key.Returns the data encryption key (DEK) for the specified project and repository.byte @Nullable []getMetadata(byte[] metadataKey) Returns the value of the specified metadata key.byte @Nullable []getObject(byte[] key, byte[] metadataKey) Returns the object associated with the specified key.byte @Nullable []getObjectId(byte[] key, byte[] metadataKey) Returns the object ID bytes associated with the specified key.getSessionKey(int version) Returns the session key for the specified version.kekId()Returns the ID of the key encryption key (KEK).static EncryptionStorageManagerof(CentralDogmaConfig cfg) Creates a newEncryptionStorageManagerinstance.static EncryptionStorageManagerCreates a newEncryptionStorageManagerinstance.voidputObject(byte[] metadataKey, byte[] metadataValue, byte[] key, byte[] value) Stores the specified key-value object with metadata.voidputObjectId(byte[] metadataKey, byte[] metadataValue, byte[] key, byte[] value, byte @Nullable [] previousKeyToRemove) Stores the specified key-value pair with metadata.voidreencryptRepositoryData(String projectName, String repoName) Re-encrypts all data for the specified repository with the current DEK version.voidremoveCurrentDekListener(String projectName, String repoName) Removes a previously registered current DEK listener.voidremoveWdek(String projectName, String repoName, int version, boolean removeCurrent) Removes the wrapped data encryption key (WDEK) for the specified project and repository.rewrapAllKeys(Executor executor) Rewraps all wrapped data encryption keys (WDEKs) and session master keys with theEncryptionConfig.kekId()specified in the configuration.voidrotateSessionMasterKey(SessionMasterKey sessionMasterKey) Rotates the session master key.voidrotateWdek(WrappedDekDetails wdekDetails) Rotates the wrapped data encryption key (WDEK) for theWrappedDekDetails.projectName()andWrappedDekDetails.repoName().voidstoreSessionMasterKey(SessionMasterKey sessionMasterKey) Stores the session master key.voidstoreWdek(WrappedDekDetails wdekDetails) Stores the wrapped data encryption key (WDEK) for theWrappedDekDetails.projectName()andWrappedDekDetails.repoName().wdeks()Returns all wrapped data encryption keys (WDEKs).Methods inherited from interface SafeCloseable
close
-
Method Details
-
of
Creates a newEncryptionStorageManagerinstance. -
of
Creates a newEncryptionStorageManagerinstance. -
enabled
boolean enabled()Returnstrueif the encryption is enabled. -
encryptSessionCookie
boolean encryptSessionCookie()Returnstrueif the session cookie should be encrypted. -
kekId
String kekId()Returns the ID of the key encryption key (KEK). -
generateWdek
CompletableFuture<String> generateWdek()Generates a new data encryption key (DEK) and wraps it. -
generateSessionMasterKey
Generates a new session master key. -
storeSessionMasterKey
Stores the session master key. -
getCurrentSessionMasterKey
SessionMasterKey getCurrentSessionMasterKey()Returns the current session master key. -
getCurrentSessionKey
CompletableFuture<SessionKey> getCurrentSessionKey()Returns the current session key that is derived from the current session master key. -
getSessionKey
Returns the session key for the specified version. -
rotateSessionMasterKey
Rotates the session master key. -
wdeks
List<WrappedDekDetails> wdeks()Returns all wrapped data encryption keys (WDEKs). -
getDek
-
getCurrentDek
Returns the current wrapped data encryption key (WDEK) for the specified project and repository. -
storeWdek
Stores the wrapped data encryption key (WDEK) for theWrappedDekDetails.projectName()andWrappedDekDetails.repoName(). This raises an exception if the WDEK already exists. -
rotateWdek
Rotates the wrapped data encryption key (WDEK) for theWrappedDekDetails.projectName()andWrappedDekDetails.repoName(). -
removeWdek
-
getObject
byte @Nullable [] getObject(byte[] key, byte[] metadataKey) Returns the object associated with the specified key. -
getObjectId
byte @Nullable [] getObjectId(byte[] key, byte[] metadataKey) Returns the object ID bytes associated with the specified key. -
getMetadata
byte @Nullable [] getMetadata(byte[] metadataKey) Returns the value of the specified metadata key. -
putObject
void putObject(byte[] metadataKey, byte[] metadataValue, byte[] key, byte[] value) Stores the specified key-value object with metadata. -
putObjectId
void putObjectId(byte[] metadataKey, byte[] metadataValue, byte[] key, byte[] value, byte @Nullable [] previousKeyToRemove) Stores the specified key-value pair with metadata. ThepreviousKeyToRemovewill be removed. -
containsMetadata
boolean containsMetadata(byte[] key) Returnstrueif the specified key exists. -
deleteObjectId
void deleteObjectId(byte[] metadataKey, byte[] key) Deletes the specified keys. -
deleteRepositoryData
-
reencryptRepositoryData
-
getAllData
Deprecated.Do not use this method for production code as it may return a large amount of data.Returns all data stored in the encryption storage manager. -
addSessionKeyListener
Adds a listener that is called when a new session key is stored. -
addCurrentDekListener
void addCurrentDekListener(String projectName, String repoName, Consumer<SecretKeyWithVersion> listener) Adds a listener that is called when the current DEK for a repository is updated or removed. The listener receives the project/repo key and the new DEK (or null if removed). -
removeCurrentDekListener
-
rewrapAllKeys
Rewraps all wrapped data encryption keys (WDEKs) and session master keys with theEncryptionConfig.kekId()specified in the configuration.- Parameters:
executor- theExecutorto use for storing re-wrapped keys.
-