Package com.amazonaws.encryptionsdk.kms
Class AwsKmsMrkAwareMasterKey
java.lang.Object
com.amazonaws.encryptionsdk.MasterKeyProvider<K>
com.amazonaws.encryptionsdk.MasterKey<AwsKmsMrkAwareMasterKey>
com.amazonaws.encryptionsdk.kms.AwsKmsMrkAwareMasterKey
- All Implemented Interfaces:
KmsMethods
public final class AwsKmsMrkAwareMasterKey
extends MasterKey<AwsKmsMrkAwareMasterKey>
implements KmsMethods
Represents a single Aws KMS key and is used to encrypt/decrypt data with
AwsCrypto. This
key may be a multi region key, in which case this component is able to recognize different
regional replicas of this multi region key as the same.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddGrantToken(String grantToken)AddsgrantTokento the list of grantTokens sent to KMS when this class calls it.decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext)Will attempt to decrypt if awsKmsArnMatchForDecrypt returns true inAwsKmsMrkAwareMasterKey#filterEncryptedDataKeys(String, AwsKmsCmkArnInfo, EncryptedDataKey).encryptDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext, DataKey<?> dataKey)Returns a new copy of the provideddataKeywhich is protected by thisMasterKeyfor use withalgorithmand associated with the providedencryptionContext.generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)This is identical behavior toReturns the grantTokens which this object sends to KMS when calling it.getKeyId()voidsetGrantTokens(List<String> grantTokens)Clears and sets all grant tokens on this instance.Methods inherited from class com.amazonaws.encryptionsdk.MasterKey
canProvide, equals, getDefaultProviderId, getMasterKey, getMasterKeysForEncryption, hashCode, toStringMethods inherited from class com.amazonaws.encryptionsdk.MasterKeyProvider
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, getMasterKey
-
Method Details
-
getProviderId
- Specified by:
getProviderIdin classMasterKey<AwsKmsMrkAwareMasterKey>
-
getKeyId
- Specified by:
getKeyIdin classMasterKey<AwsKmsMrkAwareMasterKey>
-
setGrantTokens
Clears and sets all grant tokens on this instance. This is not thread safe.- Specified by:
setGrantTokensin interfaceKmsMethods
-
getGrantTokens
Description copied from interface:KmsMethodsReturns the grantTokens which this object sends to KMS when calling it.- Specified by:
getGrantTokensin interfaceKmsMethods
-
addGrantToken
Description copied from interface:KmsMethodsAddsgrantTokento the list of grantTokens sent to KMS when this class calls it.- Specified by:
addGrantTokenin interfaceKmsMethods
-
generateDataKey
public DataKey<AwsKmsMrkAwareMasterKey> generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)This is identical behavior to- Specified by:
generateDataKeyin classMasterKey<AwsKmsMrkAwareMasterKey>- See Also:
KmsMasterKey.generateDataKey(CryptoAlgorithm, Map)
-
encryptDataKey
public DataKey<AwsKmsMrkAwareMasterKey> encryptDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext, DataKey<?> dataKey)Description copied from class:MasterKeyReturns a new copy of the provideddataKeywhich is protected by thisMasterKeyfor use withalgorithmand associated with the providedencryptionContext.- Specified by:
encryptDataKeyin classMasterKey<AwsKmsMrkAwareMasterKey>- See Also:
KmsMasterKey.encryptDataKey(CryptoAlgorithm, Map, DataKey)
-
decryptDataKey
public DataKey<AwsKmsMrkAwareMasterKey> decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext) throws AwsCryptoExceptionWill attempt to decrypt if awsKmsArnMatchForDecrypt returns true inAwsKmsMrkAwareMasterKey#filterEncryptedDataKeys(String, AwsKmsCmkArnInfo, EncryptedDataKey). An extension ofKmsMasterKey.decryptDataKey(CryptoAlgorithm, Collection, Map)but with an awareness of the properties of multi-Region keys.- Specified by:
decryptDataKeyin classMasterKeyProvider<AwsKmsMrkAwareMasterKey>- Returns:
- a DataKey if one can be decrypted, otherwise returns
null - Throws:
UnsupportedProviderException- if theencryptedDataKeyis associated with an unsupported providerCannotUnwrapDataKeyException- if theencryptedDataKeycannot be decryptedAwsCryptoException
-