ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1153119 - /webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/OpenSAMLUtil.java
Date Tue, 02 Aug 2011 13:35:20 GMT
Author: dkulp
Date: Tue Aug  2 13:35:20 2011
New Revision: 1153119

URL: http://svn.apache.org/viewvc?rev=1153119&view=rev
Log:
In some cases, the doc can be null.  Make sure we allow that.

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=1153119&r1=1153118&r2=1153119&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
Tue Aug  2 13:35:20 2011
@@ -101,13 +101,17 @@ public class OpenSAMLUtil {
     ) throws WSSecurityException {
         Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
         Element element = null;
-        Element orig = doc.getDocumentElement();
+        Element orig = doc == null ? null : doc.getDocumentElement();
         try {
             if (orig != null) {
                 doc.removeChild(orig);
             }
             try {
-                element = marshaller.marshall(xmlObject, doc);
+                if (doc == null) {
+                    element = marshaller.marshall(xmlObject);
+                } else {
+                    element = marshaller.marshall(xmlObject, doc);
+                } 
             } catch (MarshallingException ex) {
                 throw new WSSecurityException("Error marshalling a SAML assertion", ex);
             }
@@ -143,7 +147,7 @@ public class OpenSAMLUtil {
                 }
             }
         } finally {
-            if (doc.getDocumentElement() != orig) {
+            if (doc != null && doc.getDocumentElement() != orig) {
                 if (doc.getDocumentElement() != null) {
                     doc.removeChild(doc.getDocumentElement());
                 }



Mime
View raw message