Updated Branches:
  refs/heads/master 36791535e -> 9bedde2ca

CAMEL-7145 Added username, password options on cxf endpoint for basic 
authentication


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

Branch: refs/heads/master
Commit: 9bedde2cab8f605cda218a6a783ce14568661e38
Parents: 3679153
Author: Willem Jiang <[email protected]>
Authored: Wed Jan 22 11:29:10 2014 +0800
Committer: Willem Jiang <[email protected]>
Committed: Wed Jan 22 11:29:10 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfEndpoint.java | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9bedde2c/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index 4a07943..00adf1d 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -69,6 +69,7 @@ import org.apache.cxf.common.injection.ResourceInjector;
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.common.util.ReflectionUtil;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Client;
@@ -158,6 +159,9 @@ public class CxfEndpoint extends DefaultEndpoint implements 
HeaderFilterStrategy
     private Object serviceFactoryBean;
     private CxfEndpointConfigurer configurer;
     
+    // basic authentication option for the CXF client
+    private String username;
+    private String password;
 
     public CxfEndpoint() {
     }
@@ -497,6 +501,14 @@ public class CxfEndpoint extends DefaultEndpoint 
implements HeaderFilterStrategy
             LOG.debug("ClientFactoryBean: {} added properties: {}", 
factoryBean, getProperties());
         }
         
+        // setup the basic authentication property
+        if (ObjectHelper.isNotEmpty(username)) {
+            AuthorizationPolicy authPolicy = new AuthorizationPolicy();
+            authPolicy.setUserName(username);
+            authPolicy.setPassword(password);
+            
factoryBean.getProperties().put(AuthorizationPolicy.class.getName(), 
authPolicy);
+        }
+        
         if (this.isSkipPayloadMessagePartCheck()) {
             if (factoryBean.getProperties() == null) {
                 factoryBean.setProperties(new HashMap<String, Object>());      
          
@@ -929,6 +941,22 @@ public class CxfEndpoint extends DefaultEndpoint 
implements HeaderFilterStrategy
     public boolean isMtomEnabled() {
         return mtomEnabled;
     }
+    
+    public String getPassword() {
+        return password;
+    }
+    
+    public void setPassword(String password) {
+        this.password = password;
+    }
+    
+    public String getUsername() {
+        return username;
+    }
+    
+    public void setUsername(String username) {
+        this.username = username;
+    }
 
     /**
      * We need to override the {@link ClientImpl#setParameters} method

Reply via email to