Search in sources :

Example 1 with AssumeRoleRequest

use of com.aliyuncs.auth.sts.AssumeRoleRequest in project aliyun-oss-java-sdk by aliyun.

the class STSAssumeRoleSessionCredentialsProvider method getNewSessionCredentials.

private BasicCredentials getNewSessionCredentials() {
    AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest();
    assumeRoleRequest.setRoleArn(roleArn);
    assumeRoleRequest.setRoleSessionName(roleSessionName);
    assumeRoleRequest.setDurationSeconds(expiredDurationSeconds);
    AssumeRoleResponse response = null;
    try {
        response = ramClient.getAcsResponse(assumeRoleRequest);
    } catch (ClientException e) {
        LogUtils.logException("RamClient.getAcsResponse Exception:", e);
        return null;
    }
    return new BasicCredentials(response.getCredentials().getAccessKeyId(), response.getCredentials().getAccessKeySecret(), response.getCredentials().getSecurityToken(), expiredDurationSeconds).withExpiredFactor(expiredFactor);
}
Also used : AssumeRoleRequest(com.aliyuncs.auth.sts.AssumeRoleRequest) AssumeRoleResponse(com.aliyuncs.auth.sts.AssumeRoleResponse) ClientException(com.aliyuncs.exceptions.ClientException)

Aggregations

AssumeRoleRequest (com.aliyuncs.auth.sts.AssumeRoleRequest)1 AssumeRoleResponse (com.aliyuncs.auth.sts.AssumeRoleResponse)1 ClientException (com.aliyuncs.exceptions.ClientException)1