use of com.tencentcloudapi.sts.v20180813.models.GetFederationTokenResponse in project cloud-sdk by mizhousoft.
the class TencentOCRServiceImpl method getTempCredential.
/**
* {@inheritDoc}
*/
@Override
public TempCredential getTempCredential(long durationSecond) throws CloudSDKException {
GetFederationTokenRequest request = new GetFederationTokenRequest();
request.setName("ocr");
request.setDurationSeconds(durationSecond);
request.setPolicy("{\"version\": \"2.0\", \"statement\": [{\"action\": [\"ocr:*\"], \"resource\": \"*\", \"effect\": \"allow\"}]}");
try {
GetFederationTokenResponse response = cosClient.GetFederationToken(request);
Credentials credential = response.getCredentials();
TempCredential tempCredential = new TempCredential();
tempCredential.setSecretId(credential.getTmpSecretId());
tempCredential.setSecretKey(credential.getTmpSecretKey());
tempCredential.setToken(credential.getToken());
tempCredential.setExpiredTime(response.getExpiredTime());
return tempCredential;
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getMessage(), e);
}
}
Aggregations