camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r833350 - in /camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http: BasicAuthenticationHttpClientConfigurer.java HttpComponent.java ProxyHttpClientConfigurer.java
Date Fri, 06 Nov 2009 11:24:26 GMT
Author: ningjiang
Date: Fri Nov  6 11:24:26 2009
New Revision: 833350

URL: http://svn.apache.org/viewvc?rev=833350&view=rev
Log:
CAMEL-2138 quick fix the NTCredential, and introduce host ,and proxyNtHost options for the
NTCredential

Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java?rev=833350&r1=833349&r2=833350&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
Fri Nov  6 11:24:26 2009
@@ -19,21 +19,29 @@
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 
 public class BasicAuthenticationHttpClientConfigurer implements HttpClientConfigurer {
     private final String username;
     private final String password;
     private final String domain;
+    private final String host;
     
-    public BasicAuthenticationHttpClientConfigurer(String user, String pwd, String domain)
{
+    public BasicAuthenticationHttpClientConfigurer(String user, String pwd, String domain,
String host) {
         username = user;
         password = pwd;
         this.domain = domain;
+        this.host = host;
     }
 
     public void configureHttpClient(HttpClient client) {
-        Credentials defaultcreds = new NTCredentials(username, password, null, domain);
+        Credentials defaultcreds;
+        if (domain != null) {
+            defaultcreds = new NTCredentials(username, password, host, domain);
+        } else {
+            defaultcreds = new UsernamePasswordCredentials(username, password);
+        }
         client.getState().setCredentials(AuthScope.ANY, defaultcreds);
     }
 

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java?rev=833350&r1=833349&r2=833350&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
Fri Nov  6 11:24:26 2009
@@ -83,25 +83,27 @@
         String username = getAndRemoveParameter(parameters, "username", String.class);
         String password = getAndRemoveParameter(parameters, "password", String.class);
         String domain = getAndRemoveParameter(parameters, "domain", String.class);
+        String host = getAndRemoveParameter(parameters, "host", String.class);
         if (username != null && password != null) {
             httpClientConfigurer = CompositeHttpConfigurer.combineConfigurers(
                 httpClientConfigurer, 
-                new BasicAuthenticationHttpClientConfigurer(username, password, domain));
+                new BasicAuthenticationHttpClientConfigurer(username, password, domain, host));
         }
         
         // check the proxy details for proxy configuration
-        String host = getAndRemoveParameter(parameters, "proxyHost", String.class);
-        Integer port = getAndRemoveParameter(parameters, "proxyPort", Integer.class);
-        if (host != null && port != null) {
+        String proxyHost = getAndRemoveParameter(parameters, "proxyHost", String.class);
+        Integer proxyPort = getAndRemoveParameter(parameters, "proxyPort", Integer.class);
+        if (proxyHost != null && proxyPort != null) {
             String proxyUsername = getAndRemoveParameter(parameters, "proxyUsername", String.class);
             String proxyPassword = getAndRemoveParameter(parameters, "proxyPassword", String.class);
             String proxyDomain = getAndRemoveParameter(parameters, "proxyDomain", String.class);
+            String proxyNtHost = getAndRemoveParameter(parameters, "proxyNtHost", String.class);
             if (proxyUsername != null && proxyPassword != null) {
                 httpClientConfigurer = CompositeHttpConfigurer.combineConfigurers(
-                    httpClientConfigurer, new ProxyHttpClientConfigurer(host, port, proxyUsername,
proxyPassword, proxyDomain));
+                    httpClientConfigurer, new ProxyHttpClientConfigurer(proxyHost, proxyPort,
proxyUsername, proxyPassword, proxyDomain, proxyNtHost));
             } else {
                 httpClientConfigurer = CompositeHttpConfigurer.combineConfigurers(
-                    httpClientConfigurer, new ProxyHttpClientConfigurer(host, port));
+                    httpClientConfigurer, new ProxyHttpClientConfigurer(proxyHost, proxyPort));
             }
         }
         

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java?rev=833350&r1=833349&r2=833350&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
Fri Nov  6 11:24:26 2009
@@ -19,6 +19,7 @@
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 
 /**
@@ -34,24 +35,31 @@
     private final String username;
     private final String password;
     private final String domain;
+    private final String ntHost;
     
     public ProxyHttpClientConfigurer(String host, Integer port) {
-        this(host, port, null, null, null);
+        this(host, port, null, null, null, null);
     }
     
-    public ProxyHttpClientConfigurer(String host, Integer port, String username, String password,
String domain) {
+    public ProxyHttpClientConfigurer(String host, Integer port, String username, String password,
String domain, String ntHost) {
         this.host = host;
         this.port = port;
         this.username = username;
         this.password = password;
         this.domain = domain;
+        this.ntHost = ntHost;
     }
 
     public void configureHttpClient(HttpClient client) {
         client.getHostConfiguration().setProxy(host, port);
 
         if (username != null && password != null) {
-            Credentials defaultcreds = new NTCredentials(username, password, null, domain);
+            Credentials defaultcreds;        
+            if (domain != null) {
+                defaultcreds = new NTCredentials(username, password, ntHost, domain);
+            } else {
+                defaultcreds = new UsernamePasswordCredentials(username, password);
+            }
             client.getState().setProxyCredentials(AuthScope.ANY, defaultcreds);
         }
     }



Mime
View raw message