You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/03 05:05:18 UTC

svn commit: r730903 - in /activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http: BasicAuthenticationHttpClientConfigurer.java HttpComponent.java

Author: ningjiang
Date: Fri Jan  2 20:05:17 2009
New Revision: 730903

URL: http://svn.apache.org/viewvc?rev=730903&view=rev
Log:
CAMEL-1214 Did a quick fix for basic authentication of camel-http 

Added:
    activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java   (with props)
Modified:
    activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java

Added: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java?rev=730903&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java (added)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java Fri Jan  2 20:05:17 2009
@@ -0,0 +1,24 @@
+package org.apache.camel.component.http;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+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;
+    
+    public BasicAuthenticationHttpClientConfigurer(String user, String pwd) {
+        username = user;
+        password = pwd;
+    }
+
+    public void configureHttpClient(HttpClient client) {
+        
+        Credentials defaultcreds = new UsernamePasswordCredentials(username, password);
+        client.getState().setCredentials(AuthScope.ANY, defaultcreds);
+
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java?rev=730903&r1=730902&r2=730903&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java Fri Jan  2 20:05:17 2009
@@ -78,6 +78,12 @@
         if (ref != null) {
             httpBinding = CamelContextHelper.mandatoryLookup(getCamelContext(), ref, HttpBinding.class);
         }
+        
+        // lookup http client front configurer in the registry if provided
+        ref = getAndRemoveParameter(parameters, "httpClientConfigurerRef", String.class);
+        if (ref != null) {
+            httpClientConfigurer = CamelContextHelper.mandatoryLookup(getCamelContext(), ref, HttpClientConfigurer.class);
+        }
 
         // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
         URI httpUri = URISupport.createRemainingURI(new URI(uri), parameters);