Search in sources :

Example 1 with S3Configuration

use of org.apache.camel.component.aws.s3.S3Configuration in project syndesis by syndesisio.

the class AWSS3RawOptionsTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    camelContext.setAutoStartup(false);
    camelContext.addComponent("aws-s3", new S3Component() {

        @Override
        protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
            final S3Configuration configuration = new S3Configuration();
            setProperties(configuration, parameters);
            return new S3Endpoint(uri, this, configuration) {

                @Override
                public void doStart() throws Exception {
                // don't let the endpoint to start as it would try to
                // process the keys
                }
            };
        }
    });
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) S3Configuration(org.apache.camel.component.aws.s3.S3Configuration) S3Endpoint(org.apache.camel.component.aws.s3.S3Endpoint) Endpoint(org.apache.camel.Endpoint) S3Component(org.apache.camel.component.aws.s3.S3Component) S3Endpoint(org.apache.camel.component.aws.s3.S3Endpoint) IOException(java.io.IOException)

Example 2 with S3Configuration

use of org.apache.camel.component.aws.s3.S3Configuration in project syndesis by syndesisio.

the class AWSS3VerifierExtension method verifyConnectivity.

// *********************************
// Connectivity validation
// *********************************
@Override
@SuppressWarnings("PMD.AvoidCatchingGenericException")
protected Result verifyConnectivity(Map<String, Object> parameters) {
    ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
    try {
        S3Configuration configuration = setProperties(new S3Configuration(), parameters);
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
        AmazonS3 client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build();
        client.listBuckets();
    } catch (SdkClientException e) {
        ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()).detail("aws_s3_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()).detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
        builder.error(errorBuilder.build());
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
        builder.error(ResultErrorBuilder.withException(e).build());
    }
    return builder.build();
}
Also used : ResultBuilder(org.apache.camel.component.extension.verifier.ResultBuilder) AmazonS3(com.amazonaws.services.s3.AmazonS3) AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) S3Configuration(org.apache.camel.component.aws.s3.S3Configuration) SdkClientException(com.amazonaws.SdkClientException) ResultErrorBuilder(org.apache.camel.component.extension.verifier.ResultErrorBuilder) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) SdkClientException(com.amazonaws.SdkClientException)

Example 3 with S3Configuration

use of org.apache.camel.component.aws.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();
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) Http(akka.http.scaladsl.Http) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Aggregations

S3Configuration (org.apache.camel.component.aws.s3.S3Configuration)2 Http (akka.http.scaladsl.Http)1 SdkClientException (com.amazonaws.SdkClientException)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 IOException (java.io.IOException)1 URI (java.net.URI)1 CamelContext (org.apache.camel.CamelContext)1 Endpoint (org.apache.camel.Endpoint)1 S3Component (org.apache.camel.component.aws.s3.S3Component)1 S3Endpoint (org.apache.camel.component.aws.s3.S3Endpoint)1 ResultBuilder (org.apache.camel.component.extension.verifier.ResultBuilder)1 ResultErrorBuilder (org.apache.camel.component.extension.verifier.ResultErrorBuilder)1 BeforeClass (org.junit.BeforeClass)1 S3Configuration (software.amazon.awssdk.services.s3.S3Configuration)1