Search in sources :

Example 6 with DefaultProfile

use of com.aliyuncs.profile.DefaultProfile in project aliyun-oss-java-sdk by aliyun.

the class CredentialsProviderFactory method newSTSAssumeRoleSessionCredentialsProvider.

/**
 * Create a new STSAssumeRoleSessionCredentialsProvider, which makes a
 * request to the Aliyun Security Token Service (STS), uses the provided
 * {@link #roleArn} to assume a role and then request short lived session
 * credentials, which will then be returned by this class's
 * {@link #getCredentials()} method.
 *
 * @param regionId
 *            RAM's available area, for more information about regionId, see
 *            <a href="https://help.aliyun.com/document_detail/40654.html">
 *            RegionIdList</a>.
 * @param accessKeyId
 *            Access Key ID of the child user.
 * @param accessKeySecret
 *            Secret Access Key of the child user.
 * @param roleArn
 *            The ARN of the Role to be assumed.
 * @return A {@link StsAssumeRoleCredentialsProvider} instance.
 * @throws ClientException
 *             OSS Client side exception.
 */
public static STSAssumeRoleSessionCredentialsProvider newSTSAssumeRoleSessionCredentialsProvider(String regionId, String accessKeyId, String accessKeySecret, String roleArn) throws ClientException {
    DefaultProfile profile = DefaultProfile.getProfile(regionId);
    com.aliyuncs.auth.BasicCredentials basicCredentials = new com.aliyuncs.auth.BasicCredentials(accessKeyId, accessKeySecret);
    return new STSAssumeRoleSessionCredentialsProvider(basicCredentials, roleArn, profile);
}
Also used : DefaultProfile(com.aliyuncs.profile.DefaultProfile)

Aggregations

DefaultProfile (com.aliyuncs.profile.DefaultProfile)6 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)4 PublicKey (com.aliyun.oss.common.auth.PublicKey)2 IAcsClient (com.aliyuncs.IAcsClient)1 KeyPairCredentials (com.aliyuncs.auth.KeyPairCredentials)1 ClientException (com.aliyuncs.fc.exceptions.ClientException)1 OpenFunctionComputeResponse (com.aliyuncs.fc.response.OpenFunctionComputeResponse)1 OpenFcServiceRequest (com.aliyuncs.fc_open.model.v20200310.OpenFcServiceRequest)1 OpenFcServiceResponse (com.aliyuncs.fc_open.model.v20200310.OpenFcServiceResponse)1 DeletePublicKeyRequest (com.aliyuncs.ram.model.v20150501.DeletePublicKeyRequest)1 ListPublicKeysRequest (com.aliyuncs.ram.model.v20150501.ListPublicKeysRequest)1 ListPublicKeysResponse (com.aliyuncs.ram.model.v20150501.ListPublicKeysResponse)1 UploadPublicKeyRequest (com.aliyuncs.ram.model.v20150501.UploadPublicKeyRequest)1 UploadPublicKeyResponse (com.aliyuncs.ram.model.v20150501.UploadPublicKeyResponse)1 ArrayList (java.util.ArrayList)1