AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest()
.withDurationSeconds(durationInSeconds)
.withExternalId(externalId)
.withRoleArn(awsCredential.getRoleArn())
.withRoleSessionName("hadoop-provisioning");
AssumeRoleResult result = client.assumeRole(assumeRoleRequest);
cacheSessionCredentials(result, durationInSeconds, awsCredential);
return new BasicSessionCredentials(
result.getCredentials().getAccessKeyId(),
result.getCredentials().getSecretAccessKey(),
result.getCredentials().getSessionToken());
}