public class KeyManagementUtility
extends java.lang.Object
| Constructor and Description |
|---|
KeyManagementUtility(KeyManager keyManager,
MetadataManager metadataManager,
java.sql.Connection connection,
software.amazon.awssdk.services.kms.KmsClient kmsClient,
EncryptionConfig config) |
KeyManagementUtility(KeyManager keyManager,
MetadataManager metadataManager,
javax.sql.DataSource dataSource,
software.amazon.awssdk.services.kms.KmsClient kmsClient,
EncryptionConfig config) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
createMasterKeyWithPermissions(java.lang.String description)
Creates a master key with default permissions suitable for JDBC encryption.
|
java.lang.String |
createMasterKeyWithPermissions(java.lang.String description,
java.lang.String keyPolicy)
Creates a new KMS master key with proper permissions for encryption operations.
|
void |
generateAndStoreDataKey(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn,
java.lang.String algorithm)
Generates and stores a data key for the specified table and column.
|
java.util.List<java.lang.String> |
getColumnsUsingKey(java.lang.String keyId)
Lists all columns that use a specific key ID.
|
void |
initializeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn)
Initializes encryption for a new table and column combination.
|
void |
initializeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn,
java.lang.String algorithm)
Initializes encryption for a new table and column combination with specified algorithm.
|
void |
removeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName)
Removes encryption configuration for a table and column.
|
void |
rotateDataKey(java.lang.String tableName,
java.lang.String columnName,
@Nullable java.lang.String newMasterKeyArn)
Rotates the data key for an existing encrypted column.
|
boolean |
validateMasterKey(java.lang.String masterKeyArn)
Validates that a master key exists and is accessible.
|
public KeyManagementUtility(KeyManager keyManager, MetadataManager metadataManager, javax.sql.DataSource dataSource, software.amazon.awssdk.services.kms.KmsClient kmsClient, EncryptionConfig config)
public KeyManagementUtility(KeyManager keyManager, MetadataManager metadataManager, java.sql.Connection connection, software.amazon.awssdk.services.kms.KmsClient kmsClient, EncryptionConfig config)
public java.lang.String createMasterKeyWithPermissions(java.lang.String description,
java.lang.String keyPolicy)
throws KeyManagementException
description - Description for the master keykeyPolicy - Optional key policy JSON string. If null, uses default policyKeyManagementException - if key creation failspublic java.lang.String createMasterKeyWithPermissions(java.lang.String description)
throws KeyManagementException
description - Description for the master keyKeyManagementException - if key creation failspublic void generateAndStoreDataKey(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn,
java.lang.String algorithm)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnmasterKeyArn - ARN of the master key to usealgorithm - Encryption algorithm (defaults to AES-256-GCM if null)KeyManagementException - if key generation or storage failspublic void rotateDataKey(java.lang.String tableName,
java.lang.String columnName,
@Nullable java.lang.String newMasterKeyArn)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnnewMasterKeyArn - Optional new master key ARN. If null, uses existing master keyKeyManagementException - if key rotation failspublic void initializeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnmasterKeyArn - ARN of the master key to useKeyManagementException - if initialization failspublic void initializeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName,
java.lang.String masterKeyArn,
java.lang.String algorithm)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnmasterKeyArn - ARN of the master key to usealgorithm - Encryption algorithm to useKeyManagementException - if initialization failspublic void removeEncryptionForColumn(java.lang.String tableName,
java.lang.String columnName)
throws KeyManagementException
tableName - Name of the tablecolumnName - Name of the columnKeyManagementException - if removal failspublic java.util.List<java.lang.String> getColumnsUsingKey(java.lang.String keyId)
throws KeyManagementException
keyId - The key ID to search forKeyManagementException - if query failspublic boolean validateMasterKey(java.lang.String masterKeyArn)
throws KeyManagementException
masterKeyArn - ARN of the master key to validateKeyManagementException - if validation fails