Search in sources :

Example 6 with ClientConfigurationFactory

use of com.amazonaws.ClientConfigurationFactory in project georocket by georocket.

the class S3Store method getS3Client.

/**
 * Get or initialize the S3 client.
 * Note: this method must be synchronized because we're accessing the
 * {@link #s3Client} field and we're calling this method from a worker thread.
 * @return the S3 client
 */
private synchronized AmazonS3 getS3Client() {
    if (s3Client == null) {
        BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
        AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials));
        if (forceSignatureV2) {
            ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
            ClientConfiguration config = configFactory.getConfig();
            config.setSignerOverride("S3SignerType");
            builder = builder.withClientConfiguration(config);
        }
        String endpoint = "http://" + host + ":" + port;
        String clientRegion = null;
        if (!ServiceUtils.isS3USStandardEndpoint(endpoint)) {
            clientRegion = AwsHostNameUtils.parseRegion(host, AmazonS3Client.S3_SERVICE_NAME);
        }
        builder = builder.withEndpointConfiguration(new EndpointConfiguration(endpoint, clientRegion));
        builder = builder.withPathStyleAccessEnabled(pathStyleAccess);
        s3Client = builder.build();
    }
    return s3Client;
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AmazonS3ClientBuilder(com.amazonaws.services.s3.AmazonS3ClientBuilder) ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 7 with ClientConfigurationFactory

use of com.amazonaws.ClientConfigurationFactory in project zeppelin by apache.

the class S3NotebookRepo method createClientConfiguration.

/**
 * Create AWS client configuration and return it.
 * @return AWS client configuration
 */
private ClientConfiguration createClientConfiguration() {
    ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
    ClientConfiguration config = configFactory.getConfig();
    String s3SignerOverride = conf.getS3SignerOverride();
    if (StringUtils.isNotBlank(s3SignerOverride)) {
        config.setSignerOverride(s3SignerOverride);
    }
    return config;
}
Also used : ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) ClientConfiguration(com.amazonaws.ClientConfiguration)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)7 ClientConfigurationFactory (com.amazonaws.ClientConfigurationFactory)7 EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)2 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)2 Protocol (com.amazonaws.Protocol)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonDynamoDBStreamsAdapterClient (com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient)1 AmazonKinesis (com.amazonaws.services.kinesis.AmazonKinesis)1 AmazonKinesisClient (com.amazonaws.services.kinesis.AmazonKinesisClient)1 Provides (com.google.inject.Provides)1 Properties (java.util.Properties)1 Test (org.junit.Test)1