in solution/solution-kms-managed-accesskey/code-example/java/src/main/java/org/example/Main.java [13:38]
public static void main(String[] args) {
// 1. 获取ACSClient by aliyun-java-sdk-managed-credentials-provider
IAcsClient client = null;
try {
// 通过 AKExpireHandler 自定义错误重试判断逻辑,对因凭据手动轮转极端场景下 AK 失效的错误进行重试
client = new ProxyAcsClient("cn-hangzhou", "acs/ram/user/workshop-kms-ram-secret", new AliyunSdkAKExpireHandler());
} catch (ClientException e) {
e.printStackTrace();
}
// 2. 调用OpenAPI实现业务功能
ResourceBundle resource = ResourceBundle.getBundle("application");
String vpcEndpoint = resource.getString("endpoint.vpc");
DescribeVpcsRequest request = new DescribeVpcsRequest();
request.setSysEndpoint(vpcEndpoint);
DescribeVpcsResponse response;
try {
response = client.getAcsResponse(request);
System.out.println(JSON.toJSONString(response));
} catch (ClientException e) {
e.printStackTrace();
}
// 3. 通过下面方法关闭客户端来释放插件关联的资源
client.shutdown();
}