Example usage for com.amazonaws.services.kms AWSKMSClient AWSKMSClient

List of usage examples for com.amazonaws.services.kms AWSKMSClient AWSKMSClient

Introduction

In this page you can find the example usage for com.amazonaws.services.kms AWSKMSClient AWSKMSClient.

Prototype

@Deprecated
public AWSKMSClient() 

Source Link

Document

Constructs a new client to invoke service methods on KMS.

Usage

From source file:com.nike.cerberus.aws.KmsClientFactory.java

License:Apache License

/**
 * Returns a KMS client for the given region.  Clients are cached by region.
 *
 * @param region Region to configure a client for
 * @return AWS KMS client//from   w w w .  j  a  v  a  2s  .  c om
 */
public AWSKMSClient getClient(Region region) {
    AWSKMSClient client = kmsClientMap.get(region);

    if (client == null) {
        final AWSKMSClient newClient = new AWSKMSClient();
        newClient.setRegion(region);
        kmsClientMap.put(region, newClient);
        client = newClient;
    }

    return client;
}

From source file:de.zalando.spring.cloud.config.aws.kms.test.EncryptionCLI.java

License:Apache License

@Override
public void run(final String... args) {
    try {/*  w  ww.j  a  v a 2 s  . c om*/
        checkArgument(args.length >= 3, "Too few arguments.");

        final String text = args[1];
        final AWSKMSClient kms = new AWSKMSClient();
        kms.setRegion(fromName(args[2]));

        switch (args[0]) {

        case "encrypt":
            checkArgument(args.length == 4, "Too few arguments.");
            System.out.println(new KmsTextEncryptor(kms, args[3]).encrypt(text));
            break;

        case "decrypt":
            System.out.println(new KmsTextEncryptor(kms, null).decrypt(text));
            break;

        default:

            break;
        }
    } catch (final IllegalArgumentException e) {
        System.out.println(e.getMessage() + " Usage:\n" //
                + "./run.sh encrypt 'plaintext' eu-west-1 ${kmsKeyId}\n" //
                + "./run.sh decrypt 'base64cipherText' eu-west-1");
    }
}

From source file:ws.salient.aws.AmazonClientProvider.java

License:Apache License

public AmazonClientProvider() {
    Region region = Regions.getCurrentRegion();
    if (region == null) {
        region = Region.getRegion(Regions.US_EAST_1);
    }/*from w w w  .jav  a  2s. c om*/
    s3 = new AmazonS3Client().withRegion(region);
    kms = new AWSKMSClient().withRegion(region);
    dynamodb = new DynamoDB(new AmazonDynamoDBClient().withRegion(region));
    lambda = new AWSLambdaClient().withRegion(region);
}