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

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

commit f05d366bddf66d752ddb672441fa1a75a86f4438
Author: Colm O hEigeartaigh <[email protected]>
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)
---
 .../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 917217e..83ff2f5 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
@@ -71,18 +71,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 2295008..c2cdb48 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
@@ -70,6 +70,7 @@ public class WSS4JStaxOutInterceptor extends 
AbstractWSS4JStaxInterceptor {
     
     public WSS4JStaxOutInterceptor(WSSSecurityProperties securityProperties) {
         super(securityProperties);
+        WSSec.init();
         setPhase(Phase.PRE_STREAM);
         getBefore().add(StaxOutInterceptor.class.getName());
         
@@ -78,6 +79,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());
@@ -86,6 +88,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 614b82c..f881788 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
@@ -104,6 +104,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
"[email protected]" <[email protected]>.

Reply via email to