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 2014/01/22 04:47:58 UTC

[2/2] git commit: CAMEL-7145 Added username, password options on cxf endpoint for basic authentication

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

Conflicts:
	components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java


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

Branch: refs/heads/camel-2.11.x
Commit: 91949901ac5f9d0a38efcc96234132a84d42e29b
Parents: 9f41897
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Jan 22 11:29:10 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Jan 22 11:47:22 2014 +0800

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


http://git-wip-us.apache.org/repos/asf/camel/blob/91949901/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 7003723..cd434c5 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
@@ -66,6 +66,7 @@ import org.apache.cxf.common.classloader.ClassLoaderUtils;
 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.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Client;
@@ -162,6 +163,9 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy
     private ReflectionServiceFactoryBean serviceFactoryBean;
     private CxfEndpointConfigurer configurer;
     
+    // basic authentication option for the CXF client
+    private String username;
+    private String password;
 
     public CxfEndpoint(String remaining, CxfComponent cxfComponent) {
         super(remaining, cxfComponent);
@@ -495,6 +499,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>());                
@@ -900,6 +912,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