You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/07/08 10:20:11 UTC

[camel] 02/04: CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - DynamoDB Streams

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 55e755d9833bcbf84cab63c4fe159804186f65e1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 8 12:18:16 2020 +0200

    CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - DynamoDB Streams
---
 .../component/aws2/ddbstream/Ddb2StreamConfiguration.java   | 10 ++++++++++
 .../camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java  | 13 +++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConfiguration.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConfiguration.java
index e2265a9..cd399ef8 100644
--- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConfiguration.java
+++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConfiguration.java
@@ -59,6 +59,8 @@ public class Ddb2StreamConfiguration implements Cloneable {
     private String proxyHost;
     @UriParam(description = "To define a proxy port when instantiating the DDBStreams client")
     private Integer proxyPort;
+    @UriParam(defaultValue = "false", description = "If we want to trust all certificates in case of overriding the endpoint")
+    private boolean trustAllCertificates;
 
     public DynamoDbStreamsClient getAmazonDynamoDbStreamsClient() {
         return amazonDynamoDbStreamsClient;
@@ -147,6 +149,14 @@ public class Ddb2StreamConfiguration implements Cloneable {
     public void setProxyPort(Integer proxyPort) {
         this.proxyPort = proxyPort;
     }
+    
+    public boolean isTrustAllCertificates() {
+        return trustAllCertificates;
+    }
+
+    public void setTrustAllCertificates(boolean trustAllCertificates) {
+        this.trustAllCertificates = trustAllCertificates;
+    }
 
     // *************************************************
     //
diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
index eaef7e9..da43abb 100644
--- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
+++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
@@ -29,12 +29,15 @@ import org.apache.camel.support.ScheduledPollEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.SdkHttpClient;
+import software.amazon.awssdk.http.SdkHttpConfigurationOption;
 import software.amazon.awssdk.http.apache.ApacheHttpClient;
 import software.amazon.awssdk.http.apache.ProxyConfiguration;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.dynamodb.model.Record;
 import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
 import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
 
 /**
  * Receive messages from AWS DynamoDB Stream service using AWS SDK version 2.x.
@@ -139,6 +142,16 @@ public class Ddb2StreamEndpoint extends ScheduledPollEndpoint {
         if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
             clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
         }
+        if (configuration.isTrustAllCertificates()) {
+            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
+                    .builder()
+                    .put(
+                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
+                            Boolean.TRUE
+                    )
+                    .build());
+            clientBuilder.httpClient(ahc);
+        }
         client = clientBuilder.build();
         return client;
     }