Search in sources :

Example 6 with S3Configuration

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);
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) Test(org.junit.jupiter.api.Test)

Example 7 with S3Configuration

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;
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) SdkRequest(software.amazon.awssdk.core.SdkRequest) UploadPartRequest(software.amazon.awssdk.services.s3.model.UploadPartRequest) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest)

Example 8 with S3Configuration

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);
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) Region(software.amazon.awssdk.regions.Region) S3EndpointUtils.isFipsRegion(software.amazon.awssdk.services.s3.internal.endpoints.S3EndpointUtils.isFipsRegion)

Example 9 with S3Configuration

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));
}
Also used : SdkHttpRequest(software.amazon.awssdk.http.SdkHttpRequest) ConfiguredS3SdkHttpRequest(software.amazon.awssdk.services.s3.internal.ConfiguredS3SdkHttpRequest) S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) RegionMetadata(software.amazon.awssdk.regions.RegionMetadata) URI(java.net.URI)

Example 10 with S3Configuration

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();
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) SdkHttpRequest(software.amazon.awssdk.http.SdkHttpRequest) Region(software.amazon.awssdk.regions.Region)

Aggregations

S3Configuration (software.amazon.awssdk.services.s3.S3Configuration)12 URI (java.net.URI)5 S3Configuration (jetbrains.buildServer.artifacts.s3.S3Configuration)4 File (java.io.File)3 NotNull (org.jetbrains.annotations.NotNull)3 Test (org.junit.jupiter.api.Test)3 ConfiguredS3SdkHttpRequest (software.amazon.awssdk.services.s3.internal.ConfiguredS3SdkHttpRequest)3 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 Consumer (java.util.function.Consumer)2 Supplier (java.util.function.Supplier)2 ExtensionHolder (jetbrains.buildServer.ExtensionHolder)2 AgentArtifactHelper (jetbrains.buildServer.agent.artifacts.AgentArtifactHelper)2 FileUploadInfo (jetbrains.buildServer.artifacts.s3.FileUploadInfo)2 S3UploadLogger (jetbrains.buildServer.artifacts.s3.publish.logger.S3UploadLogger)2 PresignedUrlsProviderClientFactory (jetbrains.buildServer.artifacts.s3.publish.presigned.upload.PresignedUrlsProviderClientFactory)2 S3Configuration (org.apache.camel.component.aws.s3.S3Configuration)2 SdkHttpRequest (software.amazon.awssdk.http.SdkHttpRequest)2 Region (software.amazon.awssdk.regions.Region)2 S3Request (software.amazon.awssdk.services.s3.model.S3Request)2 Http (akka.http.scaladsl.Http)1