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:
JceMasterKey,KmsMasterKey
public abstract class MasterKey<K extends MasterKey<K>> extends MasterKeyProvider<K>
Represents the cryptographic key used to protect theDataKey(which, in turn, protects the data). All MasterKeys extendMasterKeyProviderbecause they are all capable of providing exactly themselves. This simplifies implementation when only a singleMasterKeyis used and/or expected.
-
-
Constructor Summary
Constructors Constructor Description MasterKey()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanProvide(String provider)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.booleanequals(Object obj)TwoMasterKeys are equal if they are instances of the exact same class and their values forkeyId,providerId, anddefaultProviderIdare equal.abstract DataKey<K>generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)StringgetDefaultProviderId()Equivalent to callinggetProviderId().abstract StringgetKeyId()KgetMasterKey(String provider, String keyId)ReturnsthisifproviderandkeyIdmatchthis.List<K>getMasterKeysForEncryption(MasterKeyRequest request)Returns a list of length1containingthis.abstract StringgetProviderId()inthashCode()StringtoString()-
Methods inherited from class com.amazonaws.encryptionsdk.MasterKeyProvider
buildCannotDecryptDksException, buildCannotDecryptDksException, buildCannotDecryptDksException, decryptDataKey, getMasterKey
-
-
-
-
Method Detail
-
getProviderId
public abstract String getProviderId()
-
getDefaultProviderId
public String getDefaultProviderId()
Equivalent to callinggetProviderId().- Specified by:
getDefaultProviderIdin classMasterKeyProvider<K extends MasterKey<K>>
-
getKeyId
public abstract String getKeyId()
-
generateDataKey
public abstract DataKey<K> generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)
-
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
public boolean canProvide(String provider)
- Overrides:
canProvidein classMasterKeyProvider<K extends MasterKey<K>>- Returns:
-
getMasterKey
public K getMasterKey(String provider, String keyId) throws UnsupportedProviderException, NoSuchMasterKeyException
ReturnsthisifproviderandkeyIdmatchthis. 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
-
getMasterKeysForEncryption
public List<K> getMasterKeysForEncryption(MasterKeyRequest request)
Returns a list of length1containingthis.- Specified by:
getMasterKeysForEncryptionin classMasterKeyProvider<K extends MasterKey<K>>
-
equals
public boolean equals(Object obj)
TwoMasterKeys are equal if they are instances of the exact same class and their values forkeyId,providerId, anddefaultProviderIdare equal.
-
-