Search in sources :

Example 1 with ListPublicKeysResponse

use of com.aliyuncs.ram.model.v20150501.ListPublicKeysResponse in project aliyun-oss-java-sdk by aliyun.

the class AuthUtils method listPublicKeys.

/**
 * List the public keys that has been uploaded.
 *
 * @param regionId
 *            RAM's available area.
 * @param accessKeyId
 *            Access Key ID of the root user.
 * @param accessKeySecret
 *            Secret Access Key of the root user.
 * @return Public keys.
 * @throws ClientException
 */
public static List<PublicKey> listPublicKeys(String regionId, String accessKeyId, String accessKeySecret) throws ClientException {
    DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
    DefaultAcsClient client = new DefaultAcsClient(profile);
    ListPublicKeysRequest listPublicKeysRequest = new ListPublicKeysRequest();
    ListPublicKeysResponse listPublicKeysResponse = client.getAcsResponse(listPublicKeysRequest);
    List<PublicKey> publicKeys = new ArrayList<PublicKey>();
    for (com.aliyuncs.ram.model.v20150501.ListPublicKeysResponse.PublicKey publicKey : listPublicKeysResponse.getPublicKeys()) {
        publicKeys.add(new PublicKey(publicKey));
    }
    return publicKeys;
}
Also used : DefaultProfile(com.aliyuncs.profile.DefaultProfile) DefaultAcsClient(com.aliyuncs.DefaultAcsClient) PublicKey(com.aliyun.oss.common.auth.PublicKey) ArrayList(java.util.ArrayList) ListPublicKeysRequest(com.aliyuncs.ram.model.v20150501.ListPublicKeysRequest) ListPublicKeysResponse(com.aliyuncs.ram.model.v20150501.ListPublicKeysResponse)

Aggregations

PublicKey (com.aliyun.oss.common.auth.PublicKey)1 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)1 DefaultProfile (com.aliyuncs.profile.DefaultProfile)1 ListPublicKeysRequest (com.aliyuncs.ram.model.v20150501.ListPublicKeysRequest)1 ListPublicKeysResponse (com.aliyuncs.ram.model.v20150501.ListPublicKeysResponse)1 ArrayList (java.util.ArrayList)1