use of com.aliyuncs.ram.model.v20150501.UploadPublicKeyResponse in project aliyun-oss-java-sdk by aliyun.
the class AuthUtils method uploadPublicKey.
/**
* Upload the public key of RSA key pair.
*
* @param regionId
* RAM's available area.
* @param accessKeyId
* Access Key ID of the root user.
* @param accessKeySecret
* Secret Access Key of the root user.
* @param publicKey
* Public key content.
* @return Public key description, include public key id etc.
* @throws ClientException
*/
public static PublicKey uploadPublicKey(String regionId, String accessKeyId, String accessKeySecret, String publicKey) throws ClientException {
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
UploadPublicKeyRequest uploadPublicKeyRequest = new UploadPublicKeyRequest();
uploadPublicKeyRequest.setPublicKeySpec(publicKey);
UploadPublicKeyResponse uploadPublicKeyResponse = client.getAcsResponse(uploadPublicKeyRequest);
com.aliyuncs.ram.model.v20150501.UploadPublicKeyResponse.PublicKey pubKey = uploadPublicKeyResponse.getPublicKey();
return new PublicKey(pubKey);
}
Aggregations