Search in sources :

Example 11 with KmsClient

use of software.amazon.awssdk.services.kms.KmsClient in project aws-doc-sdk-examples by awsdocs.

the class DisableCustomerKey method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <keyId> \n\n" + "Where:\n" + "    keyId - a key id value to disable (for example, xxxxxbcd-12ab-34cd-56ef-1234567890ab). \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String keyId = args[0];
    Region region = Region.US_WEST_2;
    KmsClient kmsClient = KmsClient.builder().region(region).build();
    disableKey(kmsClient, keyId);
    kmsClient.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) KmsClient(software.amazon.awssdk.services.kms.KmsClient)

Example 12 with KmsClient

use of software.amazon.awssdk.services.kms.KmsClient in project aws-doc-sdk-examples by awsdocs.

the class EncryptDataKey method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <keyId> \n\n" + "Where:\n" + "    keyId - a key id value to use to encrypt/decrypt the data (for example, xxxxxbcd-12ab-34cd-56ef-1234567890ab). \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String keyId = args[0];
    Region region = Region.US_WEST_2;
    KmsClient kmsClient = KmsClient.builder().region(region).build();
    SdkBytes encryData = encryptData(kmsClient, keyId);
    decryptData(kmsClient, encryData, keyId);
    System.out.println("Done");
    kmsClient.close();
}
Also used : SdkBytes(software.amazon.awssdk.core.SdkBytes) Region(software.amazon.awssdk.regions.Region) KmsClient(software.amazon.awssdk.services.kms.KmsClient)

Example 13 with KmsClient

use of software.amazon.awssdk.services.kms.KmsClient in project aws-doc-sdk-examples by awsdocs.

the class ListGrants method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <keyId> \n\n" + "Where:\n" + "    keyId - a key id value to use (for example, xxxxxbcd-12ab-34cd-56ef-1234567890ab). \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String keyId = args[0];
    Region region = Region.US_WEST_2;
    KmsClient kmsClient = KmsClient.builder().region(region).build();
    displayGrantIds(kmsClient, keyId);
    kmsClient.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) KmsClient(software.amazon.awssdk.services.kms.KmsClient)

Example 14 with KmsClient

use of software.amazon.awssdk.services.kms.KmsClient in project aws-doc-sdk-examples by awsdocs.

the class RevokeGrant method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <keyId> <grantId> \n\n" + "Where:\n" + "    keyId - a unique identifier for the customer master key associated with the grant (for example, xxxxxbcd-12ab-34cd-56ef-1234567890ab). \n\n" + "    grantId - a grant id value of the grant revoke. \n\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String keyId = args[0];
    String grantId = args[1];
    Region region = Region.US_WEST_2;
    KmsClient kmsClient = KmsClient.builder().region(region).build();
    revokeKeyGrant(kmsClient, keyId, grantId);
    kmsClient.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) KmsClient(software.amazon.awssdk.services.kms.KmsClient)

Example 15 with KmsClient

use of software.amazon.awssdk.services.kms.KmsClient in project aws-doc-sdk-examples by awsdocs.

the class DescribeKey method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <keyId> \n\n" + "Where:\n" + "    keyId -  a key id value to describe (for example, xxxxxbcd-12ab-34cd-56ef-1234567890ab). \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String keyId = args[0];
    Region region = Region.US_WEST_2;
    KmsClient kmsClient = KmsClient.builder().region(region).build();
    describeSpecifcKey(kmsClient, keyId);
    kmsClient.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) KmsClient(software.amazon.awssdk.services.kms.KmsClient)

Aggregations

KmsClient (software.amazon.awssdk.services.kms.KmsClient)17 Region (software.amazon.awssdk.regions.Region)15 SdkBytes (software.amazon.awssdk.core.SdkBytes)3 KmsException (software.amazon.awssdk.services.kms.model.KmsException)2 DynamoDbClient (software.amazon.awssdk.services.dynamodb.DynamoDbClient)1 DecryptRequest (software.amazon.awssdk.services.kms.model.DecryptRequest)1 DecryptResponse (software.amazon.awssdk.services.kms.model.DecryptResponse)1 EncryptRequest (software.amazon.awssdk.services.kms.model.EncryptRequest)1 EncryptResponse (software.amazon.awssdk.services.kms.model.EncryptResponse)1