You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/11/07 20:48:15 UTC

[cxf] 01/03: CXF-7551 - Policy Based WSS4J Stax Interceptors may not be correctly initialized

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 48a6bb802822500435f7f9645505a0788b662083
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Nov 7 17:03:50 2017 +0000

    CXF-7551 - Policy Based WSS4J Stax Interceptors may not be correctly initialized
    
    (cherry picked from commit 0161dd80785bc79d9c6df77f9bb8b512f879f480)
    (cherry picked from commit f05d366bddf66d752ddb672441fa1a75a86f4438)
---
 .../ws/security/wss4j/WSS4JStaxInInterceptor.java  |  3 ++
 .../ws/security/wss4j/WSS4JStaxOutInterceptor.java |  3 ++
 .../org/apache/cxf/systest/ws/fault/FaultTest.java | 36 ++++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
index 74489ed..348ca8b 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
@@ -76,18 +76,21 @@ public class WSS4JStaxInInterceptor extends AbstractWSS4JStaxInterceptor {
     
     public WSS4JStaxInInterceptor(WSSSecurityProperties securityProperties) {
         super(securityProperties);
+        WSSec.init();
         setPhase(Phase.POST_STREAM);
         getAfter().add(StaxInInterceptor.class.getName());
     }
     
     public WSS4JStaxInInterceptor(Map<String, Object> props) {
         super(props);
+        WSSec.init();
         setPhase(Phase.POST_STREAM);
         getAfter().add(StaxInInterceptor.class.getName());
     }
     
     public WSS4JStaxInInterceptor() {
         super();
+        WSSec.init();
         setPhase(Phase.POST_STREAM);
         getAfter().add(StaxInInterceptor.class.getName());
     }
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxOutInterceptor.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxOutInterceptor.java
index 84930bd..8ab8419 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxOutInterceptor.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxOutInterceptor.java
@@ -68,6 +68,7 @@ public class WSS4JStaxOutInterceptor extends AbstractWSS4JStaxInterceptor {
     
     public WSS4JStaxOutInterceptor(WSSSecurityProperties securityProperties) {
         super(securityProperties);
+        WSSec.init();
         setPhase(Phase.PRE_STREAM);
         getBefore().add(StaxOutInterceptor.class.getName());
         
@@ -76,6 +77,7 @@ public class WSS4JStaxOutInterceptor extends AbstractWSS4JStaxInterceptor {
 
     public WSS4JStaxOutInterceptor(Map<String, Object> props) {
         super(props);
+        WSSec.init();
         setPhase(Phase.PRE_STREAM);
         getBefore().add(StaxOutInterceptor.class.getName());
         getAfter().add(LoggingOutInterceptor.class.getName());
@@ -84,6 +86,7 @@ public class WSS4JStaxOutInterceptor extends AbstractWSS4JStaxInterceptor {
     
     public WSS4JStaxOutInterceptor() {
         super();
+        WSSec.init();
         setPhase(Phase.PRE_STREAM);
         getBefore().add(StaxOutInterceptor.class.getName());
         getAfter().add(LoggingOutInterceptor.class.getName());
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
index 6615a12..579eeb9 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
@@ -103,6 +103,42 @@ public class FaultTest extends AbstractBusClientServerTestBase {
     }
     
     @org.junit.Test
+    public void testSoap11StAX() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = FaultTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        BusFactory.setDefaultBus(bus);
+        BusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItSoap11Port");
+        DoubleItPortType utPort =
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(utPort, PORT);
+
+        // Make a successful invocation
+        SecurityTestUtil.enableStreaming(utPort);
+        ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
+        utPort.doubleIt(25);
+/*
+        // Now make an invocation using another username
+        ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob");
+        ((BindingProvider)utPort).getRequestContext().put("security.password", "password");
+        try {
+            utPort.doubleIt(25);
+            fail("Expected failure on bob");
+        } catch (Exception ex) {
+            assertTrue(ex.getMessage().contains("This is a fault"));
+        }
+*/
+        ((java.io.Closeable)utPort).close();
+        bus.shutdown(true);
+    }
+
+    @org.junit.Test
     public void testSoap12() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = FaultTest.class.getResource("client.xml");

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.