ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1694031 - in /webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message: WSSecDKEncrypt.java WSSecEncrypt.java
Date Tue, 04 Aug 2015 10:57:56 GMT
Author: coheigea
Date: Tue Aug  4 10:57:55 2015
New Revision: 1694031

URL: http://svn.apache.org/r1694031
Log:
[WSS-549] - Don't write out a ReferenceList if there are no elements to encrypt

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java?rev=1694031&r1=1694030&r2=1694031&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
Tue Aug  4 10:57:55 2015
@@ -176,13 +176,15 @@ public class WSSecDKEncrypt extends WSSe
      * @param secHeader The security header.
      */
     public void addExternalRefElement(Element referenceList, WSSecHeader secHeader) {
-        Node node = getdktElement().getNextSibling();
-        if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
-            secHeader.getSecurityHeader().insertBefore(referenceList, node);
-        } else {
-            // If (at this moment) DerivedKeyToken is the LAST element of 
-            // the security header 
-            secHeader.getSecurityHeader().appendChild(referenceList);
+        if (referenceList != null) {
+            Node node = getdktElement().getNextSibling();
+            if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
+                secHeader.getSecurityHeader().insertBefore(referenceList, node);
+            } else {
+                // If (at this moment) DerivedKeyToken is the LAST element of 
+                // the security header 
+                secHeader.getSecurityHeader().appendChild(referenceList);
+            }
         }
     }
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java?rev=1694031&r1=1694030&r2=1694031&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
Tue Aug  4 10:57:55 2015
@@ -255,6 +255,10 @@ public class WSSecEncrypt extends WSSecE
                     callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
                     storeBytesInAttachment
             );
+        if (encDataRefs.isEmpty()) {
+            return null;
+        }
+        
         if (dataRef == null) {
             dataRef = 
                 document.createElementNS(
@@ -284,7 +288,9 @@ public class WSSecEncrypt extends WSSecE
      * @param dataRef The internal <code>enc:Reference</code> element
      */
     public void addInternalRefElement(Element dataRef) {
-        getEncryptedKeyElement().appendChild(dataRef);
+        if (dataRef != null) {
+            getEncryptedKeyElement().appendChild(dataRef);
+        }
     }
 
     /**
@@ -298,7 +304,9 @@ public class WSSecEncrypt extends WSSecE
      * @param secHeader The security header.
      */
     public void addExternalRefElement(Element dataRef, WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), dataRef);
+        if (dataRef != null) {
+            WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), dataRef);
+        }
     }
 
     public void addAttachmentEncryptedDataElements(WSSecHeader secHeader) {



Mime
View raw message