Class LocalWrapKmsClient
java.lang.Object
org.apache.parquet.crypto.keytools.LocalWrapKmsClient
- All Implemented Interfaces:
KmsClient
Typically, KMS systems support in-server key wrapping. Their clients should implement KmsClient interface directly.
An extension of the LocalWrapKmsClient class should used only in rare situations where in-server wrapping is not
supported. The wrapping will be done locally then - the MEKs will be fetched from the KMS server via the
getMasterKeyFromServer function, and used to encrypt a DEK or KEK inside the LocalWrapKmsClient code.
Note: master key rotation is not supported with local wrapping.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.hadoop.conf.Configurationprotected Stringprotected Stringprotected Stringstatic final StringFields inherited from interface org.apache.parquet.crypto.keytools.KmsClient
KEY_ACCESS_TOKEN_DEFAULT, KMS_INSTANCE_ID_DEFAULT, KMS_INSTANCE_URL_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]getMasterKeyFromServer(String masterKeyIdentifier) Get master key from the remote KMS server.voidinitialize(org.apache.hadoop.conf.Configuration configuration, String kmsInstanceID, String kmsInstanceURL, String accessToken) Pass configuration with KMS-specific parameters.protected abstract voidPass configuration with KMS-specific parameters.byte[]Decrypts (unwraps) a key with the master key.Wraps a key - encrypts it with the master key, encodes the result and potentially adds a KMS-specific metadata.
-
Field Details
-
LOCAL_WRAP_NO_KEY_VERSION
- See Also:
-
kmsInstanceID
-
kmsInstanceURL
-
kmsToken
-
hadoopConfiguration
protected org.apache.hadoop.conf.Configuration hadoopConfiguration
-
-
Constructor Details
-
LocalWrapKmsClient
public LocalWrapKmsClient()
-
-
Method Details
-
initialize
public void initialize(org.apache.hadoop.conf.Configuration configuration, String kmsInstanceID, String kmsInstanceURL, String accessToken) Description copied from interface:KmsClientPass configuration with KMS-specific parameters.- Specified by:
initializein interfaceKmsClient- Parameters:
configuration- Hadoop configurationkmsInstanceID- ID of the KMS instance handled by this KmsClient. Use the default value, for KMS systems that don't work with multiple instances.kmsInstanceURL- URL of the KMS instance handled by this KmsClient. Use the default value, for KMS systems that don't work with URLs.accessToken- KMS access (authorization) token. Use the default value, for KMS systems that don't work with tokens.
-
wrapKey
Description copied from interface:KmsClientWraps a key - encrypts it with the master key, encodes the result and potentially adds a KMS-specific metadata.If your KMS client code throws runtime exceptions related to access/permission problems (such as Hadoop AccessControlException), catch them and throw the KeyAccessDeniedException.
- Specified by:
wrapKeyin interfaceKmsClient- Parameters:
key- : key bytes to be wrappedmasterKeyIdentifier- : a string that uniquely identifies the master key in a KMS instance- Returns:
- wrapped key
- Throws:
KeyAccessDeniedException- unauthorized to encrypt with the given master key
-
unwrapKey
public byte[] unwrapKey(String wrappedKey, String masterKeyIdentifier) throws KeyAccessDeniedException Description copied from interface:KmsClientDecrypts (unwraps) a key with the master key.If your KMS client code throws runtime exceptions related to access/permission problems (such as Hadoop AccessControlException), catch them and throw the KeyAccessDeniedException.
- Specified by:
unwrapKeyin interfaceKmsClient- Parameters:
wrappedKey- String produced by wrapKey operationmasterKeyIdentifier- : a string that uniquely identifies the master key in a KMS instance- Returns:
- unwrapped key bytes
- Throws:
KeyAccessDeniedException- unauthorized to unwrap with the given master key
-
getMasterKeyFromServer
protected abstract byte[] getMasterKeyFromServer(String masterKeyIdentifier) throws KeyAccessDeniedException Get master key from the remote KMS server.If your KMS client code throws runtime exceptions related to access/permission problems (such as Hadoop AccessControlException), catch them and throw the KeyAccessDeniedException.
- Parameters:
masterKeyIdentifier- : a string that uniquely identifies the master key in a KMS instance- Returns:
- master key bytes
- Throws:
KeyAccessDeniedException- unauthorized to get the master key
-
initializeInternal
Pass configuration with KMS-specific parameters.- Throws:
KeyAccessDeniedException
-