Example usage for com.amazonaws.auth AWSStaticCredentialsProvider AWSStaticCredentialsProvider

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

Introduction

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

Prototype

public AWSStaticCredentialsProvider(AWSCredentials credentials) 

Source Link

Usage

From source file:org.pentaho.amazon.client.impl.S3ClientFactory.java

License:Apache License

@Override
public S3Client createClient(String accessKey, String secretKey, String region) {
    AmazonClientCredentials clientCredentials = new AmazonClientCredentials(accessKey, secretKey, region);

    AmazonS3 awsS3Client = AmazonS3ClientBuilder.standard().withRegion(clientCredentials.getRegion())
            .withCredentials(new AWSStaticCredentialsProvider(clientCredentials.getAWSCredentials())).build();

    S3Client s3Client = new S3ClientImpl(awsS3Client);

    return s3Client;
}

From source file:org.pentaho.di.trans.steps.s3csvinput.S3CsvInputMeta.java

License:Apache License

public AmazonS3 getS3Client(VariableSpace space) throws SdkClientException {
    if (!getUseAwsDefaultCredentials()) {
        // Handle legacy credentials ( embedded in the step ).  We'll force a region since it not specified and
        // then turn on GlobalBucketAccess so if the files accessed are elsewhere it won't matter.
        BasicAWSCredentials credentials = new BasicAWSCredentials(
                Encr.decryptPasswordOptionallyEncrypted(space.environmentSubstitute(awsAccessKey)),
                Encr.decryptPasswordOptionallyEncrypted(space.environmentSubstitute(awsSecretKey)));

        return AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials))
                .withRegion(Regions.US_EAST_1).enableForceGlobalBucketAccess().build();
    } else {/*ww w.  java 2  s  . c o m*/
        // Get Credentials the new way
        return AmazonS3ClientBuilder.standard().enableForceGlobalBucketAccess().build();
    }
}

From source file:org.restcomm.connect.commons.amazonS3.S3AccessTool.java

License:Open Source License

public AmazonS3 getS3client() {
    BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, securityKey);

    if (testing && (!testingUrl.isEmpty() || !testingUrl.equals(""))) {
        s3client = new AmazonS3Client(awsCreds);
        s3client.setRegion(Region.getRegion(Regions.fromName(bucketRegion)));
        s3client.setEndpoint(testingUrl);
    } else {/*  w w w.  ja  va 2 s  . com*/
        s3client = AmazonS3ClientBuilder.standard().withRegion(Regions.fromName(bucketRegion))
                .withCredentials(new AWSStaticCredentialsProvider(awsCreds)).build();
    }

    return s3client;
}

From source file:org.restcomm.connect.tts.awspolly.AWSPollySpeechSyntetizer.java

License:Open Source License

public AWSPollySpeechSyntetizer(final Configuration configuration) {
    super();/*from   w w w. j  a  va 2  s .  c o  m*/
    // retrieve polly api credentials
    final String awsAccessKey = configuration.getString("aws-access-key");
    final String awsSecretKey = configuration.getString("aws-secret-key");
    final String awsRegion = configuration.getString("aws-region");

    // Initialize the Amazon Cognito credentials provider.
    AWSCredentials credentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
    // Default region
    String region = "eu-west-1";

    //AWS Specific Region
    if ((awsRegion != null) && (!"".equals(awsRegion))) {
        region = awsRegion;
    }

    // Create a client that supports generation of presigned URLs.
    this.pollyClient = (AmazonPollyClient) AmazonPollyClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(region).build();
    //initialize voices list
    men = new HashMap<>();
    women = new HashMap<>();

    load(configuration);
}

From source file:org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource.java

License:Apache License

@Bean
public AmazonDynamoDB amazonDynamoDB() {
    Assert.notNull(PORT, "System property '" + DYNAMODB_PORT_PROPERTY + " not set!");

    AmazonDynamoDBClientBuilder builder = AmazonDynamoDBClientBuilder.standard();
    builder.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("AWS-Key", "")));
    builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
            String.format("http://localhost:%s", PORT), "us-east-1"));

    return builder.build();
}

From source file:org.springframework.cloud.stream.binder.kinesis.LocalDynamoDbResource.java

License:Apache License

@Override
protected void obtainResource() {
    String url = "http://localhost:" + this.port;

    this.resource = AmazonDynamoDBAsyncClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
            .withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
            .withEndpointConfiguration(//from w ww .jav  a 2s .co m
                    new AwsClientBuilder.EndpointConfiguration(url, Regions.DEFAULT_REGION.getName()))
            .build();

    this.resource.listTables();
}

From source file:org.springframework.cloud.stream.binder.kinesis.LocalKinesisResource.java

License:Apache License

@Override
protected void obtainResource() {
    // See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
    System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");

    this.resource = AmazonKinesisAsyncClientBuilder.standard()
            .withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
                    "http://localhost:" + this.port, Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", ""))).build();

    // Check connection
    this.resource.listStreams();
}

From source file:org.springframework.integration.aws.DynamoDbRunning.java

License:Apache License

@Override
public Statement apply(Statement base, Description description) {
    assumeTrue(dynamoDbOnline.get(this.port));

    String url = "http://localhost:" + this.port;

    this.amazonDynamoDB = AmazonDynamoDBAsyncClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
            .withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
            .withEndpointConfiguration(/*w  ww. j a  v  a2 s  .  c o m*/
                    new AwsClientBuilder.EndpointConfiguration(url, Regions.DEFAULT_REGION.getName()))
            .build();

    try {
        this.amazonDynamoDB.listTables();
    } catch (SdkClientException e) {
        logger.warn("Tests not running because no DynamoDb on " + url, e);
        assumeNoException(e);
    }
    return super.apply(base, description);
}

From source file:org.symphonyoss.vb.util.AwsS3Client.java

License:Apache License

public AwsS3Client() {

    AWSCredentials credentials = new BasicAWSCredentials(System.getProperty(BotConfig.S3_KEY_ID),
            System.getProperty(BotConfig.S3_ACCESS_KEY));
    s3Client = AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1)
            .withCredentials(new AWSStaticCredentialsProvider(credentials)).build();

}

From source file:org.thingsboard.rule.engine.aws.sns.TbSnsNode.java

License:Apache License

@Override
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
    this.config = TbNodeUtils.convert(configuration, TbSnsNodeConfiguration.class);
    AWSCredentials awsCredentials = new BasicAWSCredentials(this.config.getAccessKeyId(),
            this.config.getSecretAccessKey());
    AWSStaticCredentialsProvider credProvider = new AWSStaticCredentialsProvider(awsCredentials);
    try {/*  www.j a v a  2s.c  o m*/
        this.snsClient = AmazonSNSClient.builder().withCredentials(credProvider)
                .withRegion(this.config.getRegion()).build();
    } catch (Exception e) {
        throw new TbNodeException(e);
    }
}