Example usage for com.amazonaws.auth STSAssumeRoleSessionCredentialsProvider getCredentials

List of usage examples for com.amazonaws.auth STSAssumeRoleSessionCredentialsProvider getCredentials

Introduction

In this page you can find the example usage for com.amazonaws.auth STSAssumeRoleSessionCredentialsProvider getCredentials.

Prototype

@Override
    public AWSSessionCredentials getCredentials() 

Source Link

Usage

From source file:org.jenkinsci.plugins.awsdevicefarm.AWSDeviceFarm.java

License:Open Source License

/**
 * Private AWSDeviceFarm constructor. Uses the roleArn to generate STS creds if the roleArn isn't null; otherwise
 * just uses the AWSCredentials creds.//from   w ww.j ava 2  s  .  com
 *
 * @param creds   AWSCredentials creds to use for authentication.
 * @param roleArn Role ARN to use for authentication.
 */
private AWSDeviceFarm(AWSCredentials creds, String roleArn) {
    if (roleArn != null) {
        STSAssumeRoleSessionCredentialsProvider sts = new STSAssumeRoleSessionCredentialsProvider.Builder(
                roleArn, RandomStringUtils.randomAlphanumeric(8)).build();
        creds = sts.getCredentials();
    }

    ClientConfiguration clientConfiguration = new ClientConfiguration()
            .withUserAgent("AWS Device Farm - Jenkins v1.0");
    api = new AWSDeviceFarmClient(creds, clientConfiguration);
    api.setServiceNameIntern("devicefarm");
}