use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class EnableChunkedEncodingInterceptorTest method modifyRequest_valueOnServiceConfig_TakesPrecedenceOverDefaultEnabled.
@Test
public void modifyRequest_valueOnServiceConfig_TakesPrecedenceOverDefaultEnabled() {
S3Configuration config = S3Configuration.builder().chunkedEncodingEnabled(false).build();
ExecutionAttributes executionAttributes = new ExecutionAttributes().putAttribute(SERVICE_CONFIG, config);
interceptor.modifyRequest(context(PutObjectRequest.builder().build()), executionAttributes);
assertThat(executionAttributes.getAttribute(ENABLE_CHUNKED_ENCODING)).isEqualTo(false);
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class EnableChunkedEncodingInterceptor method modifyRequest.
@Override
public SdkRequest modifyRequest(Context.ModifyRequest context, ExecutionAttributes executionAttributes) {
SdkRequest sdkRequest = context.request();
if (sdkRequest instanceof PutObjectRequest || sdkRequest instanceof UploadPartRequest) {
S3Configuration serviceConfiguration = (S3Configuration) executionAttributes.getAttribute(AwsSignerExecutionAttribute.SERVICE_CONFIG);
boolean enableChunkedEncoding;
if (serviceConfiguration != null) {
enableChunkedEncoding = serviceConfiguration.chunkedEncodingEnabled();
} else {
enableChunkedEncoding = true;
}
executionAttributes.putAttributeIfAbsent(S3SignerExecutionAttribute.ENABLE_CHUNKED_ENCODING, enableChunkedEncoding);
}
return sdkRequest;
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class S3AccessPointEndpointResolver method validateConfiguration.
private void validateConfiguration(S3EndpointResolverContext context, S3AccessPointResource s3Resource) {
S3Configuration serviceConfig = context.serviceConfiguration();
Validate.isFalse(isAccelerateEnabled(serviceConfig), S3_CONFIG_ERROR_MESSAGE, "accelerate mode enabled.");
Validate.isFalse(isPathStyleAccessEnabled(serviceConfig), S3_CONFIG_ERROR_MESSAGE, "path style addressing enabled.");
Validate.isTrue(s3Resource.accountId().isPresent(), "An S3 access point ARN must have an account ID");
Region clientRegion = context.region();
if (s3Resource.region().isPresent()) {
validateRegion(s3Resource, serviceConfig, clientRegion, context.fipsEnabled());
} else {
validateGlobalConfiguration(serviceConfig, clientRegion);
}
validatePartition(s3Resource, clientRegion);
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.
the class S3BucketEndpointResolver method resolveEndpoint.
/**
* Determine which endpoint to use based on region and {@link S3Configuration}. Will either be a traditional
* S3 endpoint (i.e. s3.us-east-1.amazonaws.com), the global S3 accelerate endpoint (i.e. s3-accelerate.amazonaws.com) or
* a regional dualstack endpoint for IPV6 (i.e. s3.dualstack.us-east-1.amazonaws.com).
*/
private static URI resolveEndpoint(S3EndpointResolverContext context) {
SdkHttpRequest request = context.request();
String protocol = request.protocol();
RegionMetadata regionMetadata = RegionMetadata.of(context.region());
String dnsSuffixWithoutTagConsideration = regionMetadata != null ? regionMetadata.domain() : PartitionMetadata.of(context.region()).dnsSuffix();
S3Configuration serviceConfiguration = context.serviceConfiguration();
boolean useAccelerate = isAccelerateEnabled(serviceConfiguration) && isAccelerateSupported(context.originalRequest());
boolean useDualstack = isDualstackEnabled(serviceConfiguration);
boolean useFips = context.fipsEnabled();
if (useAccelerate && useFips) {
throw new IllegalStateException("FIPS is not currently supported for S3 accelerate endpoints.");
}
if (useAccelerate && useDualstack) {
return accelerateDualstackEndpoint(dnsSuffixWithoutTagConsideration, protocol);
}
if (useAccelerate) {
return accelerateEndpoint(dnsSuffixWithoutTagConsideration, protocol);
}
return invokeSafely(() -> new URI(protocol, null, request.host(), request.port(), null, null, null));
}
use of com.ibm.cohort.tooling.s3.S3Configuration in project boot by workoss.
the class CustomEndpointExecutionInterceptor method modifyHttpRequest.
@Override
public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
boolean endpointOverridden = Boolean.TRUE.equals(executionAttributes.getAttribute(SdkExecutionAttribute.ENDPOINT_OVERRIDDEN));
String bucketName = context.request().getValueForField("Bucket", String.class).orElse(null);
S3Configuration serviceConfiguration = (S3Configuration) executionAttributes.getAttribute(AwsSignerExecutionAttribute.SERVICE_CONFIG);
Region region = executionAttributes.getAttribute(AwsSignerExecutionAttribute.SIGNING_REGION);
SdkHttpRequest.Builder builder = context.httpRequest().toBuilder();
if (endpointOverridden && canUseVirtualAddressing(serviceConfiguration, bucketName)) {
changeToDnsEndpoint(region, builder, bucketName);
}
return builder.build();
}
Aggregations