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 TypeMethodDescriptionvoid
addGrantToken(String grantToken)
AddsgrantToken
to 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 provideddataKey
which is protected by thisMasterKey
for use withalgorithm
and 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()
void
setGrantTokens(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, toString
Methods inherited from class com.amazonaws.encryptionsdk.MasterKeyProvider
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, getMasterKey
-
Method Details
-
getProviderId
- Specified by:
getProviderId
in classMasterKey<AwsKmsMrkAwareMasterKey>
-
getKeyId
- Specified by:
getKeyId
in classMasterKey<AwsKmsMrkAwareMasterKey>
-
setGrantTokens
Clears and sets all grant tokens on this instance. This is not thread safe.- Specified by:
setGrantTokens
in interfaceKmsMethods
-
getGrantTokens
Description copied from interface:KmsMethods
Returns the grantTokens which this object sends to KMS when calling it.- Specified by:
getGrantTokens
in interfaceKmsMethods
-
addGrantToken
Description copied from interface:KmsMethods
AddsgrantToken
to the list of grantTokens sent to KMS when this class calls it.- Specified by:
addGrantToken
in interfaceKmsMethods
-
generateDataKey
public DataKey<AwsKmsMrkAwareMasterKey> generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)This is identical behavior to- Specified by:
generateDataKey
in 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:MasterKey
Returns a new copy of the provideddataKey
which is protected by thisMasterKey
for use withalgorithm
and associated with the providedencryptionContext
.- Specified by:
encryptDataKey
in 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:
decryptDataKey
in classMasterKeyProvider<AwsKmsMrkAwareMasterKey>
- Returns:
- a DataKey if one can be decrypted, otherwise returns
null
- Throws:
UnsupportedProviderException
- if theencryptedDataKey
is associated with an unsupported providerCannotUnwrapDataKeyException
- if theencryptedDataKey
cannot be decryptedAwsCryptoException
-