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);
}
Aggregations