Package com.amazonaws.encryptionsdk
Class MasterKey<K extends MasterKey<K>>
java.lang.Object
com.amazonaws.encryptionsdk.MasterKeyProvider<K>
com.amazonaws.encryptionsdk.MasterKey<K>
- Type Parameters:
K- the concrete type of theMasterKey
- Direct Known Subclasses:
AwsKmsMrkAwareMasterKey,JceMasterKey,KmsMasterKey
Represents the cryptographic key used to protect the
DataKey (which, in turn, protects
the data).
All MasterKeys extend MasterKeyProvider because they are all capable of providing
exactly themselves. This simplifies implementation when only a single MasterKey is used
and/or expected.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanProvide(String provider)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.booleanTwoMasterKeys are equal if they are instances of the exact same class and their values forkeyId,providerId, anddefaultProviderIdare equal.generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)Equivalent to callinggetProviderId().abstract StringgetKeyId()getMasterKey(String provider, String keyId)ReturnsthisifproviderandkeyIdmatchthis.getMasterKeysForEncryption(MasterKeyRequest request)Returns a list of length1containingthis.abstract StringinthashCode()toString()Methods inherited from class com.amazonaws.encryptionsdk.MasterKeyProvider
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, decryptDataKey, getMasterKey
-
Constructor Details
-
MasterKey
public MasterKey()
-
-
Method Details
-
getProviderId
-
getDefaultProviderId
Equivalent to callinggetProviderId().- Specified by:
getDefaultProviderIdin classMasterKeyProvider<K extends MasterKey<K>>
-
getKeyId
-
generateDataKey
-
encryptDataKey
public abstract DataKey<K> 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. -
canProvide
- Overrides:
canProvidein classMasterKeyProvider<K extends MasterKey<K>>- Returns:
-
getMasterKey
public K getMasterKey(String provider, String keyId) throws UnsupportedProviderException, NoSuchMasterKeyExceptionReturnsthisifproviderandkeyIdmatchthis. Otherwise, throws an appropriate exception.- Specified by:
getMasterKeyin classMasterKeyProvider<K extends MasterKey<K>>- Returns:
- Throws:
UnsupportedProviderException- if this object cannot returnMasterKeys associated with the given providerNoSuchMasterKeyException- if this object cannot find (and thus construct) theMasterKeyassociated withkeyId
-
toString
-
getMasterKeysForEncryption
Returns a list of length1containingthis.- Specified by:
getMasterKeysForEncryptionin classMasterKeyProvider<K extends MasterKey<K>>
-
equals
TwoMasterKeys are equal if they are instances of the exact same class and their values forkeyId,providerId, anddefaultProviderIdare equal. -
hashCode
public int hashCode()
-