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 TypeMethodDescriptionboolean
canProvide(String provider)
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
.boolean
TwoMasterKey
s are equal if they are instances of the exact same class and their values forkeyId
,providerId
, anddefaultProviderId
are equal.generateDataKey(CryptoAlgorithm algorithm, Map<String,String> encryptionContext)
Equivalent to callinggetProviderId()
.abstract String
getKeyId()
getMasterKey(String provider, String keyId)
Returnsthis
ifprovider
andkeyId
matchthis
.getMasterKeysForEncryption(MasterKeyRequest request)
Returns a list of length1
containingthis
.abstract String
int
hashCode()
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:
getDefaultProviderId
in 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 provideddataKey
which is protected by thisMasterKey
for use withalgorithm
and associated with the providedencryptionContext
. -
canProvide
- Overrides:
canProvide
in classMasterKeyProvider<K extends MasterKey<K>>
- Returns:
-
getMasterKey
public K getMasterKey(String provider, String keyId) throws UnsupportedProviderException, NoSuchMasterKeyExceptionReturnsthis
ifprovider
andkeyId
matchthis
. Otherwise, throws an appropriate exception.- Specified by:
getMasterKey
in classMasterKeyProvider<K extends MasterKey<K>>
- Returns:
- Throws:
UnsupportedProviderException
- if this object cannot returnMasterKey
s associated with the given providerNoSuchMasterKeyException
- if this object cannot find (and thus construct) theMasterKey
associated withkeyId
-
toString
-
getMasterKeysForEncryption
Returns a list of length1
containingthis
.- Specified by:
getMasterKeysForEncryption
in classMasterKeyProvider<K extends MasterKey<K>>
-
equals
TwoMasterKey
s are equal if they are instances of the exact same class and their values forkeyId
,providerId
, anddefaultProviderId
are equal. -
hashCode
public int hashCode()
-