use of com.amazonaws.services.securitytoken.model.AssumeRoleRequest in project SimianArmy by Netflix.
the class STSAssumeRoleSessionCredentialsProvider method startSession.
/**
* Starts a new session by sending a request to the AWS Security Token
* Service (STS) to assume a Role using the long lived AWS credentials. This
* class then vends the short lived session credentials for the assumed Role
* sent back from STS.
*/
private void startSession() {
AssumeRoleResult assumeRoleResult = securityTokenService.assumeRole(new AssumeRoleRequest().withRoleArn(roleArn).withDurationSeconds(DEFAULT_DURATION_SECONDS).withRoleSessionName("SimianArmy"));
Credentials stsCredentials = assumeRoleResult.getCredentials();
sessionCredentials = new BasicSessionCredentials(stsCredentials.getAccessKeyId(), stsCredentials.getSecretAccessKey(), stsCredentials.getSessionToken());
sessionCredentialsExpiration = stsCredentials.getExpiration();
}
use of com.amazonaws.services.securitytoken.model.AssumeRoleRequest in project athenz by yahoo.
the class ZTSClient method assumeAWSRole.
Credentials assumeAWSRole(String account, String roleName) {
try {
AssumeRoleRequest req = getAssumeRoleRequest(account, roleName);
AWSSecurityTokenServiceClient client = new AWSSecurityTokenServiceClient();
AssumeRoleResult res = client.assumeRole(req);
return res.getCredentials();
} catch (Exception ex) {
LOG.error("assumeAWSRole - unable to assume role: " + ex.getMessage());
return null;
}
}
use of com.amazonaws.services.securitytoken.model.AssumeRoleRequest in project athenz by yahoo.
the class ZTSClientTest method testGetAssumeRoleRequest.
@Test
public void testGetAssumeRoleRequest() {
ZTSClient client = new ZTSClient("http://localhost:4080");
AssumeRoleRequest req = client.getAssumeRoleRequest("1234", "role1");
assertNotNull(req);
assertEquals(req.getRoleArn(), "arn:aws:iam::1234:role/role1");
assertEquals(req.getRoleSessionName(), "role1");
client.close();
}
use of com.amazonaws.services.securitytoken.model.AssumeRoleRequest in project athenz by yahoo.
the class CloudStore method getAssumeRoleRequest.
AssumeRoleRequest getAssumeRoleRequest(String account, String roleName, String principal) {
// assume the target role to get the credentials for the client
// aws format is arn:aws:iam::<account-id>:role/<role-name>
String arn = "arn:aws:iam::" + account + ":role/" + roleName;
AssumeRoleRequest req = new AssumeRoleRequest();
req.setRoleArn(arn);
req.setRoleSessionName(principal);
return req;
}
use of com.amazonaws.services.securitytoken.model.AssumeRoleRequest in project athenz by yahoo.
the class CloudStoreTest method testGetAssumeRoleRequest.
@Test
public void testGetAssumeRoleRequest() {
CloudStore store = new CloudStore(null);
AssumeRoleRequest req = store.getAssumeRoleRequest("1234", "admin", "sys.auth.zts");
assertEquals("arn:aws:iam::1234:role/admin", req.getRoleArn());
assertEquals("sys.auth.zts", req.getRoleSessionName());
store.close();
}
Aggregations