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 withAwsCrypto
. 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGrantToken(String grantToken)
AddsgrantToken
to the list of grantTokens sent to KMS when this class calls it.DataKey<AwsKmsMrkAwareMasterKey>
decryptDataKey(CryptoAlgorithm algorithm, Collection<? extends EncryptedDataKey> encryptedDataKeys, Map<String,String> encryptionContext)
Will attempt to decrypt if awsKmsArnMatchForDecrypt returns true inAwsKmsMrkAwareMasterKey#filterEncryptedDataKeys(String, AwsKmsCmkArnInfo, EncryptedDataKey)
.DataKey<AwsKmsMrkAwareMasterKey>
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
.DataKey<AwsKmsMrkAwareMasterKey>
generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)
This is identical behavior toList<String>
getGrantTokens()
Returns the grantTokens which this object sends to KMS when calling it.String
getKeyId()
String
getProviderId()
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 Detail
-
getProviderId
public String getProviderId()
- Specified by:
getProviderId
in classMasterKey<AwsKmsMrkAwareMasterKey>
-
getKeyId
public String getKeyId()
- Specified by:
getKeyId
in classMasterKey<AwsKmsMrkAwareMasterKey>
-
setGrantTokens
public void setGrantTokens(List<String> grantTokens)
Clears and sets all grant tokens on this instance. This is not thread safe.- Specified by:
setGrantTokens
in interfaceKmsMethods
-
getGrantTokens
public List<String> getGrantTokens()
Description copied from interface:KmsMethods
Returns the grantTokens which this object sends to KMS when calling it.- Specified by:
getGrantTokens
in interfaceKmsMethods
-
addGrantToken
public void addGrantToken(String grantToken)
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 AwsCryptoException
Will 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
-
-