All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.dkms.gcs.sdk.samples.governance.DescribeKey Maven / Gradle / Ivy

Go to download

Dedicated Key Management Service SDK for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com

The newest version!
package com.aliyun.dkms.gcs.sdk.samples.governance;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.kms.model.v20160120.*;
import com.aliyuncs.profile.DefaultProfile;

public class DescribeKey {

    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "", "");
        /** use STS Token
         DefaultProfile profile = DefaultProfile.getProfile(
         "",           // The region ID
         "",       // The AccessKey ID of the RAM account
         "",   // The AccessKey Secret of the RAM account
         "");          // STS Token
         **/
        IAcsClient client = new DefaultAcsClient(profile);

        DescribeKeyRequest request = new DescribeKeyRequest();
        request.setKeyId("");
        try {
            DescribeKeyResponse response = client.getAcsResponse(request);
            final DescribeKeyResponse.KeyMetadata keyMetadata = response.getKeyMetadata();
            System.out.printf("KeyId: %s%n", keyMetadata.getKeyId());
            System.out.printf("Description: %s%n", keyMetadata.getDescription());
            System.out.printf("KeyState: %s%n", keyMetadata.getKeyState());
            System.out.printf("CreationDate: %s%n", keyMetadata.getCreationDate());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy