servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r908886 - 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/
Date Thu, 11 Feb 2010 08:59:46 GMT
Author: ffang
Date: Thu Feb 11 08:59:28 2010
New Revision: 908886

URL: http://svn.apache.org/viewvc?rev=908886&view=rev
Log:
[SMXCOMP-711]JBIJAASInterceptor incorrectly positioned in interceptor chain when WS-SP support
enabled

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiJAASInterceptor.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
    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/JbiJAASInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiJAASInterceptor.java?rev=908886&r1=908885&r2=908886&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiJAASInterceptor.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiJAASInterceptor.java
Thu Feb 11 08:59:28 2010
@@ -28,6 +28,7 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.ws.security.wss4j.AbstractWSS4JInterceptor;
+import org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JInInterceptor;
 import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
 import org.apache.servicemix.common.security.AuthenticationService;
 import org.apache.ws.security.WSSecurityEngineResult;
@@ -49,6 +50,7 @@
         super();
         setPhase(Phase.PRE_PROTOCOL);
         getAfter().add(WSS4JInInterceptor.class.getName());
+        getAfter().add(PolicyBasedWSS4JInInterceptor.class.getName());
         this.authenticationService = authenticationService;
         this.x509 = x509;
         this.delegateToJaas = delegateToJaas;

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java?rev=908886&r1=908885&r2=908886&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
Thu Feb 11 08:59:28 2010
@@ -16,23 +16,30 @@
  */
 package org.apache.servicemix.cxfbc.ws.security;
 
+
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
+import junit.framework.TestCase;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 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.tck.SpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
 
-public class CxfBcSecurityJAASTest extends SpringTestSupport {
+public class CxfBcSecurityJAASTest extends TestCase {
 
     private static final Logger LOG = LogUtils.getL7dLogger(CxfBCSecurityTest.class);
     
@@ -57,6 +64,54 @@
         }
     }
     
+    
+    protected static boolean serversStarted;
+    private ServerLauncher sl;
+    
+    public void setUp() throws Exception {
+        startJBIContainers();
+        Thread.sleep(3000);
+    }
+    
+    public void tearDown() throws Exception {
+        try {
+            sl.stopServer();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to stop jbi container " + sl.getClass());
+        } 
+        serversStarted = false;
+        
+        super.tearDown();
+    }
+    
+    
+    
+    
+    public void testJAASPolicy() {
+        LOG.info("test security ws-policy");
+        Bus bus = new SpringBusFactory().createBus(
+                "org/apache/servicemix/cxfbc/ws/security/client-jaas.xml"); 
+        BusFactory.setDefaultBus(bus);
+        LoggingInInterceptor in = new LoggingInInterceptor();
+        bus.getInInterceptors().add(in);
+        bus.getInFaultInterceptors().add(in);
+        LoggingOutInterceptor out = new LoggingOutInterceptor();
+        bus.getOutInterceptors().add(out);
+        bus.getOutFaultInterceptors().add(out);
+        final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC,
+                new javax.xml.namespace.QName(
+                        "http://apache.org/hello_world_soap_http",
+                        "SOAPServiceWSSecurity"));
+        final Greeter greeter = svc.getPort(new javax.xml.namespace.QName(
+                "http://apache.org/hello_world_soap_http",
+                "TimestampSignEncryptPolicy"), Greeter.class);
+        String ret = greeter.sayHi();
+        assertEquals(ret, "Bonjour");
+        ret = greeter.greetMe("ffang");
+        assertEquals(ret, "Hello ffang");
+    }
+    
     public void testJAAS() {
         LOG.info("test security");
         Bus bus = new SpringBusFactory().createBus(
@@ -132,12 +187,54 @@
             assertEquals(e.getMessage(), "Password does not match");
         }
     }
-    
+    /***
     @Override
     protected AbstractXmlApplicationContext createBeanFactory() {
         // load cxf se and bc from spring config file
         return new ClassPathXmlApplicationContext(
             "org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml");
     }
+    **/
+    
+    protected void startJBIContainers() throws Exception {
+        if (serversStarted) {
+            return;
+        }
+        Map<String, String> props = new HashMap<String, String>();          
     
+        if (System.getProperty("javax.xml.transform.TransformerFactory") != null) {
+            props.put("javax.xml.transform.TransformerFactory", System.getProperty("javax.xml.transform.TransformerFactory"));
+        }
+        if (System.getProperty("javax.xml.stream.XMLInputFactory") != null) {
+            props.put("javax.xml.stream.XMLInputFactory", System.getProperty("javax.xml.stream.XMLInputFactory"));
+        }
+        if (System.getProperty("javax.xml.stream.XMLOutputFactory") != null) {
+            props.put("javax.xml.stream.XMLOutputFactory", System.getProperty("javax.xml.stream.XMLOutputFactory"));
+        }
+        if (System.getProperty("java.security.auth.login.config") != null) {
+            props.put("java.security.auth.login.config", System.getProperty("java.security.auth.login.config"));
+        }
+        
+        assertTrue("JBIContainers did not launch correctly", 
+                launchServer(JAASServer.class, props, true));
+       
+        
+        serversStarted = true;
+    }
+    
+    protected 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;
+    }
+    
 
 }

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml?rev=908886&r1=908885&r2=908886&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
Thu Feb 11 08:59:28 2010
@@ -38,6 +38,16 @@
             <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
         </jaxws:inInterceptors>
     </jaxws:client>
+    
+    <jaxws:client name="{http://apache.org/hello_world_soap_http}TimestampSignEncryptPolicy"
createdFromAPI="true">
+        <jaxws:features>
+            <bean class="org.apache.cxf.feature.LoggingFeature"/>
+        </jaxws:features>
+        <jaxws:outInterceptors>
+            <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+            <ref bean="TimestampSignEncrypt_Request"/>
+        </jaxws:outInterceptors>
+    </jaxws:client>
 
     <bean 
         class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl?rev=908886&r1=908885&r2=908886&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl
Thu Feb 11 08:59:28 2010
@@ -38,6 +38,11 @@
             binding="tns:Greeter_SOAPBinding">
             <soap:address location="http://localhost:19000/SOAPServiceWSSecurity/TimestampSignEncrypt"/>
         </wsdl:port>
+        <wsdl:port 
+            name="TimestampSignEncryptPolicy" 
+            binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:19000/SOAPServiceWSSecurity/TimestampSignEncryptPolicy"/>
+        </wsdl:port>
     </wsdl:service>
     <service name="HelloWorldService">
            <port binding="tns:Greeter_SOAPBinding" name="HelloWorldPort">

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml?rev=908886&r1=908885&r2=908886&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
Thu Feb 11 08:59:28 2010
@@ -54,10 +54,11 @@
         </cxfse:outFaultInterceptors>
       </cxfse:endpoint>
       <cxfbc:consumer wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
+                      service="greeter:SOAPServiceWSSecurity"
+                      endpoint="TimestampSignEncrypt"
                       targetEndpoint="TimestampSignEncrypt"
                       targetService="greeter:SOAPServiceWSSecurity"
-		      targetInterface="greeter:Greeter"
-                      >
+		              targetInterface="greeter:Greeter">
         <cxfbc:inInterceptors>
           <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
           <ref bean="TimestampSignEncrypt_Request"/>
@@ -75,6 +76,26 @@
           <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
         </cxfbc:outFaultInterceptors>
       </cxfbc:consumer>
+      <cxfbc:consumer wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
+                      service="greeter:SOAPServiceWSSecurity"
+                      endpoint="TimestampSignEncryptPolicy"
+                      targetEndpoint="TimestampSignEncrypt"
+                      targetService="greeter:SOAPServiceWSSecurity"
+                      targetInterface="greeter:Greeter"
+                      busCfg="org/apache/servicemix/cxfbc/ws/security/xbean-jaas-policy-bus-context.xml">
+        <cxfbc:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inInterceptors>
+        <cxfbc:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outInterceptors>
+        <cxfbc:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inFaultInterceptors>
+        <cxfbc:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outFaultInterceptors>
+      </cxfbc:consumer>
     </sm:endpoints>
     
   </sm:container>

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=908886&r1=908885&r2=908886&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
Thu Feb 11 08:59:28 2010
@@ -43,9 +43,11 @@
         </cxfse:outFaultInterceptors>
       </cxfse:endpoint>
       <cxfbc:consumer wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
+                      service="greeter:SOAPServiceWSSecurity"
+                      endpoint="TimestampSignEncrypt"
                       targetEndpoint="TimestampSignEncrypt"
                       targetService="greeter:SOAPServiceWSSecurity"
-		      targetInterface="greeter:Greeter"
+		              targetInterface="greeter:Greeter"
                       x509="false"
                       >
         <cxfbc:inInterceptors>



Mime
View raw message