You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/11/19 06:32:53 UTC

svn commit: r718859 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/interceptors/ test/java/org/apache/servicemix/cxfbc/ws/security/ test/resources/org/apache/servicemix/cxfbc/ws/security/

Author: ffang
Date: Tue Nov 18 21:32:52 2008
New Revision: 718859

URL: http://svn.apache.org/viewvc?rev=718859&view=rev
Log:
[SM-1696]cxf bc with ws-security can't work with enable JDBCAuditor

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBCSecurityTest.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean.xml

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java?rev=718859&r1=718858&r2=718859&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java Tue Nov 18 21:32:52 2008
@@ -28,6 +28,7 @@
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -169,8 +170,20 @@
             message = (SoapMessage) soapMessage;
         }
         Map<String, Object> headers = new HashMap<String, Object>();
+        QName excludeName = new QName(
+                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+                "Security");
         for (Header header : message.getHeaders()) {
-            headers.put(QNameUtil.toString(header.getName()), header.getObject());
+            if (!header.getName().equals(excludeName)) {
+                // We must exclude this security header since in Sun's SAAJ impl, the ElementImpl
+                // has a field which doesn't implement Serializable interface, which will cause
+                //java.io.NotSerializableException when we try to serialize the JBI message.
+                // And this security header isn't necessary inside jbi container since we have already
+                // delegate the AA to JAAS at this stage.
+                // SM-1696 track this issue
+                headers.put(QNameUtil.toString(header.getName()), header
+                    .getObject());
+            }
         }
 
         normalizedMessage.setProperty(CxfJbiConstants.PROTOCOL_HEADERS, headers);

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBCSecurityTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBCSecurityTest.java?rev=718859&r1=718858&r2=718859&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBCSecurityTest.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBCSecurityTest.java Tue Nov 18 21:32:52 2008
@@ -16,6 +16,9 @@
  */
 package org.apache.servicemix.cxfbc.ws.security;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
@@ -24,16 +27,21 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.testutil.common.ServerLauncher;
 import org.apache.hello_world_soap_http.Greeter;
+import org.apache.servicemix.cxfbc.EmbededJMSBrokerLauncher;
 import org.apache.servicemix.tck.SpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
 public class CxfBCSecurityTest extends SpringTestSupport {
 
+    protected static boolean serversStarted;
     private static final Logger LOG = LogUtils.getL7dLogger(CxfBCSecurityTest.class);
-    
     private static final java.net.URL WSDL_LOC;
+       
+    private ServerLauncher sl;
+    private ServerLauncher embeddedLauncher;
     static {
         java.net.URL tmp = null;
         try {
@@ -46,6 +54,57 @@
         WSDL_LOC = tmp;
     }
     
+    public void startServers() throws Exception {
+        if (serversStarted) {
+            return;
+        }
+        Map<String, String> props = new HashMap<String, String>();                
+        if (System.getProperty("activemq.store.dir") != null) {
+            props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
+        }
+        props.put("java.util.logging.config.file", 
+                  System.getProperty("java.util.logging.config.file"));
+        
+        assertTrue("server did not launch correctly", 
+                   launchServer(EmbededJMSBrokerLauncher.class, props, false));
+        embeddedLauncher =  sl;
+        
+        
+        serversStarted = true;
+    }
+    
+    protected void setUp() throws Exception {
+        startServers();
+        super.setUp();
+            
+    }
+    
+    protected void tearDown() throws Exception {
+        try {
+            embeddedLauncher.stopServer();         
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to stop server " + embeddedLauncher.getClass());
+        }
+        
+        serversStarted = false;
+    }
+    
+    public boolean launchServer(Class<?> clz, Map<String, String> p, boolean inProcess) {
+        boolean ok = false;
+        try { 
+            sl = new ServerLauncher(clz.getName(), p, null, inProcess);
+            ok = sl.launchServer();
+            assertTrue("server failed to launch", ok);
+            
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to launch server " + clz);
+        }
+        
+        return ok;
+    }
+    
     public void testTimestampSignEncrypt() {
         LOG.info("test security");
         Bus bus = new SpringBusFactory().createBus(

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean.xml?rev=718859&r1=718858&r2=718859&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean.xml (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean.xml Tue Nov 18 21:32:52 2008
@@ -22,7 +22,7 @@
        xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
        xmlns:greeter="http://apache.org/hello_world_soap_http">
   
-  <sm:container id="jbi" embedded="true">
+  <sm:container id="jbi" embedded="true" flowNames="jms?jmsURL=tcp://localhost:61616">
     
     <sm:endpoints>
       <cxfse:endpoint>