Search in sources :

Example 1 with UploadPublicKeyRequest

use of com.aliyuncs.ram.model.v20150501.UploadPublicKeyRequest 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);
}
Also used : DefaultProfile(com.aliyuncs.profile.DefaultProfile) DefaultAcsClient(com.aliyuncs.DefaultAcsClient) PublicKey(com.aliyun.oss.common.auth.PublicKey) UploadPublicKeyRequest(com.aliyuncs.ram.model.v20150501.UploadPublicKeyRequest) UploadPublicKeyResponse(com.aliyuncs.ram.model.v20150501.UploadPublicKeyResponse)

Aggregations

PublicKey (com.aliyun.oss.common.auth.PublicKey)1 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)1 DefaultProfile (com.aliyuncs.profile.DefaultProfile)1 UploadPublicKeyRequest (com.aliyuncs.ram.model.v20150501.UploadPublicKeyRequest)1 UploadPublicKeyResponse (com.aliyuncs.ram.model.v20150501.UploadPublicKeyResponse)1