use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class S3ObjectLambdaOperationEndpointResolver method applyEndpointConfiguration.
@Override
public ConfiguredS3SdkHttpRequest applyEndpointConfiguration(S3EndpointResolverContext context) {
S3Request originalRequest = (S3Request) context.originalRequest();
validateObjectLambdaRequest(originalRequest);
S3Configuration configuration = context.serviceConfiguration();
validateConfiguration(configuration);
SdkHttpRequest updatedRequest = context.request();
if (context.endpointOverride() == null) {
String newHost = getUriForObjectLambdaOperation(context).getHost();
if (!context.isDisableHostPrefixInjection()) {
newHost = applyHostPrefix(newHost, originalRequest);
}
updatedRequest = updatedRequest.toBuilder().host(newHost).build();
}
return ConfiguredS3SdkHttpRequest.builder().sdkHttpRequest(updatedRequest).signingServiceModification(SIGNING_NAME).build();
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class EndpointAddressInterceptor method modifyHttpRequest.
@Override
public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
boolean endpointOverridden = Boolean.TRUE.equals(executionAttributes.getAttribute(SdkExecutionAttribute.ENDPOINT_OVERRIDDEN));
URI endpointOverride = endpointOverridden ? executionAttributes.getAttribute(SdkExecutionAttribute.CLIENT_ENDPOINT) : null;
S3Configuration serviceConfiguration = (S3Configuration) executionAttributes.getAttribute(AwsSignerExecutionAttribute.SERVICE_CONFIG);
boolean disableHostPrefixInjection = isDisableHostPrefixInjection(executionAttributes);
S3EndpointResolverContext resolverContext = S3EndpointResolverContext.builder().request(context.httpRequest()).originalRequest(context.request()).region(executionAttributes.getAttribute(AwsExecutionAttribute.AWS_REGION)).endpointOverride(endpointOverride).serviceConfiguration(serviceConfiguration).fipsEnabled(executionAttributes.getAttribute(AwsExecutionAttribute.FIPS_ENDPOINT_ENABLED)).disableHostPrefixInjection(disableHostPrefixInjection).build();
String bucketName = context.request().getValueForField("Bucket", String.class).orElse(null);
S3EndpointResolverFactoryContext resolverFactoryContext = S3EndpointResolverFactoryContext.builder().bucketName(bucketName).originalRequest((S3Request) context.request()).build();
ConfiguredS3SdkHttpRequest configuredRequest = S3EndpointResolverFactory.getEndpointResolver(resolverFactoryContext).applyEndpointConfiguration(resolverContext);
if (configuredRequest.signingRegionModification().isPresent()) {
executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION, configuredRequest.signingRegionModification().get());
} else {
executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION_SCOPE, RegionScope.GLOBAL);
}
configuredRequest.signingServiceModification().ifPresent(name -> executionAttributes.putAttribute(AwsSignerExecutionAttribute.SERVICE_SIGNING_NAME, name));
return configuredRequest.sdkHttpRequest();
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class EnableChunkedEncodingInterceptorTest method modifyRequest_existingValueInExecutionAttributes_TakesPrecedenceOverClientConfig.
@Test
public void modifyRequest_existingValueInExecutionAttributes_TakesPrecedenceOverClientConfig() {
boolean configValue = false;
S3Configuration config = S3Configuration.builder().chunkedEncodingEnabled(configValue).build();
ExecutionAttributes executionAttributes = new ExecutionAttributes().putAttribute(SERVICE_CONFIG, config).putAttribute(ENABLE_CHUNKED_ENCODING, !configValue);
interceptor.modifyRequest(context(PutObjectRequest.builder().build()), executionAttributes);
assertThat(executionAttributes.getAttribute(ENABLE_CHUNKED_ENCODING)).isEqualTo(!configValue);
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class S3EndpointResolverContextTest method toBuilder_maximal.
@Test
public void toBuilder_maximal() {
S3Configuration serviceConfiguration = S3Configuration.builder().build();
SdkHttpFullRequest httpRequest = SdkHttpFullRequest.builder().protocol("http").host("host").method(SdkHttpMethod.POST).build();
URI endpoint = URI.create("https://endpoint.com");
S3EndpointResolverContext context = S3EndpointResolverContext.builder().endpointOverride(endpoint).originalRequest(PutObjectRequest.builder().build()).region(Region.US_EAST_1).serviceConfiguration(serviceConfiguration).request(httpRequest).build();
assertThat(context.endpointOverride()).isEqualTo(endpoint);
assertThat(context.originalRequest()).isInstanceOf(PutObjectRequest.class);
assertThat(context.region()).isEqualTo(Region.US_EAST_1);
assertThat(context.serviceConfiguration()).isEqualTo(serviceConfiguration);
assertThat(context.request()).isEqualTo(httpRequest);
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project beam by apache.
the class S3FileSystemTest method beforeClass.
@BeforeClass
public static void beforeClass() {
api = new S3Mock.Builder().withInMemoryBackend().withPort(8002).build();
Http.ServerBinding binding = api.start();
URI endpoint = URI.create("http://localhost:" + binding.localAddress().getPort());
S3Configuration s3Configuration = S3Configuration.builder().pathStyleAccessEnabled(true).build();
client = S3Client.builder().region(Region.US_WEST_1).serviceConfiguration(s3Configuration).endpointOverride(endpoint).credentialsProvider(AnonymousCredentialsProvider.create()).build();
}
Aggregations