/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.kms.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** *
* Returns the public key of an asymmetric KMS key. Unlike the private key of a
* asymmetric KMS key, which never leaves KMS unencrypted, callers with
* kms:GetPublicKey
permission can download the public key of an
* asymmetric KMS key. You can share the public key to allow others to encrypt
* messages and verify signatures outside of KMS. For information about
* asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer
* Guide.
*
* You do not need to download the public key. Instead, you can use the public * key within KMS by calling the Encrypt, ReEncrypt, or * Verify operations with the identifier of an asymmetric KMS key. When * you use the public key within KMS, you benefit from the authentication, * authorization, and logging that are part of every KMS operation. You also * reduce of risk of encrypting data that cannot be decrypted. These features * are not effective outside of KMS. *
*
* To help you use the public key safely outside of KMS,
* GetPublicKey
returns important information about the public key
* in the response, including:
*
* KeySpec: The type of key material in the public key, such as
* RSA_4096
or ECC_NIST_P521
.
*
* KeyUsage: Whether the key is used for encryption or signing. *
** EncryptionAlgorithms or SigningAlgorithms: A list of the encryption algorithms or the signing * algorithms for the key. *
** Although KMS cannot enforce these restrictions on external operations, it is * crucial that you use this information to prevent the public key from being * used improperly. For example, you can prevent a public signing key from being * used encrypt data, or prevent a public key from being used with an encryption * algorithm that is not supported by KMS. You can also avoid errors, such as * using the wrong signing algorithm in a verification operation. *
*
* To verify a signature outside of KMS with an SM2 public key (China Regions
* only), you must specify the distinguishing ID. By default, KMS uses
* 1234567812345678
as the distinguishing ID. For more information,
* see Offline verification with SM2 key pairs.
*
* The KMS key that you use for this operation must be in a compatible key * state. For details, see Key states of KMS keys in the Key Management Service Developer * Guide. *
*
* Cross-account use: Yes. To perform this operation with a KMS key in a
* different Amazon Web Services account, specify the key ARN or alias ARN in
* the value of the KeyId
parameter.
*
* Required permissions: kms:GetPublicKey (key policy) *
** Related operations: CreateKey *
*/ public class GetPublicKeyRequest extends AmazonWebServiceRequest implements Serializable { /** ** Identifies the asymmetric KMS key that includes the public key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN.
* When using an alias name, prefix it with "alias/"
. To
* specify a KMS key in a different Amazon Web Services 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 KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *
*
* Constraints:
* Length: 1 - 2048
*/
private String keyId;
/**
*
* A list of grant tokens. *
** Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *
*/ private java.util.List* Identifies the asymmetric KMS key that includes the public key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN.
* When using an alias name, prefix it with "alias/"
. To
* specify a KMS key in a different Amazon Web Services 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 KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *
*
* Constraints:
* Length: 1 - 2048
*
* @return
* Identifies the asymmetric KMS key that includes the public key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or
* alias ARN. When using an alias name, prefix it with
* "alias/"
. To specify a KMS key in a different Amazon
* Web Services 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 KMS key, use ListKeys * or DescribeKey. To get the alias name and alias ARN, use * ListAliases. *
*/ public String getKeyId() { return keyId; } /** ** Identifies the asymmetric KMS key that includes the public key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN.
* When using an alias name, prefix it with "alias/"
. To
* specify a KMS key in a different Amazon Web Services 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 KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *
*
* Constraints:
* Length: 1 - 2048
*
* @param keyId
* Identifies the asymmetric KMS key that includes the public * key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or
* alias ARN. When using an alias name, prefix it with
* "alias/"
. To specify a KMS key in a different
* Amazon Web Services 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 KMS key, use * ListKeys or DescribeKey. To get the alias name * and alias ARN, use ListAliases. *
*/ public void setKeyId(String keyId) { this.keyId = keyId; } /** ** Identifies the asymmetric KMS key that includes the public key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN.
* When using an alias name, prefix it with "alias/"
. To
* specify a KMS key in a different Amazon Web Services 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 KMS key, 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
*
* @param keyId
* Identifies the asymmetric KMS key that includes the public * key. *
*
* To specify a KMS key, use its key ID, key ARN, alias name, or
* alias ARN. When using an alias name, prefix it with
* "alias/"
. To specify a KMS key in a different
* Amazon Web Services 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 KMS key, use * ListKeys or DescribeKey. To get the alias name * and alias ARN, use ListAliases. *
* @return A reference to this updated object so that method calls can be * chained together. */ public GetPublicKeyRequest withKeyId(String keyId) { this.keyId = keyId; return this; } /** ** A list of grant tokens. *
** Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *
* * @return* A list of grant tokens. *
** Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *
*/ public java.util.List* A list of grant tokens. *
** Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *
* * @param grantTokens* A list of grant tokens. *
** Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *
*/ public void setGrantTokens(java.util.Collection* A list of grant tokens. *
** Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *
** Returns a reference to this object so that method calls can be chained * together. * * @param grantTokens
* A list of grant tokens. *
** Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *
* @return A reference to this updated object so that method calls can be * chained together. */ public GetPublicKeyRequest withGrantTokens(String... grantTokens) { if (getGrantTokens() == null) { this.grantTokens = new java.util.ArrayList* A list of grant tokens. *
** Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *
** Returns a reference to this object so that method calls can be chained * together. * * @param grantTokens
* A list of grant tokens. *
** Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *
* @return A reference to this updated object so that method calls can be * chained together. */ public GetPublicKeyRequest withGrantTokens(java.util.Collection