use of com.amazonaws.auth.AWSCredentials in project druid by druid-io.
the class TestAWSCredentialsProvider method testWithFixedAWSKeys.
@Test
public void testWithFixedAWSKeys() {
AWSCredentialsConfig config = EasyMock.createMock(AWSCredentialsConfig.class);
EasyMock.expect(config.getAccessKey()).andReturn(new DefaultPasswordProvider("accessKeySample")).atLeastOnce();
EasyMock.expect(config.getSecretKey()).andReturn(new DefaultPasswordProvider("secretKeySample")).atLeastOnce();
EasyMock.replay(config);
AWSCredentialsProvider provider = awsModule.getAWSCredentialsProvider(config);
AWSCredentials credentials = provider.getCredentials();
Assert.assertEquals("accessKeySample", credentials.getAWSAccessKeyId());
Assert.assertEquals("secretKeySample", credentials.getAWSSecretKey());
// try to create
ServerSideEncryptingAmazonS3.Builder amazonS3ClientBuilder = s3Module.getServerSideEncryptingAmazonS3Builder(provider, new AWSProxyConfig(), new AWSEndpointConfig(), new AWSClientConfig(), new S3StorageConfig(new NoopServerSideEncryption()));
s3Module.getAmazonS3Client(amazonS3ClientBuilder);
}
use of com.amazonaws.auth.AWSCredentials in project beam by apache.
the class KinesisIOIT method createKinesisClient.
private static AmazonKinesis createKinesisClient() {
AWSCredentials credentials = new BasicAWSCredentials(options.getAwsAccessKey(), options.getAwsSecretKey());
AmazonKinesisClientBuilder clientBuilder = AmazonKinesisClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials));
if (options.getAwsServiceEndpoint() != null) {
clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(options.getAwsServiceEndpoint(), options.getAwsKinesisRegion()));
} else {
clientBuilder.setRegion(options.getAwsKinesisRegion());
}
return clientBuilder.build();
}
use of com.amazonaws.auth.AWSCredentials in project jackrabbit by apache.
the class Utils method openService.
/**
* Create AmazonS3Client from properties.
*
* @param prop properties to configure @link {@link AmazonS3Client}
* @return {@link AmazonS3Client}
*/
public static AmazonS3Client openService(final Properties prop) {
String accessKey = prop.getProperty(S3Constants.ACCESS_KEY);
String secretKey = prop.getProperty(S3Constants.SECRET_KEY);
AmazonS3Client s3service = null;
if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey)) {
LOG.info("Configuring Amazon Client from environment");
s3service = new AmazonS3Client(getClientConfiguration(prop));
} else {
LOG.info("Configuring Amazon Client from property file.");
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
s3service = new AmazonS3Client(credentials, getClientConfiguration(prop));
}
String region = prop.getProperty(S3Constants.S3_REGION);
String endpoint = null;
String propEndPoint = prop.getProperty(S3Constants.S3_END_POINT);
if ((propEndPoint != null) && !"".equals(propEndPoint)) {
endpoint = propEndPoint;
} else {
if (StringUtils.isNullOrEmpty(region)) {
com.amazonaws.regions.Region s3Region = Regions.getCurrentRegion();
if (s3Region != null) {
region = s3Region.getName();
} else {
throw new AmazonClientException("parameter [" + S3Constants.S3_REGION + "] not configured and cannot be derived from environment");
}
}
if (DEFAULT_AWS_BUCKET_REGION.equals(region)) {
endpoint = S3 + DOT + AWSDOTCOM;
} else if (Region.EU_Ireland.toString().equals(region)) {
endpoint = "s3-eu-west-1" + DOT + AWSDOTCOM;
} else {
endpoint = S3 + DASH + region + DOT + AWSDOTCOM;
}
}
/*
* setting endpoint to remove latency of redirection. If endpoint is
* not set, invocation first goes us standard region, which
* redirects it to correct location.
*/
s3service.setEndpoint(endpoint);
LOG.info("S3 service endpoint [{}] ", endpoint);
s3service.setS3ClientOptions(getS3ClientOptions(prop));
return s3service;
}
use of com.amazonaws.auth.AWSCredentials in project ignite-extensions by apache.
the class S3CheckpointManagerSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
assertTrue("Unexpected Ignite instance name: " + igniteInstanceName, igniteInstanceName.contains("s3"));
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
S3CheckpointSpi spi = new S3CheckpointSpi();
AWSCredentials cred = new BasicAWSCredentials(IgniteS3TestSuite.getAccessKey(), IgniteS3TestSuite.getSecretKey());
spi.setAwsCredentials(cred);
spi.setBucketNameSuffix(S3CheckpointSpiSelfTest.getBucketNameSuffix());
cfg.setCheckpointSpi(spi);
return cfg;
}
use of com.amazonaws.auth.AWSCredentials in project ignite-extensions by apache.
the class S3CheckpointSpiSelfTest method spiConfigure.
/**
* {@inheritDoc}
*/
@Override
protected void spiConfigure(S3CheckpointSpi spi) throws Exception {
AWSCredentials cred = new BasicAWSCredentials(IgniteS3TestSuite.getAccessKey(), IgniteS3TestSuite.getSecretKey());
spi.setAwsCredentials(cred);
spi.setBucketNameSuffix(getBucketNameSuffix());
super.spiConfigure(spi);
}
Aggregations