Search in sources :

Example 1 with GetSessionAccessKeyRequest

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

the class STSKeyPairSessionCredentialsProvider method getNewSessionCredentials.

private BasicCredentials getNewSessionCredentials() {
    GetSessionAccessKeyRequest request = new GetSessionAccessKeyRequest();
    request.setPublicKeyId(keyPairCredentials.getAccessKeyId());
    request.setDurationSeconds((int) expiredDurationSeconds);
    request.setProtocol(ProtocolType.HTTPS);
    GetSessionAccessKeyResponse response = null;
    try {
        response = this.ramClient.getAcsResponse(request);
    } catch (ClientException e) {
        LogUtils.logException("RamClient.getAcsResponse Exception:", e);
        return null;
    }
    return new BasicCredentials(response.getSessionAccesskey().getSessionAccessKeyId(), response.getSessionAccesskey().getSessionAccessKeySecert(), null, expiredDurationSeconds).withExpiredFactor(expiredFactor);
}
Also used : GetSessionAccessKeyRequest(com.aliyuncs.auth.sts.GetSessionAccessKeyRequest) GetSessionAccessKeyResponse(com.aliyuncs.auth.sts.GetSessionAccessKeyResponse) ClientException(com.aliyuncs.exceptions.ClientException)

Aggregations

GetSessionAccessKeyRequest (com.aliyuncs.auth.sts.GetSessionAccessKeyRequest)1 GetSessionAccessKeyResponse (com.aliyuncs.auth.sts.GetSessionAccessKeyResponse)1 ClientException (com.aliyuncs.exceptions.ClientException)1