This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch camel-23149-iggy-tls in repository https://gitbox.apache.org/repos/asf/camel.git
commit 70b6b955fc42453214ae7af87b1cadd139f7a066 Author: Guillaume Nodet <[email protected]> AuthorDate: Fri Mar 13 09:35:03 2026 +0100 CAMEL-23149: Add TLS configuration options to camel-iggy Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../org/apache/camel/catalog/components/iggy.json | 8 +- .../component/iggy/IggyComponentConfigurer.java | 12 ++ .../component/iggy/IggyEndpointConfigurer.java | 12 ++ .../component/iggy/IggyEndpointUriFactory.java | 4 +- .../org/apache/camel/component/iggy/iggy.json | 8 +- .../camel/component/iggy/IggyConfiguration.java | 28 +++++ .../apache/camel/component/iggy/IggyConsumer.java | 4 +- .../apache/camel/component/iggy/IggyProducer.java | 4 +- .../iggy/client/IggyClientConnectionPool.java | 7 +- .../component/iggy/client/IggyClientFactory.java | 25 +++- .../component/iggy/IggyConfigurationTest.java | 74 +++++++++++ .../component/dsl/IggyComponentBuilderFactory.java | 35 ++++++ .../endpoint/dsl/IggyEndpointBuilderFactory.java | 135 +++++++++++++++++++++ 13 files changed, 344 insertions(+), 12 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/iggy.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/iggy.json index a02841bf6512..af12c34b7e4d 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/iggy.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/iggy.json @@ -50,7 +50,9 @@ "lazyStartProducer": { "index": 23, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fai [...] "partitioning": { "index": 24, "kind": "property", "displayName": "Partitioning", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.iggy.message.Partitioning", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "balanced", "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Partitioning strategy for message distribution" }, "autowiredEnabled": { "index": 25, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] - "username": { "index": 26, "kind": "property", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } + "tlsCertificatePath": { "index": 26, "kind": "property", "displayName": "Tls Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Path to the TLS certificate file for the connection to the Iggy server" }, + "tlsEnabled": { "index": 27, "kind": "property", "displayName": "Tls Enabled", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Whether to enable TLS for the connection to the Iggy server" }, + "username": { "index": 28, "kind": "property", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } }, "properties": { "topicName": { "index": 0, "kind": "path", "displayName": "Topic Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of the topic" }, @@ -80,6 +82,8 @@ "exchangePattern": { "index": 24, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "partitioning": { "index": 25, "kind": "parameter", "displayName": "Partitioning", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.iggy.message.Partitioning", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "balanced", "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Partitioning strategy for message distribution" }, "lazyStartProducer": { "index": 26, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] - "username": { "index": 27, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } + "tlsCertificatePath": { "index": 27, "kind": "parameter", "displayName": "Tls Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Path to the TLS certificate file for the connection to the Iggy server" }, + "tlsEnabled": { "index": 28, "kind": "parameter", "displayName": "Tls Enabled", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Whether to enable TLS for the connection to the Iggy server" }, + "username": { "index": 29, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } } } diff --git a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyComponentConfigurer.java b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyComponentConfigurer.java index 30dc2a9d6ca4..15136ad4c23e 100644 --- a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyComponentConfigurer.java +++ b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyComponentConfigurer.java @@ -77,6 +77,10 @@ public class IggyComponentConfigurer extends PropertyConfigurerSupport implement case "streamId": getOrCreateConfiguration(target).setStreamId(property(camelContext, java.lang.Long.class, value)); return true; case "streamname": case "streamName": getOrCreateConfiguration(target).setStreamName(property(camelContext, java.lang.String.class, value)); return true; + case "tlscertificatepath": + case "tlsCertificatePath": getOrCreateConfiguration(target).setTlsCertificatePath(property(camelContext, java.lang.String.class, value)); return true; + case "tlsenabled": + case "tlsEnabled": getOrCreateConfiguration(target).setTlsEnabled(property(camelContext, boolean.class, value)); return true; case "username": getOrCreateConfiguration(target).setUsername(property(camelContext, java.lang.String.class, value)); return true; default: return false; } @@ -132,6 +136,10 @@ public class IggyComponentConfigurer extends PropertyConfigurerSupport implement case "streamId": return java.lang.Long.class; case "streamname": case "streamName": return java.lang.String.class; + case "tlscertificatepath": + case "tlsCertificatePath": return java.lang.String.class; + case "tlsenabled": + case "tlsEnabled": return boolean.class; case "username": return java.lang.String.class; default: return null; } @@ -188,6 +196,10 @@ public class IggyComponentConfigurer extends PropertyConfigurerSupport implement case "streamId": return getOrCreateConfiguration(target).getStreamId(); case "streamname": case "streamName": return getOrCreateConfiguration(target).getStreamName(); + case "tlscertificatepath": + case "tlsCertificatePath": return getOrCreateConfiguration(target).getTlsCertificatePath(); + case "tlsenabled": + case "tlsEnabled": return getOrCreateConfiguration(target).isTlsEnabled(); case "username": return getOrCreateConfiguration(target).getUsername(); default: return null; } diff --git a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointConfigurer.java b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointConfigurer.java index 63cc1c3be4e2..daf0dc7978e1 100644 --- a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointConfigurer.java +++ b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointConfigurer.java @@ -71,6 +71,10 @@ public class IggyEndpointConfigurer extends PropertyConfigurerSupport implements case "streamId": target.getConfiguration().setStreamId(property(camelContext, java.lang.Long.class, value)); return true; case "streamname": case "streamName": target.getConfiguration().setStreamName(property(camelContext, java.lang.String.class, value)); return true; + case "tlscertificatepath": + case "tlsCertificatePath": target.getConfiguration().setTlsCertificatePath(property(camelContext, java.lang.String.class, value)); return true; + case "tlsenabled": + case "tlsEnabled": target.getConfiguration().setTlsEnabled(property(camelContext, boolean.class, value)); return true; case "username": target.getConfiguration().setUsername(property(camelContext, java.lang.String.class, value)); return true; default: return false; } @@ -127,6 +131,10 @@ public class IggyEndpointConfigurer extends PropertyConfigurerSupport implements case "streamId": return java.lang.Long.class; case "streamname": case "streamName": return java.lang.String.class; + case "tlscertificatepath": + case "tlsCertificatePath": return java.lang.String.class; + case "tlsenabled": + case "tlsEnabled": return boolean.class; case "username": return java.lang.String.class; default: return null; } @@ -184,6 +192,10 @@ public class IggyEndpointConfigurer extends PropertyConfigurerSupport implements case "streamId": return target.getConfiguration().getStreamId(); case "streamname": case "streamName": return target.getConfiguration().getStreamName(); + case "tlscertificatepath": + case "tlsCertificatePath": return target.getConfiguration().getTlsCertificatePath(); + case "tlsenabled": + case "tlsEnabled": return target.getConfiguration().isTlsEnabled(); case "username": return target.getConfiguration().getUsername(); default: return null; } diff --git a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointUriFactory.java b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointUriFactory.java index c24043e1976a..5fad96013784 100644 --- a/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointUriFactory.java +++ b/components/camel-iggy/src/generated/java/org/apache/camel/component/iggy/IggyEndpointUriFactory.java @@ -23,7 +23,7 @@ public class IggyEndpointUriFactory extends org.apache.camel.support.component.E private static final Set<String> SECRET_PROPERTY_NAMES; private static final Map<String, String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(28); + Set<String> props = new HashSet<>(30); props.add("autoCommit"); props.add("autoCreateStream"); props.add("autoCreateTopic"); @@ -50,6 +50,8 @@ public class IggyEndpointUriFactory extends org.apache.camel.support.component.E props.add("startingOffset"); props.add("streamId"); props.add("streamName"); + props.add("tlsCertificatePath"); + props.add("tlsEnabled"); props.add("topicName"); props.add("username"); PROPERTY_NAMES = Collections.unmodifiableSet(props); diff --git a/components/camel-iggy/src/generated/resources/META-INF/org/apache/camel/component/iggy/iggy.json b/components/camel-iggy/src/generated/resources/META-INF/org/apache/camel/component/iggy/iggy.json index a02841bf6512..af12c34b7e4d 100644 --- a/components/camel-iggy/src/generated/resources/META-INF/org/apache/camel/component/iggy/iggy.json +++ b/components/camel-iggy/src/generated/resources/META-INF/org/apache/camel/component/iggy/iggy.json @@ -50,7 +50,9 @@ "lazyStartProducer": { "index": 23, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fai [...] "partitioning": { "index": 24, "kind": "property", "displayName": "Partitioning", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.iggy.message.Partitioning", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "balanced", "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Partitioning strategy for message distribution" }, "autowiredEnabled": { "index": 25, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...] - "username": { "index": 26, "kind": "property", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } + "tlsCertificatePath": { "index": 26, "kind": "property", "displayName": "Tls Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Path to the TLS certificate file for the connection to the Iggy server" }, + "tlsEnabled": { "index": 27, "kind": "property", "displayName": "Tls Enabled", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Whether to enable TLS for the connection to the Iggy server" }, + "username": { "index": 28, "kind": "property", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } }, "properties": { "topicName": { "index": 0, "kind": "path", "displayName": "Topic Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of the topic" }, @@ -80,6 +82,8 @@ "exchangePattern": { "index": 24, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "partitioning": { "index": 25, "kind": "parameter", "displayName": "Partitioning", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.iggy.message.Partitioning", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "balanced", "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Partitioning strategy for message distribution" }, "lazyStartProducer": { "index": 26, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] - "username": { "index": 27, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } + "tlsCertificatePath": { "index": 27, "kind": "parameter", "displayName": "Tls Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Path to the TLS certificate file for the connection to the Iggy server" }, + "tlsEnabled": { "index": 28, "kind": "parameter", "displayName": "Tls Enabled", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Whether to enable TLS for the connection to the Iggy server" }, + "username": { "index": 29, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.iggy.IggyConfiguration", "configurationField": "configuration", "description": "Iggy username" } } } diff --git a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConfiguration.java b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConfiguration.java index 32cca9cfd33b..c604e1fccee9 100644 --- a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConfiguration.java +++ b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConfiguration.java @@ -79,6 +79,12 @@ public class IggyConfiguration implements Cloneable { description = "Defines the initial message offset position when autoCommit is disabled. " + "Use 0 to start from the beginning of the stream, or specify a custom offset to resume from a particular point") private Long startingOffset; + @UriParam(label = "security", defaultValue = "false", + description = "Whether to enable TLS for the connection to the Iggy server") + private boolean tlsEnabled; + @UriParam(label = "security", + description = "Path to the TLS certificate file for the connection to the Iggy server") + private String tlsCertificatePath; public IggyConfiguration copy() { try { @@ -277,4 +283,26 @@ public class IggyConfiguration implements Cloneable { public void setStartingOffset(Long startingOffset) { this.startingOffset = startingOffset; } + + public boolean isTlsEnabled() { + return tlsEnabled; + } + + /** + * Whether to enable TLS for the connection to the Iggy server. + */ + public void setTlsEnabled(boolean tlsEnabled) { + this.tlsEnabled = tlsEnabled; + } + + public String getTlsCertificatePath() { + return tlsCertificatePath; + } + + /** + * Path to the TLS certificate file for the connection to the Iggy server. + */ + public void setTlsCertificatePath(String tlsCertificatePath) { + this.tlsCertificatePath = tlsCertificatePath; + } } diff --git a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConsumer.java b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConsumer.java index f58883ab2e3a..76e18c4241bb 100644 --- a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConsumer.java +++ b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConsumer.java @@ -53,7 +53,9 @@ public class IggyConsumer extends DefaultConsumer { endpoint.getConfiguration().getPort(), endpoint.getConfiguration().getUsername(), endpoint.getConfiguration().getPassword(), - endpoint.getConfiguration().getClientTransport()); + endpoint.getConfiguration().getClientTransport(), + endpoint.getConfiguration().isTlsEnabled(), + endpoint.getConfiguration().getTlsCertificatePath()); IggyBaseClient client = iggyClientConnectionPool.borrowObject(); endpoint.initializeTopic(client); diff --git a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyProducer.java b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyProducer.java index 81a20ce0a2bc..75bca5324967 100644 --- a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyProducer.java +++ b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyProducer.java @@ -52,7 +52,9 @@ public class IggyProducer extends DefaultAsyncProducer { endpoint.getConfiguration().getPort(), endpoint.getConfiguration().getUsername(), endpoint.getConfiguration().getPassword(), - endpoint.getConfiguration().getClientTransport()); + endpoint.getConfiguration().getClientTransport(), + endpoint.getConfiguration().isTlsEnabled(), + endpoint.getConfiguration().getTlsCertificatePath()); IggyBaseClient client = iggyClientConnectionPool.borrowObject(); endpoint.initializeTopic(client); diff --git a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientConnectionPool.java b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientConnectionPool.java index 4455d213a54d..9eddeb6fdf72 100644 --- a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientConnectionPool.java +++ b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientConnectionPool.java @@ -23,8 +23,11 @@ public class IggyClientConnectionPool { private final GenericObjectPool<IggyBaseClient> pool; - public IggyClientConnectionPool(String host, int port, String username, String password, String transport) { - IggyClientFactory factory = new IggyClientFactory(host, port, username, password, transport); + public IggyClientConnectionPool(String host, int port, String username, String password, String transport, + boolean tlsEnabled, String tlsCertificatePath) { + IggyClientFactory factory = new IggyClientFactory( + host, port, username, password, transport, + tlsEnabled, tlsCertificatePath); this.pool = new GenericObjectPool<>(factory); } diff --git a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientFactory.java b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientFactory.java index f0aa85e8126b..4b69d6e6e9c4 100644 --- a/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientFactory.java +++ b/components/camel-iggy/src/main/java/org/apache/camel/component/iggy/client/IggyClientFactory.java @@ -30,22 +30,41 @@ public class IggyClientFactory extends BasePooledObjectFactory<IggyBaseClient> { private final String username; private final String password; private final String transport; + private final boolean tlsEnabled; + private final String tlsCertificatePath; - public IggyClientFactory(String host, int port, String username, String password, String transport) { + public IggyClientFactory(String host, int port, String username, String password, String transport, + boolean tlsEnabled, String tlsCertificatePath) { this.host = host; this.port = port; this.username = username; this.password = password; this.transport = transport; + this.tlsEnabled = tlsEnabled; + this.tlsCertificatePath = tlsCertificatePath; } @Override public IggyBaseClient create() throws Exception { IggyBaseClient iggyBaseClient; if ("TCP".equalsIgnoreCase(transport)) { - iggyBaseClient = IggyTcpClient.builder().host(host).port(port).credentials(username, password).buildAndLogin(); + var builder = IggyTcpClient.builder().host(host).port(port).credentials(username, password); + if (tlsEnabled) { + builder.enableTls(); + if (tlsCertificatePath != null) { + builder.tlsCertificate(tlsCertificatePath); + } + } + iggyBaseClient = builder.buildAndLogin(); } else if ("HTTP".equalsIgnoreCase(transport)) { - iggyBaseClient = IggyHttpClient.builder().host(host).port(port).credentials(username, password).buildAndLogin(); + var builder = IggyHttpClient.builder().host(host).port(port).credentials(username, password); + if (tlsEnabled) { + builder.enableTls(); + if (tlsCertificatePath != null) { + builder.tlsCertificate(tlsCertificatePath); + } + } + iggyBaseClient = builder.buildAndLogin(); } else { throw new IllegalArgumentException("Only HTTP or TCP transports are supported"); } diff --git a/components/camel-iggy/src/test/java/org/apache/camel/component/iggy/IggyConfigurationTest.java b/components/camel-iggy/src/test/java/org/apache/camel/component/iggy/IggyConfigurationTest.java new file mode 100644 index 000000000000..cd83e7c87208 --- /dev/null +++ b/components/camel-iggy/src/test/java/org/apache/camel/component/iggy/IggyConfigurationTest.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.iggy; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class IggyConfigurationTest { + + @Test + public void testTlsDefaults() { + IggyConfiguration configuration = new IggyConfiguration(); + assertFalse(configuration.isTlsEnabled()); + assertNull(configuration.getTlsCertificatePath()); + } + + @Test + public void testTlsEnabled() { + IggyConfiguration configuration = new IggyConfiguration(); + configuration.setTlsEnabled(true); + assertTrue(configuration.isTlsEnabled()); + } + + @Test + public void testTlsCertificatePath() { + IggyConfiguration configuration = new IggyConfiguration(); + configuration.setTlsCertificatePath("/path/to/cert.pem"); + assertEquals("/path/to/cert.pem", configuration.getTlsCertificatePath()); + } + + @Test + public void testTlsConfigurationCopy() { + IggyConfiguration configuration = new IggyConfiguration(); + configuration.setTlsEnabled(true); + configuration.setTlsCertificatePath("/path/to/cert.pem"); + + IggyConfiguration copy = configuration.copy(); + assertTrue(copy.isTlsEnabled()); + assertEquals("/path/to/cert.pem", copy.getTlsCertificatePath()); + } + + @Test + public void testTlsEndpointUri() throws Exception { + org.apache.camel.impl.DefaultCamelContext context = new org.apache.camel.impl.DefaultCamelContext(); + context.start(); + try { + IggyEndpoint endpoint = context.getEndpoint( + "iggy:myTopic?tlsEnabled=true&tlsCertificatePath=/path/to/cert.pem&streamName=myStream&username=user&password=pass", + IggyEndpoint.class); + assertTrue(endpoint.getConfiguration().isTlsEnabled()); + assertEquals("/path/to/cert.pem", endpoint.getConfiguration().getTlsCertificatePath()); + } finally { + context.stop(); + } + } +} diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IggyComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IggyComponentBuilderFactory.java index d6ea3de56b03..7ad4c6fd2ad3 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IggyComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IggyComponentBuilderFactory.java @@ -506,6 +506,39 @@ public interface IggyComponentBuilderFactory { return this; } + /** + * Path to the TLS certificate file for the connection to the Iggy + * server. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param tlsCertificatePath the value to set + * @return the dsl builder + */ + default IggyComponentBuilder tlsCertificatePath(java.lang.String tlsCertificatePath) { + doSetProperty("tlsCertificatePath", tlsCertificatePath); + return this; + } + + + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyComponentBuilder tlsEnabled(boolean tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } + /** * Iggy username. * @@ -567,6 +600,8 @@ public interface IggyComponentBuilderFactory { case "lazyStartProducer": ((IggyComponent) component).setLazyStartProducer((boolean) value); return true; case "partitioning": getOrCreateConfiguration((IggyComponent) component).setPartitioning((org.apache.iggy.message.Partitioning) value); return true; case "autowiredEnabled": ((IggyComponent) component).setAutowiredEnabled((boolean) value); return true; + case "tlsCertificatePath": getOrCreateConfiguration((IggyComponent) component).setTlsCertificatePath((java.lang.String) value); return true; + case "tlsEnabled": getOrCreateConfiguration((IggyComponent) component).setTlsEnabled((boolean) value); return true; case "username": getOrCreateConfiguration((IggyComponent) component).setUsername((java.lang.String) value); return true; default: return false; } diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IggyEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IggyEndpointBuilderFactory.java index 6410c9f3d558..e090e3c3ed46 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IggyEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IggyEndpointBuilderFactory.java @@ -586,6 +586,51 @@ public interface IggyEndpointBuilderFactory { doSetProperty("startingOffset", startingOffset); return this; } + /** + * Path to the TLS certificate file for the connection to the Iggy + * server. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param tlsCertificatePath the value to set + * @return the dsl builder + */ + default IggyEndpointConsumerBuilder tlsCertificatePath(String tlsCertificatePath) { + doSetProperty("tlsCertificatePath", tlsCertificatePath); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointConsumerBuilder tlsEnabled(boolean tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointConsumerBuilder tlsEnabled(String tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } /** * Iggy username. * @@ -1098,6 +1143,51 @@ public interface IggyEndpointBuilderFactory { doSetProperty("partitioning", partitioning); return this; } + /** + * Path to the TLS certificate file for the connection to the Iggy + * server. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param tlsCertificatePath the value to set + * @return the dsl builder + */ + default IggyEndpointProducerBuilder tlsCertificatePath(String tlsCertificatePath) { + doSetProperty("tlsCertificatePath", tlsCertificatePath); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointProducerBuilder tlsEnabled(boolean tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointProducerBuilder tlsEnabled(String tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } /** * Iggy username. * @@ -1507,6 +1597,51 @@ public interface IggyEndpointBuilderFactory { doSetProperty("streamName", streamName); return this; } + /** + * Path to the TLS certificate file for the connection to the Iggy + * server. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param tlsCertificatePath the value to set + * @return the dsl builder + */ + default IggyEndpointBuilder tlsCertificatePath(String tlsCertificatePath) { + doSetProperty("tlsCertificatePath", tlsCertificatePath); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointBuilder tlsEnabled(boolean tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } + /** + * Whether to enable TLS for the connection to the Iggy server. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: security + * + * @param tlsEnabled the value to set + * @return the dsl builder + */ + default IggyEndpointBuilder tlsEnabled(String tlsEnabled) { + doSetProperty("tlsEnabled", tlsEnabled); + return this; + } /** * Iggy username. *
