AWS KMS API: Difference between revisions
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
* [[Amazon_KMS#AWS_KMS_API|Amazon KMS]] | * [[Amazon_KMS#AWS_KMS_API|Amazon KMS]] | ||
* [[ | * [[AWS_SDK_for_Java_Version_2#Component_APIs|AWS SDK for Java Version 2]] | ||
=Overview= | =Overview= |
Revision as of 05:23, 3 October 2021
External
- https://docs.aws.amazon.com/kms/latest/developerguide/programming-top.html
- https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kms/AWSKMSClient.html
Internal
Overview
Dependencies
SKD 2
dependencies {
// SDK 2
implementation 'software.amazon.awssdk:kms:2.1.1'
}
SDK 1
dependencies {
// SDK 1
implementation 'com.amazonaws:aws-java-sdk-kms:1.11.458'
}
Playground Example
Setting Explicit Credentials
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.kms.AWSKMS;
import com.amazonaws.services.kms.AWSKMSClientBuilder;
import com.amazonaws.services.kms.model.DescribeKeyRequest;
import com.amazonaws.services.kms.model.DescribeKeyResult;
String masterKeyArn = "...";
AWSKMS kmsClient = AWSKMSClientBuilder.defaultClient();
DescribeKeyRequest req =
new DescribeKeyRequest().
withKeyId(masterKeyArn).
withRequestCredentialsProvider(new AWSCredentialsProvider() {
@Override
public AWSCredentials getCredentials() {
return new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return "my-access-key-id";
}
@Override
public String getAWSSecretKey() {
return "my-secret-key-id";
}
};
}
@Override
public void refresh() {
}
});
DescribeKeyResult res = kmsClient.describeKey(req);
Also see: