camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject [2/2] camel git commit: CAMEL-10588: Add HTTP proxy config params to camel-servicenow
Date Mon, 12 Dec 2016 16:31:10 GMT
CAMEL-10588: Add HTTP proxy config params to camel-servicenow


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5999fb22
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5999fb22
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5999fb22

Branch: refs/heads/master
Commit: 5999fb22336023e22e6c996215e0ac641257676d
Parents: 87898bf
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Mon Dec 12 15:18:00 2016 +0100
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Mon Dec 12 15:18:00 2016 +0100

----------------------------------------------------------------------
 .../ServiceNowComponentConfiguration.java       | 48 ++++++++++++++++++
 .../src/main/docs/servicenow-component.adoc     |  6 ++-
 .../component/servicenow/ServiceNowClient.java  | 45 +++++++++++++++++
 .../servicenow/ServiceNowConfiguration.java     | 52 ++++++++++++++++++++
 4 files changed, 150 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5999fb22/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java
b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java
index 24caf73..83809362 100644
--- a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java
+++ b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java
@@ -287,6 +287,22 @@ public class ServiceNowComponentConfiguration {
          */
         @NestedConfigurationProperty
         private ProxyAuthorizationPolicy proxyAuthorizationPolicy;
+        /**
+         * The proxy host name
+         */
+        private String proxyHost;
+        /**
+         * The proxy port number
+         */
+        private Integer proxyPort;
+        /**
+         * Username for proxy authentication
+         */
+        private String proxyUserName;
+        /**
+         * Password for proxy authentication
+         */
+        private String proxyPassword;
         private Map models;
         /**
          * Defines the response model
@@ -561,6 +577,38 @@ public class ServiceNowComponentConfiguration {
             this.proxyAuthorizationPolicy = proxyAuthorizationPolicy;
         }
 
+        public String getProxyHost() {
+            return proxyHost;
+        }
+
+        public void setProxyHost(String proxyHost) {
+            this.proxyHost = proxyHost;
+        }
+
+        public Integer getProxyPort() {
+            return proxyPort;
+        }
+
+        public void setProxyPort(Integer proxyPort) {
+            this.proxyPort = proxyPort;
+        }
+
+        public String getProxyUserName() {
+            return proxyUserName;
+        }
+
+        public void setProxyUserName(String proxyUserName) {
+            this.proxyUserName = proxyUserName;
+        }
+
+        public String getProxyPassword() {
+            return proxyPassword;
+        }
+
+        public void setProxyPassword(String proxyPassword) {
+            this.proxyPassword = proxyPassword;
+        }
+
         public Map getModels() {
             return models;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/5999fb22/components/camel-servicenow/src/main/docs/servicenow-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/docs/servicenow-component.adoc b/components/camel-servicenow/src/main/docs/servicenow-component.adoc
index ac87e0d..f122586 100644
--- a/components/camel-servicenow/src/main/docs/servicenow-component.adoc
+++ b/components/camel-servicenow/src/main/docs/servicenow-component.adoc
@@ -57,7 +57,7 @@ The ServiceNow component supports 7 options which are listed below.
 
 
 // endpoint options: START
-The ServiceNow component supports 37 endpoint options which are listed below:
+The ServiceNow component supports 41 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2,1,1m,1m,5",options="header"]
@@ -93,11 +93,15 @@ The ServiceNow component supports 37 endpoint options which are listed
below:
 | mapper | advanced |  | ObjectMapper | Sets Jackson's ObjectMapper to use for request/reply
 | proxyAuthorizationPolicy | advanced |  | ProxyAuthorizationPolicy | To configure proxy
authentication
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be
strictly used or Camel is allowed to use asynchronous processing (if supported).
+| proxyHost | proxy |  | String | The proxy host name
+| proxyPort | proxy |  | Integer | The proxy port number
 | apiUrl | security |  | String | The ServiceNow REST API url
 | oauthClientId | security |  | String | OAuth2 ClientID
 | oauthClientSecret | security |  | String | OAuth2 ClientSecret
 | oauthTokenUrl | security |  | String | OAuth token Url
 | password | security |  | String | ServiceNow account password MUST be provided
+| proxyPassword | security |  | String | Password for proxy authentication
+| proxyUserName | security |  | String | Username for proxy authentication
 | sslContextParameters | security |  | SSLContextParameters | To configure security using
SSLContextParameters. See http://camel.apache.org/camel-configuration-utilities.html
 | userName | security |  | String | ServiceNow user account name MUST be provided
 |=======================================================================

http://git-wip-us.apache.org/repos/asf/camel/blob/5999fb22/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
index 0d7fb5d..2bdd86a 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
@@ -29,8 +29,10 @@ import org.apache.camel.Message;
 import org.apache.camel.component.servicenow.auth.AuthenticationRequestFilter;
 import org.apache.camel.util.jsse.SSLContextParameters;
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 
 public final class ServiceNowClient {
     private final ServiceNowConfiguration configuration;
@@ -50,6 +52,8 @@ public final class ServiceNowClient {
 
         configureRequestContext(camelContext, configuration, client);
         configureTls(camelContext, configuration, client);
+        configureHttpClientPolicy(camelContext, configuration, client);
+        configureProxyAuthorizationPolicy(camelContext, configuration, client);
     }
 
     public ServiceNowClient types(MediaType type) {
@@ -174,4 +178,45 @@ public final class ServiceNowClient {
             conduit.setTlsClientParameters(tlsClientParams);
         }
     }
+
+    private static void configureHttpClientPolicy(
+            CamelContext context, ServiceNowConfiguration configuration, WebClient client)
throws Exception {
+
+        HTTPClientPolicy httpPolicy = configuration.getHttpClientPolicy();
+        if (httpPolicy == null) {
+            String host = configuration.getProxyHost();
+            Integer port = configuration.getProxyPort();
+
+            if (host != null && port != null) {
+                httpPolicy = new HTTPClientPolicy();
+                httpPolicy.setProxyServer(host);
+                httpPolicy.setProxyServerPort(port);
+            }
+        }
+
+        if (httpPolicy != null) {
+            WebClient.getConfig(client).getHttpConduit().setClient(httpPolicy);
+        }
+    }
+
+    private static void configureProxyAuthorizationPolicy(
+            CamelContext context, ServiceNowConfiguration configuration, WebClient client)
throws Exception {
+
+        ProxyAuthorizationPolicy proxyPolicy = configuration.getProxyAuthorizationPolicy();
+        if (proxyPolicy == null) {
+            String username = configuration.getProxyUserName();
+            String password = configuration.getProxyPassword();
+
+            if (username != null && password != null) {
+                proxyPolicy = new ProxyAuthorizationPolicy();
+                proxyPolicy.setAuthorizationType("Basic");
+                proxyPolicy.setUserName(username);
+                proxyPolicy.setPassword(password);
+            }
+        }
+
+        if (proxyPolicy != null) {
+            WebClient.getConfig(client).getHttpConduit().setProxyAuthorization(proxyPolicy);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5999fb22/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
index fe930e8..dd23df9 100644
--- a/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
+++ b/components/camel-servicenow/src/main/java/org/apache/camel/component/servicenow/ServiceNowConfiguration.java
@@ -111,6 +111,14 @@ public class ServiceNowConfiguration implements Cloneable {
     private HTTPClientPolicy httpClientPolicy;
     @UriParam(label = "advanced")
     private ProxyAuthorizationPolicy proxyAuthorizationPolicy;
+    @UriParam(label = "proxy")
+    private String proxyHost;
+    @UriParam(label = "proxy")
+    private Integer proxyPort;
+    @UriParam(label = "proxy,security")
+    private String proxyUserName;
+    @UriParam(label = "proxy,security")
+    private String proxyPassword;
 
     public String getUserName() {
         return userName;
@@ -515,6 +523,50 @@ public class ServiceNowConfiguration implements Cloneable {
         this.proxyAuthorizationPolicy = proxyAuthorizationPolicy;
     }
 
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    /**
+     * The proxy host name
+     */
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public Integer getProxyPort() {
+        return proxyPort;
+    }
+
+    /**
+     * The proxy port number
+     */
+    public void setProxyPort(Integer proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
+    public String getProxyUserName() {
+        return proxyUserName;
+    }
+
+    /**
+     * Username for proxy authentication
+     */
+    public void setProxyUserName(String proxyUserName) {
+        this.proxyUserName = proxyUserName;
+    }
+
+    public String getProxyPassword() {
+        return proxyPassword;
+    }
+
+    /**
+     * Password for proxy authentication
+     */
+    public void setProxyPassword(String proxyPassword) {
+        this.proxyPassword = proxyPassword;
+    }
+
     // *************************************************
     //
     // *************************************************


Mime
View raw message