public class KeyManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
KeyManager.DataKeyResult
Result class for data key generation operations.
|
| Constructor and Description |
|---|
KeyManager(software.amazon.awssdk.services.kms.KmsClient kmsClient,
java.sql.Connection connection,
boolean isPostgreSQL,
EncryptionConfig config) |
KeyManager(software.amazon.awssdk.services.kms.KmsClient kmsClient,
PluginService pluginService,
EncryptionConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clears the data key cache.
|
java.lang.String |
createMasterKey(java.lang.String description)
Creates a new KMS master key with the specified description.
|
byte[] |
decryptDataKey(java.lang.String encryptedDataKey,
java.lang.String masterKeyArn)
Decrypts an encrypted data key using KMS with caching support.
|
KeyManager.DataKeyResult |
generateDataKey(java.lang.String masterKeyArn)
Generates a new data key using the specified master key.
|
java.lang.String |
generateKeyId()
Generates a unique key ID for new keys to store in the database.
|
DataKeyCache |
getDataKeyCache()
Returns the data key cache for metrics and management.
|
java.util.Optional<KeyMetadata> |
getKeyMetadata(java.lang.String keyId)
Retrieves key metadata from the database for the specified key ID.
|
boolean |
isPostgreSQL() |
void |
shutdown()
Shuts down the key manager and cleans up resources.
|
int |
storeKeyMetadata(java.lang.String tableName,
java.lang.String columnName,
KeyMetadata keyMetadata)
Stores key metadata in the database for the specified table and column.
|
void |
updateLastUsed(java.lang.String keyId)
Updates the last used timestamp for the specified key.
|
public KeyManager(software.amazon.awssdk.services.kms.KmsClient kmsClient,
PluginService pluginService,
EncryptionConfig config)
public KeyManager(software.amazon.awssdk.services.kms.KmsClient kmsClient,
java.sql.Connection connection,
boolean isPostgreSQL,
EncryptionConfig config)
public boolean isPostgreSQL()
public java.lang.String createMasterKey(java.lang.String description)
throws KeyManagementException
description - Description for the master keyKeyManagementException - if key creation failspublic KeyManager.DataKeyResult generateDataKey(java.lang.String masterKeyArn) throws KeyManagementException
masterKeyArn - ARN of the master key to use for data key generationKeyManagementException - if data key generation failspublic byte[] decryptDataKey(java.lang.String encryptedDataKey,
java.lang.String masterKeyArn)
throws KeyManagementException
encryptedDataKey - Base64-encoded encrypted data keymasterKeyArn - ARN of the master key used for encryptionKeyManagementException - if decryption failspublic int storeKeyMetadata(java.lang.String tableName,
java.lang.String columnName,
KeyMetadata keyMetadata)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnkeyMetadata - Key metadata to storeKeyManagementException - if storage failspublic java.util.Optional<KeyMetadata> getKeyMetadata(java.lang.String keyId) throws KeyManagementException
keyId - Key ID to retrieve metadata forKeyManagementException - if retrieval failspublic void updateLastUsed(java.lang.String keyId)
throws KeyManagementException
keyId - Key ID to updateKeyManagementException - if update failspublic java.lang.String generateKeyId()
public DataKeyCache getDataKeyCache()
public void clearCache()
public void shutdown()