public class EncryptRequest extends AmazonWebServiceRequest implements Serializable
Encrypts plaintext into ciphertext by using a customer master key (CMK). The
Encrypt operation has two primary use cases:
You can encrypt up to 4 kilobytes (4096 bytes) of arbitrary data such as an RSA key, a database password, or other sensitive information.
You can use the Encrypt operation to move encrypted data from
one AWS region to another. In the first region, generate a data key and use
the plaintext key to encrypt the data. Then, in the new region, call the
Encrypt method on same plaintext data key. Now, you can safely
move the encrypted data and encrypted data key to the new region, and decrypt
in the new region when necessary.
You don't need use this operation to encrypt a data key within a region. The GenerateDataKey and GenerateDataKeyWithoutPlaintext operations return an encrypted data key.
Also, you don't need to use this operation to encrypt data in your
application. You can use the plaintext and encrypted data keys that the
GenerateDataKey operation returns.
The result of this operation varies with the key state of the CMK. For details, see How Key State Affects Use of a Customer Master Key in the AWS Key Management Service Developer Guide.
To perform this operation on a CMK in a different AWS account, specify the key ARN or alias ARN in the value of the KeyId parameter.
| Constructor and Description |
|---|
EncryptRequest() |
| Modifier and Type | Method and Description |
|---|---|
EncryptRequest |
addEncryptionContextEntry(String key,
String value)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
EncryptRequest |
clearEncryptionContextEntries()
Removes all the entries added into EncryptionContext.
|
boolean |
equals(Object obj) |
Map<String,String> |
getEncryptionContext()
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
List<String> |
getGrantTokens()
A list of grant tokens.
|
String |
getKeyId()
A unique identifier for the customer master key (CMK).
|
ByteBuffer |
getPlaintext()
Data to be encrypted.
|
int |
hashCode() |
void |
setEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
void |
setGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
|
void |
setKeyId(String keyId)
A unique identifier for the customer master key (CMK).
|
void |
setPlaintext(ByteBuffer plaintext)
Data to be encrypted.
|
String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
EncryptRequest |
withEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption.
|
EncryptRequest |
withGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
|
EncryptRequest |
withGrantTokens(String... grantTokens)
A list of grant tokens.
|
EncryptRequest |
withKeyId(String keyId)
A unique identifier for the customer master key (CMK).
|
EncryptRequest |
withPlaintext(ByteBuffer plaintext)
Data to be encrypted.
|
clone, copyBaseTo, getCloneRoot, getCloneSource, getGeneralProgressListener, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setGeneralProgressListener, setRequestCredentials, setRequestMetricCollector, withGeneralProgressListener, withRequestMetricCollectorpublic String getKeyId()
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name,
or alias ARN. When using an alias name, prefix it with
"alias/". To specify a CMK in a different AWS account, you
must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Constraints:
Length: 1 - 2048
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN),
alias name, or alias ARN. When using an alias name, prefix it
with "alias/". To specify a CMK in a different AWS
account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public void setKeyId(String keyId)
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name,
or alias ARN. When using an alias name, prefix it with
"alias/". To specify a CMK in a different AWS account, you
must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Constraints:
Length: 1 - 2048
keyId - A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN),
alias name, or alias ARN. When using an alias name, prefix it
with "alias/". To specify a CMK in a different
AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public EncryptRequest withKeyId(String keyId)
A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN), alias name,
or alias ARN. When using an alias name, prefix it with
"alias/". To specify a CMK in a different AWS account, you
must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 2048
keyId - A unique identifier for the customer master key (CMK).
To specify a CMK, use its key ID, Amazon Resource Name (ARN),
alias name, or alias ARN. When using an alias name, prefix it
with "alias/". To specify a CMK in a different
AWS account, you must use the key ARN or alias ARN.
For example:
Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
Alias name: alias/ExampleAlias
Alias ARN:
arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias
To get the key ID and key ARN for a CMK, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases.
public ByteBuffer getPlaintext()
Data to be encrypted.
Constraints:
Length: 1 - 4096
Data to be encrypted.
public void setPlaintext(ByteBuffer plaintext)
Data to be encrypted.
Constraints:
Length: 1 - 4096
plaintext - Data to be encrypted.
public EncryptRequest withPlaintext(ByteBuffer plaintext)
Data to be encrypted.
Returns a reference to this object so that method calls can be chained together.
Constraints:
Length: 1 - 4096
plaintext - Data to be encrypted.
public Map<String,String> getEncryptionContext()
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
Name-value pair that specifies the encryption context to be used
for authenticated encryption. If used here, the same value must
be supplied to the Decrypt API or decryption will
fail. For more information, see Encryption Context.
public void setEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
encryptionContext -
Name-value pair that specifies the encryption context to be
used for authenticated encryption. If used here, the same
value must be supplied to the Decrypt API or
decryption will fail. For more information, see Encryption Context.
public EncryptRequest withEncryptionContext(Map<String,String> encryptionContext)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
Returns a reference to this object so that method calls can be chained together.
encryptionContext -
Name-value pair that specifies the encryption context to be
used for authenticated encryption. If used here, the same
value must be supplied to the Decrypt API or
decryption will fail. For more information, see Encryption Context.
public EncryptRequest addEncryptionContextEntry(String key, String value)
Name-value pair that specifies the encryption context to be used for
authenticated encryption. If used here, the same value must be supplied
to the Decrypt API or decryption will fail. For more
information, see Encryption Context.
The method adds a new key-value pair into EncryptionContext parameter, and returns a reference to this object so that method calls can be chained together.
key - The key of the entry to be added into EncryptionContext.value - The corresponding value of the entry to be added into
EncryptionContext.public EncryptRequest clearEncryptionContextEntries()
Returns a reference to this object so that method calls can be chained together.
public List<String> getGrantTokens()
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public void setGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public EncryptRequest withGrantTokens(String... grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
Returns a reference to this object so that method calls can be chained together.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public EncryptRequest withGrantTokens(Collection<String> grantTokens)
A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
Returns a reference to this object so that method calls can be chained together.
grantTokens - A list of grant tokens.
For more information, see Grant Tokens in the AWS Key Management Service Developer Guide.
public String toString()
toString in class ObjectObject.toString()Copyright © 2019. All rights reserved.