CAMEL-15384: camel-vertx-http - Allow to configure http proxy on component level
diff --git a/components/camel-vertx-http/src/generated/java/org/apache/camel/component/vertx/http/VertxHttpComponentConfigurer.java b/components/camel-vertx-http/src/generated/java/org/apache/camel/component/vertx/http/VertxHttpComponentConfigurer.java
index 021addf..bbabab4 100644
--- a/components/camel-vertx-http/src/generated/java/org/apache/camel/component/vertx/http/VertxHttpComponentConfigurer.java
+++ b/components/camel-vertx-http/src/generated/java/org/apache/camel/component/vertx/http/VertxHttpComponentConfigurer.java
@@ -27,6 +27,16 @@
case "headerFilterStrategy": target.setHeaderFilterStrategy(property(camelContext, org.apache.camel.spi.HeaderFilterStrategy.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
+ case "proxyhost":
+ case "proxyHost": target.setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
+ case "proxypassword":
+ case "proxyPassword": target.setProxyPassword(property(camelContext, java.lang.String.class, value)); return true;
+ case "proxyport":
+ case "proxyPort": target.setProxyPort(property(camelContext, java.lang.Integer.class, value)); return true;
+ case "proxytype":
+ case "proxyType": target.setProxyType(property(camelContext, io.vertx.core.net.ProxyType.class, value)); return true;
+ case "proxyusername":
+ case "proxyUsername": target.setProxyUsername(property(camelContext, java.lang.String.class, value)); return true;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": target.setUseGlobalSslContextParameters(property(camelContext, boolean.class, value)); return true;
case "vertx": target.setVertx(property(camelContext, io.vertx.core.Vertx.class, value)); return true;
@@ -45,6 +55,11 @@
answer.put("basicPropertyBinding", boolean.class);
answer.put("headerFilterStrategy", org.apache.camel.spi.HeaderFilterStrategy.class);
answer.put("lazyStartProducer", boolean.class);
+ answer.put("proxyHost", java.lang.String.class);
+ answer.put("proxyPassword", java.lang.String.class);
+ answer.put("proxyPort", java.lang.Integer.class);
+ answer.put("proxyType", io.vertx.core.net.ProxyType.class);
+ answer.put("proxyUsername", java.lang.String.class);
answer.put("useGlobalSslContextParameters", boolean.class);
answer.put("vertx", io.vertx.core.Vertx.class);
answer.put("vertxHttpBinding", org.apache.camel.component.vertx.http.VertxHttpBinding.class);
@@ -64,6 +79,16 @@
case "headerFilterStrategy": return target.getHeaderFilterStrategy();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "proxyhost":
+ case "proxyHost": return target.getProxyHost();
+ case "proxypassword":
+ case "proxyPassword": return target.getProxyPassword();
+ case "proxyport":
+ case "proxyPort": return target.getProxyPort();
+ case "proxytype":
+ case "proxyType": return target.getProxyType();
+ case "proxyusername":
+ case "proxyUsername": return target.getProxyUsername();
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return target.isUseGlobalSslContextParameters();
case "vertx": return target.getVertx();
diff --git a/components/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json b/components/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
index cae5131..7a2a233 100644
--- a/components/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
+++ b/components/camel-vertx-http/src/generated/resources/org/apache/camel/component/vertx/http/vertx-http.json
@@ -28,6 +28,11 @@
"vertxHttpBinding": { "kind": "property", "displayName": "Vertx Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.vertx.http.VertxHttpBinding", "deprecated": false, "secret": false, "description": "A custom VertxHttpBinding which can control how to bind between Vert.x and Camel" },
"vertxOptions": { "kind": "property", "displayName": "Vertx Options", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.vertx.core.VertxOptions", "deprecated": false, "secret": false, "description": "To provide a custom set of vertx options for configuring vertx" },
"headerFilterStrategy": { "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." },
+ "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The proxy server host address" },
+ "proxyPassword": { "kind": "property", "displayName": "Proxy Password", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The proxy server password if authentication is required" },
+ "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "description": "The proxy server port" },
+ "proxyType": { "kind": "property", "displayName": "Proxy Type", "group": "proxy", "label": "proxy", "required": false, "type": "object", "javaType": "io.vertx.core.net.ProxyType", "enum": [ "HTTP", "SOCKS4", "SOCKS5" ], "deprecated": false, "secret": false, "description": "The proxy server type" },
+ "proxyUsername": { "kind": "property", "displayName": "Proxy Username", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The proxy server username if authentication is required" },
"useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Enable usage of global SSL context parameters" }
},
"properties": {
diff --git a/components/camel-vertx-http/src/main/docs/vertx-http-component.adoc b/components/camel-vertx-http/src/main/docs/vertx-http-component.adoc
index ea755ba..ebcdd24 100644
--- a/components/camel-vertx-http/src/main/docs/vertx-http-component.adoc
+++ b/components/camel-vertx-http/src/main/docs/vertx-http-component.adoc
@@ -36,7 +36,7 @@
== Options
// component options: START
-The Vert.x HTTP Client component supports 8 options, which are listed below.
+The Vert.x HTTP Client component supports 13 options, which are listed below.
@@ -50,6 +50,11 @@
| *vertxHttpBinding* (advanced) | A custom VertxHttpBinding which can control how to bind between Vert.x and Camel | | VertxHttpBinding
| *vertxOptions* (advanced) | To provide a custom set of vertx options for configuring vertx | | VertxOptions
| *headerFilterStrategy* (filter) | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy
+| *proxyHost* (proxy) | The proxy server host address | | String
+| *proxyPassword* (proxy) | The proxy server password if authentication is required | | String
+| *proxyPort* (proxy) | The proxy server port | | Integer
+| *proxyType* (proxy) | The proxy server type. The value can be one of: HTTP, SOCKS4, SOCKS5 | | ProxyType
+| *proxyUsername* (proxy) | The proxy server username if authentication is required | | String
| *useGlobalSslContextParameters* (security) | Enable usage of global SSL context parameters | false | boolean
|===
// component options: END
diff --git a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
index 353f53b..18ae652 100644
--- a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
+++ b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
@@ -23,6 +23,7 @@
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
+import io.vertx.core.net.ProxyType;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.Producer;
@@ -43,6 +44,19 @@
@Component("vertx-http")
public class VertxHttpComponent extends HeaderFilterStrategyComponent implements RestProducerFactory, SSLContextParametersAware {
+ private volatile boolean managedVertx;
+
+ @Metadata(label = "proxy")
+ private String proxyHost;
+ @Metadata(label = "proxy")
+ private Integer proxyPort;
+ @Metadata(label = "proxy", enums = "HTTP,SOCKS4,SOCKS5")
+ private ProxyType proxyType;
+ @Metadata(label = "proxy")
+ private String proxyUsername;
+ @Metadata(label = "proxy")
+ private String proxyPassword;
+
@Metadata(label = "advanced")
private Vertx vertx;
@Metadata(label = "advanced")
@@ -53,7 +67,6 @@
private boolean useGlobalSslContextParameters;
@Metadata(label = "advanced")
private boolean allowJavaSerializedObject;
- private boolean managedVertx;
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
@@ -64,14 +77,27 @@
VertxHttpEndpoint endpoint = new VertxHttpEndpoint(uri, this, configuration);
setProperties(endpoint, parameters);
+ if (configuration.getProxyType() == null) {
+ configuration.setProxyType(getProxyType());
+ }
+ if (configuration.getProxyHost() == null) {
+ configuration.setProxyHost(getProxyHost());
+ }
+ if (configuration.getProxyPort() == null) {
+ configuration.setProxyPort(getProxyPort());
+ }
+ if (configuration.getProxyUsername() == null) {
+ configuration.setProxyUsername(getProxyUsername());
+ }
+ if (configuration.getProxyPassword() == null) {
+ configuration.setProxyPassword(getProxyPassword());
+ }
if (configuration.getSslContextParameters() == null) {
configuration.setSslContextParameters(retrieveGlobalSslContextParameters());
}
-
if (configuration.getVertxHttpBinding() == null) {
configuration.setVertxHttpBinding(getVertxHttpBinding());
}
-
if (configuration.getHeaderFilterStrategy() == null) {
configuration.setHeaderFilterStrategy(getHeaderFilterStrategy());
}
@@ -236,4 +262,60 @@
public void setAllowJavaSerializedObject(boolean allowJavaSerializedObject) {
this.allowJavaSerializedObject = allowJavaSerializedObject;
}
+
+ /**
+ * The proxy server host address
+ */
+ public void setProxyHost(String proxyHost) {
+ this.proxyHost = proxyHost;
+ }
+
+ public String getProxyHost() {
+ return proxyHost;
+ }
+
+ /**
+ * The proxy server port
+ */
+ public void setProxyPort(Integer proxyPort) {
+ this.proxyPort = proxyPort;
+ }
+
+ public Integer getProxyPort() {
+ return proxyPort;
+ }
+
+ /**
+ * The proxy server username if authentication is required
+ */
+ public void setProxyUsername(String proxyUsername) {
+ this.proxyUsername = proxyUsername;
+ }
+
+ public String getProxyUsername() {
+ return proxyUsername;
+ }
+
+ /**
+ * The proxy server password if authentication is required
+ */
+ public void setProxyPassword(String proxyPassword) {
+ this.proxyPassword = proxyPassword;
+ }
+
+ public String getProxyPassword() {
+ return proxyPassword;
+ }
+
+ /**
+ * The proxy server type
+ */
+ public void setProxyType(ProxyType proxyType) {
+ this.proxyType = proxyType;
+ }
+
+ public ProxyType getProxyType() {
+ return proxyType;
+ }
+
}
diff --git a/components/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpProxyServerTest.java b/components/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpProxyServerTest.java
index 67b3ae9..6572f43 100644
--- a/components/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpProxyServerTest.java
+++ b/components/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpProxyServerTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.vertx.http;
+import io.vertx.core.net.ProxyType;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.AvailablePortFinder;
@@ -35,6 +36,25 @@
assertEquals("Hello Proxied World", result);
}
+ @Test
+ public void testProxyComponent() {
+ VertxHttpComponent comp = context.getComponent("vertx-http", VertxHttpComponent.class);
+ comp.setProxyHost("localhost");
+ comp.setProxyPort(port2);
+ comp.setProxyUsername("foo");
+ comp.setProxyPassword("bar");
+ comp.setProxyType(ProxyType.HTTP);
+
+ String result = template.requestBody(getProducerUri(), null, String.class);
+ assertEquals("Hello Proxied World", result);
+
+ comp.setProxyHost(null);
+ comp.setProxyPort(null);
+ comp.setProxyUsername(null);
+ comp.setProxyPassword(null);
+ comp.setProxyType(null);
+ }
+
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/VertxHttpComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/VertxHttpComponentBuilderFactory.java
index 38f2aa1..1942b81 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/VertxHttpComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/VertxHttpComponentBuilderFactory.java
@@ -153,6 +153,64 @@
return this;
}
/**
+ * The proxy server host address.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: proxy
+ */
+ default VertxHttpComponentBuilder proxyHost(java.lang.String proxyHost) {
+ doSetProperty("proxyHost", proxyHost);
+ return this;
+ }
+ /**
+ * The proxy server password if authentication is required.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: proxy
+ */
+ default VertxHttpComponentBuilder proxyPassword(
+ java.lang.String proxyPassword) {
+ doSetProperty("proxyPassword", proxyPassword);
+ return this;
+ }
+ /**
+ * The proxy server port.
+ *
+ * The option is a: <code>java.lang.Integer</code> type.
+ *
+ * Group: proxy
+ */
+ default VertxHttpComponentBuilder proxyPort(java.lang.Integer proxyPort) {
+ doSetProperty("proxyPort", proxyPort);
+ return this;
+ }
+ /**
+ * The proxy server type.
+ *
+ * The option is a: <code>io.vertx.core.net.ProxyType</code> type.
+ *
+ * Group: proxy
+ */
+ default VertxHttpComponentBuilder proxyType(
+ io.vertx.core.net.ProxyType proxyType) {
+ doSetProperty("proxyType", proxyType);
+ return this;
+ }
+ /**
+ * The proxy server username if authentication is required.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: proxy
+ */
+ default VertxHttpComponentBuilder proxyUsername(
+ java.lang.String proxyUsername) {
+ doSetProperty("proxyUsername", proxyUsername);
+ return this;
+ }
+ /**
* Enable usage of global SSL context parameters.
*
* The option is a: <code>boolean</code> type.
@@ -189,6 +247,11 @@
case "vertxHttpBinding": ((VertxHttpComponent) component).setVertxHttpBinding((org.apache.camel.component.vertx.http.VertxHttpBinding) value); return true;
case "vertxOptions": ((VertxHttpComponent) component).setVertxOptions((io.vertx.core.VertxOptions) value); return true;
case "headerFilterStrategy": ((VertxHttpComponent) component).setHeaderFilterStrategy((org.apache.camel.spi.HeaderFilterStrategy) value); return true;
+ case "proxyHost": ((VertxHttpComponent) component).setProxyHost((java.lang.String) value); return true;
+ case "proxyPassword": ((VertxHttpComponent) component).setProxyPassword((java.lang.String) value); return true;
+ case "proxyPort": ((VertxHttpComponent) component).setProxyPort((java.lang.Integer) value); return true;
+ case "proxyType": ((VertxHttpComponent) component).setProxyType((io.vertx.core.net.ProxyType) value); return true;
+ case "proxyUsername": ((VertxHttpComponent) component).setProxyUsername((java.lang.String) value); return true;
case "useGlobalSslContextParameters": ((VertxHttpComponent) component).setUseGlobalSslContextParameters((boolean) value); return true;
default: return false;
}