Alibaba Cloud SDK for Java lets you call KMS through OpenAPI to manage keys and secrets and to perform cryptographic operations such as encryption, decryption, and secrets retrieval. Management operations (such as creating keys) are available through the shared gateway. Business operations are available through both the shared gateway and the dedicated gateway.
For available versions, source code, and SDK reference, see kms-20160120.
Before you start, review the Alibaba Cloud SDK overview to understand supported APIs, gateway differences, and the integration workflow.
Prerequisites
Before you begin, ensure that you have:
A KMS instance that is purchased and enabled. See Purchase and enable a KMS instance.
A key or secret created based on your business needs. See Software-protected keys, Hardware-protected keys, and Create a secret.
Java 8 or later installed. Run
java -versionto check your current version.(For business outside Alibaba Cloud Virtual Private Cloud (VPC)) Public network access enabled for the KMS instance. See Access keys in a KMS instance through the public network. This is not required if you only perform management operations through the shared gateway.
(For business inside Alibaba Cloud VPC) Your application able to reach
<YOUR_KMS_INSTANCE_ID>.cryptoservice.kms.aliyuncs.com:Same region and same VPC: the network is interconnected by default.
Same region but different VPCs: associate the VPC with the KMS instance. See Access KMS instances in multiple VPCs in the same region.
Install the SDK
Add the following Maven dependencies to your project's pom.xml. Maven downloads the packages automatically from the Maven repository.
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>kms20160120</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.3.6</version>
</dependency>Use the latest version. For available versions and source code, see kms-20160120.