Example usage for com.amazonaws.services.securitytoken AWSSecurityTokenServiceClient AWSSecurityTokenServiceClient

List of usage examples for com.amazonaws.services.securitytoken AWSSecurityTokenServiceClient AWSSecurityTokenServiceClient

Introduction

In this page you can find the example usage for com.amazonaws.services.securitytoken AWSSecurityTokenServiceClient AWSSecurityTokenServiceClient.

Prototype

@Deprecated
public AWSSecurityTokenServiceClient() 

Source Link

Document

Constructs a new client to invoke service methods on AWS STS.

Usage

From source file:com.dtolabs.rundeck.plugin.resources.ec2.EC2ResourceModelSource.java

License:Apache License

private void initialize() {
    final ArrayList<String> params = new ArrayList<String>();
    if (null != filterParams) {
        Collections.addAll(params, filterParams.split(";"));
    }/*from   w w  w  .ja  va  2 s .c  o m*/
    loadMapping();
    if (this.credentials == null && assumeRoleArn != null) {
        AWSSecurityTokenServiceClient sts_client = new AWSSecurityTokenServiceClient();
        //        sts_client.setEndpoint("sts-endpoint.amazonaws.com");
        AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest();
        assumeRoleRequest.setRoleArn(assumeRoleArn);
        assumeRoleRequest.setRoleSessionName("RundeckEC2ResourceModelSourceSession");
        AssumeRoleResult assumeRoleResult = sts_client.assumeRole(assumeRoleRequest);
        Credentials assumeCredentials = assumeRoleResult.getCredentials();
        credentials = new BasicSessionCredentials(assumeCredentials.getAccessKeyId(),
                assumeCredentials.getSecretAccessKey(), assumeCredentials.getSessionToken());
    }

    mapper = new InstanceToNodeMapper(this.credentials, mapping, clientConfiguration);
    mapper.setFilterParams(params);
    mapper.setEndpoint(endpoint);
    mapper.setRunningStateOnly(runningOnly);
}

From source file:com.netflix.simianarmy.aws.STSAssumeRoleSessionCredentialsProvider.java

License:Apache License

/**
 * Constructs a new STSAssumeRoleSessionCredentialsProvider, which makes a
 * request to the AWS Security Token Service (STS), uses the provided
 * {@link #roleArn} to assume a role and then request short lived session
 * credentials, which will then be returned by this class's
 * {@link #getCredentials()} method.//from  w  w w.  j a  v a 2  s .c om
 * @param roleArn
 *            The AWS ARN of the Role to be assumed.
 */
public STSAssumeRoleSessionCredentialsProvider(String roleArn) {
    this.roleArn = roleArn;
    securityTokenService = new AWSSecurityTokenServiceClient();
}

From source file:com.yahoo.athenz.zts.ZTSClient.java

License:Apache License

Credentials assumeAWSRole(String account, String roleName) {

    try {//from   w w w.j a  v  a  2 s. co  m
        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;
    }
}