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:12:20 UTC
[camel] 01/02: CAMEL-15280 - Camel-AWS2-*: Add the ability to trust
all certificates when overidding the endpoint - CloudWatch
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 e9d40b9cdefe0ae0ea19c44f0f2a9461e27a48ae
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 8 12:09:30 2020 +0200
CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - CloudWatch
---
.../component/aws2/cw/Cw2ComponentConfigurer.java | 5 ++++
.../component/aws2/cw/Cw2EndpointConfigurer.java | 5 ++++
.../apache/camel/component/aws2/cw/aws2-cw.json | 2 ++
.../src/main/docs/aws2-cw-component.adoc | 6 +++--
.../camel/component/aws2/cw/Cw2Configuration.java | 13 ++++++++++
.../camel/component/aws2/cw/Cw2Endpoint.java | 13 ++++++++++
.../dsl/Aws2CwComponentBuilderFactory.java | 15 ++++++++++++
.../builder/endpoint/StaticEndpointBuilders.java | 8 +++----
.../endpoint/dsl/Cw2EndpointBuilderFactory.java | 28 ++++++++++++++++++++++
9 files changed, 89 insertions(+), 6 deletions(-)
diff --git a/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java b/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
index 4e1feb7..07838a3 100644
--- a/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
+++ b/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2ComponentConfigurer.java
@@ -46,6 +46,8 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
case "secretkey":
case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
case "timestamp": getOrCreateConfiguration(target).setTimestamp(property(camelContext, java.time.Instant.class, value)); return true;
+ case "trustallcertificates":
+ case "trustAllCertificates": getOrCreateConfiguration(target).setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
case "unit": getOrCreateConfiguration(target).setUnit(property(camelContext, java.lang.String.class, value)); return true;
case "value": getOrCreateConfiguration(target).setValue(property(camelContext, java.lang.Double.class, value)); return true;
default: return false;
@@ -67,6 +69,7 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
answer.put("region", java.lang.String.class);
answer.put("secretKey", java.lang.String.class);
answer.put("timestamp", java.time.Instant.class);
+ answer.put("trustAllCertificates", boolean.class);
answer.put("unit", java.lang.String.class);
answer.put("value", java.lang.Double.class);
return answer;
@@ -96,6 +99,8 @@ public class Cw2ComponentConfigurer extends PropertyConfigurerSupport implements
case "secretkey":
case "secretKey": return getOrCreateConfiguration(target).getSecretKey();
case "timestamp": return getOrCreateConfiguration(target).getTimestamp();
+ case "trustallcertificates":
+ case "trustAllCertificates": return getOrCreateConfiguration(target).isTrustAllCertificates();
case "unit": return getOrCreateConfiguration(target).getUnit();
case "value": return getOrCreateConfiguration(target).getValue();
default: return null;
diff --git a/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2EndpointConfigurer.java b/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2EndpointConfigurer.java
index 31b3981..febe3db 100644
--- a/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2EndpointConfigurer.java
+++ b/components/camel-aws2-cw/src/generated/java/org/apache/camel/component/aws2/cw/Cw2EndpointConfigurer.java
@@ -39,6 +39,8 @@ public class Cw2EndpointConfigurer extends PropertyConfigurerSupport implements
case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
case "synchronous": target.setSynchronous(property(camelContext, boolean.class, value)); return true;
case "timestamp": target.getConfiguration().setTimestamp(property(camelContext, java.time.Instant.class, value)); return true;
+ case "trustallcertificates":
+ case "trustAllCertificates": target.getConfiguration().setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
case "unit": target.getConfiguration().setUnit(property(camelContext, java.lang.String.class, value)); return true;
case "value": target.getConfiguration().setValue(property(camelContext, java.lang.Double.class, value)); return true;
default: return false;
@@ -60,6 +62,7 @@ public class Cw2EndpointConfigurer extends PropertyConfigurerSupport implements
answer.put("secretKey", java.lang.String.class);
answer.put("synchronous", boolean.class);
answer.put("timestamp", java.time.Instant.class);
+ answer.put("trustAllCertificates", boolean.class);
answer.put("unit", java.lang.String.class);
answer.put("value", java.lang.Double.class);
return answer;
@@ -89,6 +92,8 @@ public class Cw2EndpointConfigurer extends PropertyConfigurerSupport implements
case "secretKey": return target.getConfiguration().getSecretKey();
case "synchronous": return target.isSynchronous();
case "timestamp": return target.getConfiguration().getTimestamp();
+ case "trustallcertificates":
+ case "trustAllCertificates": return target.getConfiguration().isTrustAllCertificates();
case "unit": return target.getConfiguration().getUnit();
case "value": return target.getConfiguration().getValue();
default: return null;
diff --git a/components/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json b/components/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
index 8ca0b90..e522642 100644
--- a/components/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
+++ b/components/camel-aws2-cw/src/generated/resources/org/apache/camel/component/aws2/cw/aws2-cw.json
@@ -30,6 +30,7 @@
"proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the CW client" },
"region": { "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The region in which EKS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1 [...]
"timestamp": { "kind": "property", "displayName": "Timestamp", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Instant", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric timestamp" },
+ "trustAllCertificates": { "kind": "property", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
"unit": { "kind": "property", "displayName": "Unit", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric unit" },
"value": { "kind": "property", "displayName": "Value", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric value" },
"basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" },
@@ -46,6 +47,7 @@
"proxyProtocol": { "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the CW client" },
"region": { "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The region in which EKS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east- [...]
"timestamp": { "kind": "parameter", "displayName": "Timestamp", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Instant", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric timestamp" },
+ "trustAllCertificates": { "kind": "parameter", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
"unit": { "kind": "parameter", "displayName": "Unit", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric unit" },
"value": { "kind": "parameter", "displayName": "Value", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.cw.Cw2Configuration", "configurationField": "configuration", "description": "The metric value" },
"basicPropertyBinding": { "kind": "parameter", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" },
diff --git a/components/camel-aws2-cw/src/main/docs/aws2-cw-component.adoc b/components/camel-aws2-cw/src/main/docs/aws2-cw-component.adoc
index c409ece..2f327b7 100644
--- a/components/camel-aws2-cw/src/main/docs/aws2-cw-component.adoc
+++ b/components/camel-aws2-cw/src/main/docs/aws2-cw-component.adoc
@@ -44,7 +44,7 @@ The metrics will be created if they don't already exists. +
// component options: START
-The AWS 2 CloudWatch component supports 14 options, which are listed below.
+The AWS 2 CloudWatch component supports 15 options, which are listed below.
@@ -60,6 +60,7 @@ The AWS 2 CloudWatch component supports 14 options, which are listed below.
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the CW client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
| *region* (producer) | The region in which EKS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | | String
| *timestamp* (producer) | The metric timestamp | | Instant
+| *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
| *unit* (producer) | The metric unit | | String
| *value* (producer) | The metric value | | Double
| *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
@@ -90,7 +91,7 @@ with the following path and query parameters:
|===
-=== Query Parameters (14 parameters):
+=== Query Parameters (15 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
@@ -104,6 +105,7 @@ with the following path and query parameters:
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the CW client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
| *region* (producer) | The region in which EKS client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | | String
| *timestamp* (producer) | The metric timestamp | | Instant
+| *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
| *unit* (producer) | The metric unit | | String
| *value* (producer) | The metric value | | Double
| *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
diff --git a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
index ec46997..5ab1744 100644
--- a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
+++ b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
@@ -54,6 +54,8 @@ public class Cw2Configuration implements Cloneable {
private Integer proxyPort;
@UriParam
private String region;
+ @UriParam(defaultValue = "false")
+ private boolean trustAllCertificates;
public String getAccessKey() {
return accessKey;
@@ -189,6 +191,17 @@ public class Cw2Configuration implements Cloneable {
public void setRegion(String region) {
this.region = region;
}
+
+ public boolean isTrustAllCertificates() {
+ return trustAllCertificates;
+ }
+
+ /**
+ * If we want to trust all certificates in case of overriding the endpoint
+ */
+ public void setTrustAllCertificates(boolean trustAllCertificates) {
+ this.trustAllCertificates = trustAllCertificates;
+ }
// *************************************************
//
diff --git a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
index 5191b25..3cfd1e4 100644
--- a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
+++ b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
@@ -29,11 +29,14 @@ import org.apache.camel.support.DefaultEndpoint;
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.cloudwatch.CloudWatchClient;
import software.amazon.awssdk.services.cloudwatch.CloudWatchClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
/**
* Sending metrics to AWS CloudWatch using AWS SDK version 2.x.
@@ -121,6 +124,16 @@ public class Cw2Endpoint extends DefaultEndpoint {
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;
}
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
index e15fac0..2a5c60a 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2CwComponentBuilderFactory.java
@@ -167,6 +167,20 @@ public interface Aws2CwComponentBuilderFactory {
return this;
}
/**
+ * If we want to trust all certificates in case of overriding the
+ * endpoint.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default Aws2CwComponentBuilder trustAllCertificates(
+ boolean trustAllCertificates) {
+ doSetProperty("trustAllCertificates", trustAllCertificates);
+ return this;
+ }
+ /**
* The metric unit.
*
* The option is a: <code>java.lang.String</code> type.
@@ -257,6 +271,7 @@ public interface Aws2CwComponentBuilderFactory {
case "proxyProtocol": getOrCreateConfiguration((Cw2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
case "region": getOrCreateConfiguration((Cw2Component) component).setRegion((java.lang.String) value); return true;
case "timestamp": getOrCreateConfiguration((Cw2Component) component).setTimestamp((java.time.Instant) value); return true;
+ case "trustAllCertificates": getOrCreateConfiguration((Cw2Component) component).setTrustAllCertificates((boolean) value); return true;
case "unit": getOrCreateConfiguration((Cw2Component) component).setUnit((java.lang.String) value); return true;
case "value": getOrCreateConfiguration((Cw2Component) component).setValue((java.lang.Double) value); return true;
case "basicPropertyBinding": ((Cw2Component) component).setBasicPropertyBinding((boolean) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index 2aa539d..3c512a1 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -836,7 +836,7 @@ public class StaticEndpointBuilders {
*
* @param path namespace
*/
- public static org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.Cw2EndpointBuilder aws2Cw(
+ static org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.Cw2EndpointBuilder aws2Cw(
String path) {
return org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.endpointBuilder("aws2-cw", path);
}
@@ -857,7 +857,7 @@ public class StaticEndpointBuilders {
* instead of the default name
* @param path namespace
*/
- public static org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.Cw2EndpointBuilder aws2Cw(
+ static org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.Cw2EndpointBuilder aws2Cw(
String componentName,
String path) {
return org.apache.camel.builder.endpoint.dsl.Cw2EndpointBuilderFactory.endpointBuilder(componentName, path);
@@ -1376,7 +1376,7 @@ public class StaticEndpointBuilders {
*
* @param path //bucketNameOrArn
*/
- static org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.AWS2S3EndpointBuilder aws2S3(
+ public static org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.AWS2S3EndpointBuilder aws2S3(
String path) {
return org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.endpointBuilder("aws2-s3", path);
}
@@ -1398,7 +1398,7 @@ public class StaticEndpointBuilders {
* instead of the default name
* @param path //bucketNameOrArn
*/
- static org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.AWS2S3EndpointBuilder aws2S3(
+ public static org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.AWS2S3EndpointBuilder aws2S3(
String componentName,
String path) {
return org.apache.camel.builder.endpoint.dsl.AWS2S3EndpointBuilderFactory.endpointBuilder(componentName, path);
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Cw2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Cw2EndpointBuilderFactory.java
index 995fa43..eff394b 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Cw2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Cw2EndpointBuilderFactory.java
@@ -211,6 +211,34 @@ public interface Cw2EndpointBuilderFactory {
return this;
}
/**
+ * If we want to trust all certificates in case of overriding the
+ * endpoint.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default Cw2EndpointBuilder trustAllCertificates(
+ boolean trustAllCertificates) {
+ doSetProperty("trustAllCertificates", trustAllCertificates);
+ return this;
+ }
+ /**
+ * If we want to trust all certificates in case of overriding the
+ * endpoint.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default Cw2EndpointBuilder trustAllCertificates(
+ String trustAllCertificates) {
+ doSetProperty("trustAllCertificates", trustAllCertificates);
+ return this;
+ }
+ /**
* The metric unit.
*
* The option is a: <code>java.lang.String</code> type.