cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: [CXF-6900] More SAAJ fixes
Date Tue, 17 May 2016 17:34:17 GMT
Repository: cxf
Updated Branches:
  refs/heads/master cf8ac102e -> 2538ae42f


[CXF-6900] More SAAJ fixes


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

Branch: refs/heads/master
Commit: 2538ae42fb0c774023deed5264291b2fe6658cb8
Parents: cf8ac10
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue May 17 13:26:31 2016 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue May 17 13:26:31 2016 -0400

----------------------------------------------------------------------
 .../apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java   |  2 +-
 .../apache/cxf/binding/soap/saaj/SAAJStreamWriter.java    | 10 ++++++++++
 .../cxf/ws/security/wss4j/AbstractPolicySecurityTest.java |  5 ++---
 .../cxf/ws/security/wss4j/AbstractSecurityTest.java       |  8 ++++----
 .../cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java  |  3 +++
 5 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/2538ae42/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 74de7a3..d30bf4f 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
@@ -38,9 +38,9 @@ import org.apache.cxf.common.util.StringUtils;
  * location, it will just walk into it instead of creating a new element
  */
 public class OverlayW3CDOMStreamWriter extends W3CDOMStreamWriter {
+    protected boolean isOverlaid = true;
 
     List<Boolean> isOverlaidStack = new LinkedList<Boolean>();
-    boolean isOverlaid = true;
     Boolean textOverlay;
     
     public OverlayW3CDOMStreamWriter(Document document) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/2538ae42/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 d29276c..393a553 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
@@ -40,6 +40,10 @@ public final class SAAJStreamWriter extends OverlayW3CDOMStreamWriter {
     public SAAJStreamWriter(SOAPPart part) {
         super(part);
         this.part = part;
+        Node nd = part.getFirstChild();
+        if (nd == null) {
+            isOverlaid = false;
+        }
     }
     public SAAJStreamWriter(SOAPPart part, Element current) {
         super(part, current);
@@ -69,8 +73,14 @@ public final class SAAJStreamWriter extends OverlayW3CDOMStreamWriter {
                 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());
                     return;
                 } else if ("Body".equals(local)) {
+                    if (part.getEnvelope().getBody() == null) {
+                        part.getEnvelope().addBody();
+                    }
                     setChild(adjustPrefix(part.getEnvelope().getBody(), prefix), false);
                     return;
                 } else if ("Header".equals(local)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/2538ae42/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
index 5702b5e..b627081 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
@@ -30,7 +30,6 @@ import java.util.concurrent.Executor;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.soap.Node;
-import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
@@ -405,7 +404,7 @@ public abstract class AbstractPolicySecurityTest extends AbstractSecurityTest
{
      * @see #getSoapMessageForDom(Document, AssertionInfoMap)
      */
     protected SoapMessage getOutSoapMessageForDom(Document doc, AssertionInfoMap aim)
-        throws SOAPException {
+        throws Exception {
         SoapMessage msg = this.getSoapMessageForDom(doc, aim);
         msg.put(SecurityConstants.SIGNATURE_PROPERTIES, "outsecurity.properties");
         msg.put(SecurityConstants.ENCRYPT_PROPERTIES, "outsecurity.properties");
@@ -421,7 +420,7 @@ public abstract class AbstractPolicySecurityTest extends AbstractSecurityTest
{
     }
     
     protected SoapMessage getSoapMessageForDom(Document doc, AssertionInfoMap aim)
-        throws SOAPException {
+        throws Exception {
         
         SoapMessage msg = this.getSoapMessageForDom(doc);
         if (aim != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/2538ae42/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
index e5e531d..38bc2be 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
@@ -32,17 +32,16 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.dom.DOMSource;
 
 import org.w3c.dom.Document;
 
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.saaj.SAAJStreamWriter;
 import org.apache.cxf.helpers.DOMUtils.NullResolver;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -81,10 +80,11 @@ public abstract class AbstractSecurityTest extends AbstractCXFTest {
      * Creates a {@link SoapMessage} from the contents of a document.
      * @param doc the document containing the SOAP content.
      */
-    protected SoapMessage getSoapMessageForDom(Document doc) throws SOAPException {
+    protected SoapMessage getSoapMessageForDom(Document doc) throws Exception {
         SOAPMessage saajMsg = MessageFactory.newInstance().createMessage();
         SOAPPart part = saajMsg.getSOAPPart();
-        part.setContent(new DOMSource(doc));
+        SAAJStreamWriter writer = new SAAJStreamWriter(part);
+        StaxUtils.copy(doc, writer);
         saajMsg.saveChanges();
 
         MessageImpl message = new MessageImpl();

http://git-wip-us.apache.org/repos/asf/cxf/blob/2538ae42/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
index 71e7bb3..879ec0d 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageCheckerTest.java
@@ -27,6 +27,8 @@ import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import javax.xml.soap.SOAPMessage;
+
 import org.w3c.dom.Document;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
@@ -37,6 +39,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptor;
 import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.ws.security.wss4j.CryptoCoverageChecker.XPathExpression;
 import org.apache.cxf.ws.security.wss4j.CryptoCoverageUtil.CoverageScope;
 import org.apache.cxf.ws.security.wss4j.CryptoCoverageUtil.CoverageType;


Mime
View raw message