You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/05/28 11:32:20 UTC
svn commit: r1682182 -
/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
Author: coheigea
Date: Thu May 28 09:32:20 2015
New Revision: 1682182
URL: http://svn.apache.org/r1682182
Log:
NPE fix for BinarySecurity
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java?rev=1682182&r1=1682181&r2=1682182&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java Thu May 28 09:32:20 2015
@@ -209,9 +209,25 @@ public class BinarySecurity {
*
* @return the first text node.
*/
- protected Text getFirstNode() {
+ private Text getFirstNode() {
Node node = element.getFirstChild();
- return node != null && Node.TEXT_NODE == node.getNodeType() ? (Text) node : null;
+ while (node != null && Node.TEXT_NODE != node.getNodeType()) {
+ node = node.getNextSibling();
+ }
+ if (node instanceof Text) {
+ return (Text)node;
+ }
+
+ // Otherwise we have no Text child. Just remove the child nodes + add a new text node
+ node = element.getFirstChild();
+ while (node != null) {
+ Node nextNode = node.getNextSibling();
+ element.removeChild(node);
+ node = nextNode;
+ }
+
+ Node textNode = element.getOwnerDocument().createTextNode("");
+ return (Text)element.appendChild(textNode);
}
/**