ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1166873 - /webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java
Date Thu, 08 Sep 2011 19:38:11 GMT
Author: dkulp
Date: Thu Sep  8 19:38:11 2011
New Revision: 1166873

URL: http://svn.apache.org/viewvc?rev=1166873&view=rev
Log:
Restore all Document content, not just the element.

Modified:
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java?rev=1166873&r1=1166872&r2=1166873&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java
Thu Sep  8 19:38:11 2011
@@ -28,6 +28,7 @@ import org.opensaml.xml.signature.Signat
 import org.opensaml.xml.signature.SignatureException;
 import org.opensaml.xml.signature.Signer;
 import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 
 /**
@@ -101,10 +102,12 @@ public class OpenSAMLUtil {
     ) throws WSSecurityException {
         Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
         Element element = null;
-        Element orig = doc == null ? null : doc.getDocumentElement();
+        DocumentFragment frag = doc == null ? null : doc.createDocumentFragment();
         try {
-            if (orig != null) {
-                doc.removeChild(orig);
+            if (frag != null) {
+                while (doc.getFirstChild() != null) {
+                    frag.appendChild(doc.removeChild(doc.getFirstChild()));
+                }
             }
             try {
                 if (doc == null) {
@@ -147,13 +150,11 @@ public class OpenSAMLUtil {
                 }
             }
         } finally {
-            if (doc != null && doc.getDocumentElement() != orig) {
-                if (doc.getDocumentElement() != null) {
-                    doc.removeChild(doc.getDocumentElement());
-                }
-                if (orig != null) {
-                    doc.appendChild(orig);
+            if (frag != null) {
+                while (doc.getFirstChild() != null) {
+                    doc.removeChild(doc.getFirstChild());
                 }
+                doc.appendChild(frag);
             }
         }
         return element;



Mime
View raw message