cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [07/14] cxf git commit: Updates to get the transformation stuff to workaround all the bugs/junk in SAAJ for the faults
Date Mon, 25 Jul 2016 15:30:41 GMT
Updates to get the transformation stuff to workaround all the bugs/junk in SAAJ for the faults

# Conflicts:
#	rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/StaxSerializer.java
#	rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java


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

Branch: refs/heads/3.0.x-fixes
Commit: c372fb70c18f63cb17cef66a962e4ab90ee89875
Parents: 8cd54b2
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri May 20 11:31:00 2016 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Mon Jul 25 10:19:34 2016 -0400

----------------------------------------------------------------------
 .../staxutils/OverlayW3CDOMStreamWriter.java    |  6 ++
 .../cxf/staxutils/W3CDOMStreamWriter.java       |  4 +
 .../cxf/binding/soap/saaj/SAAJStreamWriter.java | 78 ++++++++++++++------
 .../ws/security/wss4j/WSS4JFaultCodeTest.java   |  2 +
 4 files changed, 69 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c372fb70/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java b/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
index d30bf4f..475973a 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
@@ -25,6 +25,7 @@ import java.util.List;
 import javax.xml.stream.XMLStreamException;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
@@ -53,6 +54,11 @@ public class OverlayW3CDOMStreamWriter extends W3CDOMStreamWriter {
     public OverlayW3CDOMStreamWriter(Document doc, Element e) {
         super(doc, e);
     }
+    public OverlayW3CDOMStreamWriter(Document doc, DocumentFragment frag) {
+        super(doc, frag);
+        isOverlaid = false;
+    }
+
 
     @Override
     protected void createAndAddElement(String prefix, String local, String namespace) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/c372fb70/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
index 6903c4c..353da70 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
@@ -60,6 +60,10 @@ public class W3CDOMStreamWriter implements XMLStreamWriter {
         this.document = frag.getOwnerDocument();
         currentNode = frag;
     }
+    public W3CDOMStreamWriter(Document document, DocumentFragment frag) {
+        this.document = document;
+        currentNode = frag;
+    }
 
     public W3CDOMStreamWriter(Element e) {
         this.document = e.getOwnerDocument();

http://git-wip-us.apache.org/repos/asf/cxf/blob/c372fb70/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
index 393a553..185079b 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
@@ -21,11 +21,13 @@ package org.apache.cxf.binding.soap.saaj;
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPPart;
 
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -36,7 +38,10 @@ import static org.apache.cxf.binding.soap.saaj.SAAJUtils.adjustPrefix;
 
 public final class SAAJStreamWriter extends OverlayW3CDOMStreamWriter {
     private final SOAPPart part;
-
+    private final SOAPEnvelope envelope;
+    private String uri;
+    
+    
     public SAAJStreamWriter(SOAPPart part) {
         super(part);
         this.part = part;
@@ -44,20 +49,47 @@ public final class SAAJStreamWriter extends OverlayW3CDOMStreamWriter
{
         if (nd == null) {
             isOverlaid = false;
         }
+        envelope = null;
     }
     public SAAJStreamWriter(SOAPPart part, Element current) {
         super(part, current);
         this.part = part;
+        envelope = null;
     }
-
+    public SAAJStreamWriter(SOAPEnvelope env, DocumentFragment frag) {
+        super(env.getOwnerDocument(), frag);
+        this.part = null;
+        this.envelope = env;
+        isOverlaid = false;
+    }
+    public SAAJStreamWriter(SOAPEnvelope env, Element cur) {
+        super(env.getOwnerDocument(), cur);
+        this.part = null;
+        this.envelope = env;
+        isOverlaid = false;
+    }
+    
+    private String getEnvelopeURI() throws SOAPException {
+        if (uri == null) {
+            uri = getEnvelope().getElementName().getURI();
+        }
+        return uri;
+    }
+    private SOAPEnvelope getEnvelope() throws SOAPException {
+        if (envelope == null) {
+            return part.getEnvelope();
+        }
+        return envelope;
+    }
+    
     protected void adjustOverlaidNode(Node nd2, String pfx) {
         String namespace = nd2.getNamespaceURI();
         try {
             if (namespace != null 
-                && namespace.equals(part.getEnvelope().getElementName().getURI()))
{
+                && namespace.equals(getEnvelopeURI())) {
                 adjustPrefix((SOAPElement)nd2, pfx);
                 if ("Envelope".equals(nd2.getLocalName())) {
-                    adjustPrefix(part.getEnvelope().getHeader(), pfx);
+                    adjustPrefix(getEnvelope().getHeader(), pfx);
                 }
             }
         } catch (SOAPException e) {
@@ -67,37 +99,41 @@ public final class SAAJStreamWriter extends OverlayW3CDOMStreamWriter
{
     }
     
     protected void createAndAddElement(String prefix, String local, String namespace) {
+        if (part == null) {
+            super.createAndAddElement(prefix, local, namespace);
+            return;
+        }
         try {
             if (namespace != null 
-                && namespace.equals(part.getEnvelope().getElementName().getURI()))
{
+                && namespace.equals(getEnvelopeURI())) {
                 if ("Envelope".equals(local)) {
-                    setChild(adjustPrefix(part.getEnvelope(), prefix), false);
-                    adjustPrefix(part.getEnvelope().getHeader(), prefix);
-                    adjustPrefix(part.getEnvelope().getBody(), prefix);
-                    part.getEnvelope().removeChild(part.getEnvelope().getHeader());
-                    part.getEnvelope().removeChild(part.getEnvelope().getBody());
+                    setChild(adjustPrefix(getEnvelope(), prefix), false);
+                    adjustPrefix(getEnvelope().getHeader(), prefix);
+                    adjustPrefix(getEnvelope().getBody(), prefix);
+                    getEnvelope().removeChild(getEnvelope().getHeader());
+                    getEnvelope().removeChild(getEnvelope().getBody());
                     return;
                 } else if ("Body".equals(local)) {
-                    if (part.getEnvelope().getBody() == null) {
-                        part.getEnvelope().addBody();
+                    if (getEnvelope().getBody() == null) {
+                        getEnvelope().addBody();
                     }
-                    setChild(adjustPrefix(part.getEnvelope().getBody(), prefix), false);
+                    setChild(adjustPrefix(getEnvelope().getBody(), prefix), false);
                     return;
                 } else if ("Header".equals(local)) {
-                    if (part.getEnvelope().getHeader() == null) {
-                        part.getEnvelope().addHeader();
+                    if (getEnvelope().getHeader() == null) {
+                        getEnvelope().addHeader();
                     }
-                    setChild(adjustPrefix(part.getEnvelope().getHeader(), prefix), false);
+                    setChild(adjustPrefix(getEnvelope().getHeader(), prefix), false);
                     return;
                 } else if ("Fault".equals(local)) {
-                    SOAPFault f = part.getEnvelope().getBody().getFault();
+                    SOAPFault f = getEnvelope().getBody().getFault();
                     if (f == null) {
-                        Element el = part.createElementNS(namespace, 
+                        Element el = getDocument().createElementNS(namespace, 
                                              StringUtils.isEmpty(prefix) ? local : prefix
+ ":" + local);
-                        part.getEnvelope().getBody().appendChild(el);
-                        f = part.getEnvelope().getBody().getFault();
+                        getEnvelope().getBody().appendChild(el);
+                        f = getEnvelope().getBody().getFault();
                         if (f == null) {
-                            f = part.getEnvelope().getBody().addFault();
+                            f = getEnvelope().getBody().addFault();
                         }
                     }
                     setChild(adjustPrefix(f, prefix), false);

http://git-wip-us.apache.org/repos/asf/cxf/blob/c372fb70/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JFaultCodeTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JFaultCodeTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JFaultCodeTest.java
index bd1b526..1e443c7 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JFaultCodeTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JFaultCodeTest.java
@@ -264,6 +264,8 @@ public class WSS4JFaultCodeTest extends AbstractSecurityTest {
         
         try {
             inHandler.handleMessage(inmsg);
+            StaxUtils.print(saajMsg.getSOAPPart());
+            
             fail("Expected failure on a SOAP Fault");
         } catch (SoapFault fault) {
             fault.printStackTrace();


Mime
View raw message