Example usage for com.amazonaws.auth DefaultAWSCredentialsProviderChain DefaultAWSCredentialsProviderChain

List of usage examples for com.amazonaws.auth DefaultAWSCredentialsProviderChain DefaultAWSCredentialsProviderChain

Introduction

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

Prototype

public DefaultAWSCredentialsProviderChain() 

Source Link

Usage

From source file:ws.salient.aws.Application.java

License:Apache License

public void run() {
    try {/*from  w  w  w .j  a  v a  2 s.  c  o m*/
        String applicationName = "Salient";
        AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
        String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID();
        KinesisClientLibConfiguration config = new KinesisClientLibConfiguration(applicationName, "salient",
                credentialsProvider, workerId).withMetricsLevel(MetricsLevel.NONE)
                        .withInitialPositionInStream(InitialPositionInStream.LATEST)
                        .withIdleTimeBetweenReadsInMillis(200);
        Worker worker = new Worker.Builder().recordProcessorFactory(() -> {
            return new RecordProcessor();
        }).config(config).build();
        worker.run();
    } catch (UnknownHostException ex) {
        throw new RuntimeException(ex);
    }
    unpackRepository("/maven.zip");
}

From source file:zipkin.autoconfigure.collector.kinesis.ZipkinKinesisCredentialsAutoConfiguration.java

License:Apache License

private static AWSCredentialsProvider getDefaultCredentialsProvider(
        ZipkinKinesisCollectorProperties properties) {
    AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain();

    // Create credentials provider from ID and secret if given.
    if (!isNullOrEmpty(properties.awsAccessKeyId) && !isNullOrEmpty(properties.awsSecretAccessKey)) {
        provider = new AWSStaticCredentialsProvider(
                new BasicAWSCredentials(properties.awsAccessKeyId, properties.awsSecretAccessKey));
    }/*from w ww .j  ava 2 s .  c o m*/

    return provider;
}

From source file:zipkin.autoconfigure.collector.sqs.ZipkinSQSCredentialsAutoConfiguration.java

License:Apache License

private static AWSCredentialsProvider getDefaultCredentialsProvider(ZipkinSQSCollectorProperties properties) {
    AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain();

    // Create credentials provider from ID and secret if given.
    if (!isNullOrEmpty(properties.awsAccessKeyId) && !isNullOrEmpty(properties.awsSecretAccessKey)) {
        provider = new AWSStaticCredentialsProvider(
                new BasicAWSCredentials(properties.awsAccessKeyId, properties.awsSecretAccessKey));
    }/*from ww w . j  a  v a 2  s .co  m*/

    return provider;
}

From source file:zipkin.autoconfigure.storage.elasticsearch.aws.ZipkinElasticsearchAwsStorageAutoConfiguration.java

License:Apache License

/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain} */
@Bean/*from  w  ww.j a  v a  2  s.  com*/
@ConditionalOnMissingBean
AWSCredentials.Provider credentials() {
    return new AWSCredentials.Provider() {
        AWSCredentialsProvider delegate = new DefaultAWSCredentialsProviderChain();

        @Override
        public AWSCredentials get() {
            com.amazonaws.auth.AWSCredentials result = delegate.getCredentials();
            String sessionToken = result instanceof AWSSessionCredentials
                    ? ((AWSSessionCredentials) result).getSessionToken()
                    : null;
            return new AWSCredentials(result.getAWSAccessKeyId(), result.getAWSSecretKey(), sessionToken);
        }
    };
}

From source file:zipkin.autoconfigure.storage.elasticsearch.aws.ZipkinElasticsearchAwsStorageProperties.java

License:Apache License

ElasticsearchStorage.Builder toBuilder() {
    if (!hostsIsDefaultOrEmpty() && aws.domain != null) {
        logger.warn("Expected exactly one of hosts or domain: instead saw hosts '{}' and domain '{}'."
                + " Ignoring hosts and proceeding to look for domain. Either unset ES_HOSTS or "
                + "ES_AWS_DOMAIN to suppress this message.", hosts, aws.domain);
    }/*from   www  .jav a 2  s. co  m*/

    String region;
    if (aws.domain != null) {
        region = aws.region;
        if (region == null)
            region = new DefaultAwsRegionProviderChain().getRegion();
    } else {
        region = ZipkinElasticsearchHttpStorageAutoConfiguration.regionFromAwsUrls(hosts).get();
    }
    ElasticsearchAwsRequestSigner signer = new ElasticsearchAwsRequestSigner(region,
            new DefaultAWSCredentialsProviderChain());
    HttpClient.Builder httpBuilder = new HttpClient.Builder().addPostInterceptor(signer);

    if (aws.domain != null) {
        httpBuilder.hosts(new ElasticsearchDomainEndpoint(aws.domain, region));
    } else {
        httpBuilder.hosts(this.hosts);
    }

    return ElasticsearchStorage.builder(httpBuilder).index(index).indexShards(indexShards)
            .indexReplicas(indexReplicas);
}

From source file:zipkin.reporter.kinesis.KinesisSender.java

License:Apache License

public static Builder builder() {
    return new AutoValue_KinesisSender.Builder().credentialsProvider(new DefaultAWSCredentialsProviderChain())
            .encoding(Encoding.JSON).messageMaxBytes(1024 * 1024); // 1MB Kinesis limit.
}

From source file:zipkin.reporter.sqs.SQSSender.java

License:Apache License

public static Builder builder() {
    return new AutoValue_SQSSender.Builder().credentialsProvider(new DefaultAWSCredentialsProviderChain())
            .encoding(Encoding.JSON).messageMaxBytes(256 * 1024); // 256KB SQS limit.
}