use of com.amazonaws.ClientConfiguration in project crate by crate.
the class AwsS3ServiceImplTests method launchAWSConfigurationTest.
private void launchAWSConfigurationTest(Settings settings, Protocol expectedProtocol, String expectedProxyHost, int expectedProxyPort, String expectedProxyUsername, String expectedProxyPassword, Integer expectedMaxRetries, boolean expectedUseThrottleRetries, int expectedReadTimeout) {
final S3ClientSettings clientSettings = S3ClientSettings.getClientSettings(settings);
final ClientConfiguration configuration = S3Service.buildConfiguration(clientSettings);
assertThat(configuration.getResponseMetadataCacheSize(), is(0));
assertThat(configuration.getProtocol(), is(expectedProtocol));
assertThat(configuration.getProxyHost(), is(expectedProxyHost));
assertThat(configuration.getProxyPort(), is(expectedProxyPort));
assertThat(configuration.getProxyUsername(), is(expectedProxyUsername));
assertThat(configuration.getProxyPassword(), is(expectedProxyPassword));
assertThat(configuration.getMaxErrorRetry(), is(expectedMaxRetries));
assertThat(configuration.useThrottledRetries(), is(expectedUseThrottleRetries));
assertThat(configuration.getSocketTimeout(), is(expectedReadTimeout));
}
use of com.amazonaws.ClientConfiguration in project zeppelin by apache.
the class S3NotebookRepo method init.
public void init(ZeppelinConfiguration conf) throws IOException {
this.conf = conf;
bucketName = conf.getS3BucketName();
user = conf.getS3User();
rootFolder = user + "/notebook";
useServerSideEncryption = conf.isS3ServerSideEncryption();
if (StringUtils.isNotBlank(conf.getS3CannedAcl())) {
objectCannedAcl = CannedAccessControlList.valueOf(conf.getS3CannedAcl());
}
// always use the default provider chain
AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
CryptoConfiguration cryptoConf = new CryptoConfiguration();
String keyRegion = conf.getS3KMSKeyRegion();
if (StringUtils.isNotBlank(keyRegion)) {
cryptoConf.setAwsKmsRegion(Region.getRegion(Regions.fromName(keyRegion)));
}
ClientConfiguration cliConf = createClientConfiguration();
// see if we should be encrypting data in S3
String kmsKeyID = conf.getS3KMSKeyID();
if (kmsKeyID != null) {
// use the AWS KMS to encrypt data
KMSEncryptionMaterialsProvider emp = new KMSEncryptionMaterialsProvider(kmsKeyID);
this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cliConf, cryptoConf);
} else if (conf.getS3EncryptionMaterialsProviderClass() != null) {
// use a custom encryption materials provider class
EncryptionMaterialsProvider emp = createCustomProvider(conf);
this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cliConf, cryptoConf);
} else {
// regular S3
this.s3client = new AmazonS3Client(credentialsProvider, cliConf);
}
s3client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(conf.isS3PathStyleAccess()).build());
// set S3 endpoint to use
s3client.setEndpoint(conf.getS3Endpoint());
}
use of com.amazonaws.ClientConfiguration in project druid by druid-io.
the class KinesisRecordSupplier method getAmazonKinesisClient.
public static AmazonKinesis getAmazonKinesisClient(String endpoint, AWSCredentialsConfig awsCredentialsConfig, String awsAssumedRoleArn, String awsExternalId) {
AWSCredentialsProvider awsCredentialsProvider = AWSCredentialsUtils.defaultAWSCredentialsProviderChain(awsCredentialsConfig);
if (awsAssumedRoleArn != null) {
log.info("Assuming role [%s] with externalId [%s]", awsAssumedRoleArn, awsExternalId);
STSAssumeRoleSessionCredentialsProvider.Builder builder = new STSAssumeRoleSessionCredentialsProvider.Builder(awsAssumedRoleArn, StringUtils.format("druid-kinesis-%s", UUID.randomUUID().toString())).withStsClient(AWSSecurityTokenServiceClientBuilder.standard().withCredentials(awsCredentialsProvider).build());
if (awsExternalId != null) {
builder.withExternalId(awsExternalId);
}
awsCredentialsProvider = builder.build();
}
return AmazonKinesisClientBuilder.standard().withCredentials(awsCredentialsProvider).withClientConfiguration(new ClientConfiguration()).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, AwsHostNameUtils.parseRegion(endpoint, null))).build();
}
use of com.amazonaws.ClientConfiguration in project aws-xray-sdk-java by aws.
the class TracingHandlerTest method mockHttpClient.
private void mockHttpClient(Object client, String responseContent) {
AmazonHttpClient amazonHttpClient = new AmazonHttpClient(new ClientConfiguration());
ConnectionManagerAwareHttpClient apacheHttpClient = Mockito.mock(ConnectionManagerAwareHttpClient.class);
HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
BasicHttpEntity responseBody = new BasicHttpEntity();
InputStream in = EmptyInputStream.INSTANCE;
if (null != responseContent && !responseContent.isEmpty()) {
in = new ByteArrayInputStream(responseContent.getBytes(StandardCharsets.UTF_8));
}
responseBody.setContent(in);
httpResponse.setEntity(responseBody);
try {
Mockito.doReturn(httpResponse).when(apacheHttpClient).execute(Mockito.any(HttpUriRequest.class), Mockito.any(HttpContext.class));
} catch (IOException e) {
// Ignore
}
Whitebox.setInternalState(amazonHttpClient, "httpClient", apacheHttpClient);
Whitebox.setInternalState(client, "client", amazonHttpClient);
}
use of com.amazonaws.ClientConfiguration in project pipeline-aws-plugin by jenkinsci.
the class ProxyTest method shouldParseProxyLowerCase.
@Test
public void shouldParseProxyLowerCase() throws Exception {
EnvVars vars = new EnvVars();
vars.put(ProxyConfiguration.HTTPS_PROXY_LC, "http://127.0.0.1:8888/");
ClientConfiguration config = new ClientConfiguration();
config.setProtocol(Protocol.HTTPS);
ProxyConfiguration.configure(vars, config);
Assert.assertNull(config.getProxyUsername());
Assert.assertNull(config.getProxyPassword());
Assert.assertEquals("127.0.0.1", config.getProxyHost());
Assert.assertEquals(8888, config.getProxyPort());
}
Aggregations