ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1664582 - in /webservices/wss4j/trunk: ws-security-common/src/main/java/org/apache/wss4j/common/util/ ws-security-dom/src/main/java/org/apache/wss4j/dom/ ws-security-dom/src/main/java/org/apache/wss4j/dom/message/ ws-security-dom/src/main/...
Date Fri, 06 Mar 2015 10:44:22 GMT
Author: coheigea
Date: Fri Mar  6 10:44:21 2015
New Revision: 1664582

URL: http://svn.apache.org/r1664582
Log:
More refactoring

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/XMLUtils.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/BinarySecurity.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DOMX509IssuerSerial.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityTokenReference.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedKeyProcessor.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/ReferenceListProcessor.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SecurityContextTokenProcessor.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/X509Util.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/DerivedKeyTokenSTRParser.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/EncryptedKeySTRParser.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/STRParserUtil.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SecurityTokenRefSTRParser.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/XMLUtils.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/XMLUtils.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/XMLUtils.java
Fri Mar  6 10:44:21 2015
@@ -36,6 +36,7 @@ import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.w3c.dom.Text;
 import org.xml.sax.InputSource;
 
 public final class XMLUtils {
@@ -71,6 +72,30 @@ public final class XMLUtils {
         }
         return null;
     }
+    
+    /**
+     * Return the text content of an Element, or null if no such text content exists
+     */
+    public static String getElementText(Element e) {
+        if (e != null) {
+            Node node = e.getFirstChild();
+            StringBuilder builder = new StringBuilder();
+            boolean found = false;
+            while (node != null) {
+                if (Node.TEXT_NODE == node.getNodeType()) {
+                    found = true;
+                    builder.append(((Text)node).getData());
+                }
+                node = node.getNextSibling();
+            }
+            
+            if (!found) {
+                return null;
+            }
+            return builder.toString();
+        }
+        return null;
+    }
     
     public static String getNamespace(String prefix, Node e) {
         while (e != null && e.getNodeType() == Node.ELEMENT_NODE) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
Fri Mar  6 10:44:21 2015
@@ -41,6 +41,7 @@ import javax.xml.crypto.dom.DOMCryptoCon
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.dom.message.CallbackLookup;
+import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -160,11 +161,9 @@ public class WSDocInfo {
      * @return the token element or null if nothing found
      */
     public Element getTokenElement(String uri) {
-        String id = uri;
+        String id = WSSecurityUtil.getIDFromReference(uri);
         if (id == null) {
             return null;
-        } else if (id.charAt(0) == '#') {
-            id = id.substring(1);
         }
         
         TokenValue token = tokens.get(id);
@@ -190,11 +189,9 @@ public class WSDocInfo {
     }
     
     public void setTokenOnContext(String uri, DOMCryptoContext context) {
-        String id = uri;
+        String id = WSSecurityUtil.getIDFromReference(uri);
         if (id == null || context == null) {
             return;
-        } else if (id.charAt(0) == '#') {
-            id = id.substring(1);
         }
 
         TokenValue tokenValue = tokens.get(id);
@@ -219,12 +216,11 @@ public class WSDocInfo {
      * @return the WSSecurityEngineResult or null if nothing found
      */
     public WSSecurityEngineResult getResult(String uri) {
-        String id = uri;
+        String id = WSSecurityUtil.getIDFromReference(uri);
         if (id == null) {
             return null;
-        } else if (id.charAt(0) == '#') {
-            id = id.substring(1);
         }
+        
         if (!results.isEmpty()) {
             for (WSSecurityEngineResult result : results) {
                 String cId = (String)result.get(WSSecurityEngineResult.TAG_ID);
@@ -258,11 +254,9 @@ public class WSDocInfo {
      * See whether we have a WSSecurityEngineResult of the given Integer tag for the given
Id
      */
     public boolean hasResult(Integer tag, String uri) {
-        String id = uri;
+        String id = WSSecurityUtil.getIDFromReference(uri);
         if (id == null || "".equals(uri)) {
             return false;
-        } else if (id.charAt(0) == '#') {
-            id = id.substring(1);
         }
         
         if (!results.isEmpty()) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
Fri Mar  6 10:44:21 2015
@@ -22,6 +22,7 @@ package org.apache.wss4j.dom.message;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
+import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.dom.message.token.SecurityContextToken;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
@@ -55,6 +56,14 @@ public class WSSecSecurityContextToken {
     private byte[] secret;
     
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
+    private WSSConfig wssConfig;
+    
+    public WSSecSecurityContextToken() {
+    }
+    
+    public WSSecSecurityContextToken(WSSConfig config) {
+        wssConfig = config;
+    }
 
     public void prepare(Document doc, Crypto crypto) throws WSSecurityException {
 
@@ -68,9 +77,10 @@ public class WSSecSecurityContextToken {
         }
 
         // The wsu:Id of the wsc:SecurityContextToken
-        if (sctId != null) {
-            sct.setID(sctId);
+        if (sctId == null) {
+            sctId = getWsConfig().getIdAllocator().createId("TS-", sct);
         }
+        sct.setID(sctId);
     }
 
     public void prependSCTElementToHeader(Document doc, WSSecHeader secHeader)
@@ -144,4 +154,10 @@ public class WSSecSecurityContextToken {
         this.wscVersion = wscVersion;
     }
     
+    private WSSConfig getWsConfig() {
+        if (wssConfig == null) {
+            wssConfig = WSSConfig.getNewInstance();
+        }
+        return wssConfig;
+    }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/BinarySecurity.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/BinarySecurity.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/BinarySecurity.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/BinarySecurity.java
Fri Mar  6 10:44:21 2015
@@ -26,6 +26,7 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.common.bsp.BSPRule;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.DOM2Writer;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.xml.security.utils.Base64;
@@ -178,17 +179,12 @@ public class BinarySecurity {
      * @return the byte array containing token information
      */
     public byte[] getToken() {
-        Node node = element.getFirstChild();
-        StringBuilder builder = new StringBuilder();
-        while (node != null) {
-            if (Node.TEXT_NODE == node.getNodeType()) {
-                builder.append(((Text)node).getData());
-            }
-            node = node.getNextSibling();
-        }
-                
         try {
-            return Base64.decode(builder.toString());
+            String text = XMLUtils.getElementText(element);
+            if (text == null) {
+                return null;
+            }
+            return Base64.decode(text);
         } catch (Exception ex) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug(ex.getMessage(), ex);

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DOMX509IssuerSerial.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DOMX509IssuerSerial.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DOMX509IssuerSerial.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DOMX509IssuerSerial.java
Fri Mar  6 10:44:21 2015
@@ -21,11 +21,10 @@ package org.apache.wss4j.dom.message.tok
 
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.common.util.DOM2Writer;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
 
 import java.math.BigInteger;
 
@@ -49,13 +48,13 @@ public final class DOMX509IssuerSerial {
             WSSecurityUtil.getDirectChildElement(
                 element, WSConstants.X509_ISSUER_NAME_LN, WSConstants.SIG_NS
             );
-        issuer = getChildText(issuerNameElement);
+        issuer = XMLUtils.getElementText(issuerNameElement);
         
         Element serialNumberElement = 
             WSSecurityUtil.getDirectChildElement(
                 element, WSConstants.X509_SERIAL_NUMBER_LN, WSConstants.SIG_NS
             );
-        String serialNumberStr = getChildText(serialNumberElement);
+        String serialNumberStr = XMLUtils.getElementText(serialNumberElement);
         if (serialNumberStr != null) {
             serialNumber = new BigInteger(serialNumberStr);
         } else {
@@ -130,19 +129,4 @@ public final class DOMX509IssuerSerial {
         return DOM2Writer.nodeToString(element);
     }
     
-    
-    private String getChildText(Node parentNode) {
-        if (parentNode == null) {
-            return null;
-        }
-        Node node = parentNode.getFirstChild();
-        StringBuilder buffer = new StringBuilder();
-        while (node != null) {
-            if (Node.TEXT_NODE == node.getNodeType()) {
-                buffer.append(((Text)node).getData());
-            }
-            node = node.getNextSibling();
-        }
-        return buffer.toString();
-    }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
Fri Mar  6 10:44:21 2015
@@ -243,17 +243,19 @@ public class DerivedKeyToken {
      * @param properties The properties and values in a Map
      */
     public void setProperties(Map<String, String> properties) {
-        for (String key : properties.keySet()) {
-            String propertyName = properties.get(key); //Get the property name
-            //Check whether this property is already there
-            //If so change the value
-            Element node = 
-                WSSecurityUtil.findElement(elementProperties, propertyName, ns);
-            if (node != null) { //If the node is not null
-                Text node1 = getFirstNode(node);
-                node1.setData(properties.get(propertyName));
-            } else {
-                addProperty(propertyName, properties.get(propertyName));
+        if (properties != null && !properties.isEmpty()) {
+            for (String key : properties.keySet()) {
+                String propertyName = properties.get(key); //Get the property name
+                //Check whether this property is already there
+                //If so change the value
+                Element node = 
+                    WSSecurityUtil.findElement(elementProperties, propertyName, ns);
+                if (node != null) { //If the node is not null
+                    Text node1 = getFirstNode(node);
+                    node1.setData(properties.get(propertyName));
+                } else {
+                    addProperty(propertyName, properties.get(propertyName));
+                }
             }
         }
     }
@@ -486,9 +488,7 @@ public class DerivedKeyToken {
         SecurityTokenReference securityTokenReference = getSecurityTokenReference();
         if (securityTokenReference.containsReference()) {
             basetokenId = securityTokenReference.getReference().getURI();
-            if (basetokenId.charAt(0) == '#') {
-                basetokenId = basetokenId.substring(1);
-            }
+            basetokenId = WSSecurityUtil.getIDFromReference(basetokenId);
         } else {
             // KeyIdentifier
             basetokenId = securityTokenReference.getKeyIdentifierValue();

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
Fri Mar  6 10:44:21 2015
@@ -22,7 +22,6 @@ package org.apache.wss4j.dom.message.tok
 import javax.xml.namespace.QName;
 
 import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.DOM2Writer;
 import org.apache.wss4j.common.derivedKey.ConversationConstants;
@@ -45,8 +44,6 @@ public class SecurityContextToken {
      */
     private Element elementIdentifier;
     
-    private WSSConfig wssConfig;
-    
     private String tokenType = WSConstants.WSC_SCT;
     
     /**
@@ -89,8 +86,6 @@ public class SecurityContextToken {
         String uuid = IDGenerator.generateID("uuid:");
         
         elementIdentifier.appendChild(doc.createTextNode(uuid));
-        
-        setID(getWSSConfig().getIdAllocator().createSecureId("sctId-", element));
     }
 
     /**
@@ -269,10 +264,4 @@ public class SecurityContextToken {
         return true;
     }
 
-    private WSSConfig getWSSConfig() {
-        if (wssConfig == null) {
-            wssConfig = WSSConfig.getNewInstance();
-        }
-        return wssConfig;
-    }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityTokenReference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityTokenReference.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityTokenReference.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityTokenReference.java
Fri Mar  6 10:44:21 2015
@@ -28,13 +28,13 @@ import org.apache.wss4j.common.crypto.Me
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.DOM2Writer;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
 import org.apache.wss4j.dom.message.CallbackLookup;
 import org.apache.wss4j.dom.message.DOMCallbackLookup;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.xml.security.exceptions.Base64DecodingException;
 import org.apache.xml.security.utils.Base64;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -251,10 +251,7 @@ public class SecurityTokenReference {
         String uri,
         String type
     ) throws WSSecurityException {
-        String id = uri;
-        if (id.charAt(0) == '#') {
-            id = id.substring(1);
-        }
+        String id = WSSecurityUtil.getIDFromReference(uri);
         //
         // Delegate finding the element to the CallbackLookup instance
         //
@@ -286,10 +283,7 @@ public class SecurityTokenReference {
         String uri,
         String type
     ) throws WSSecurityException {
-        String id = uri;
-        if (id.charAt(0) == '#') {
-            id = id.substring(1);
-        }
+        String id = WSSecurityUtil.getIDFromReference(uri);
         //
         // Try to find it from the WSDocInfo instance first
         //
@@ -486,14 +480,11 @@ public class SecurityTokenReference {
                 return new X509Certificate[]{cert};
             }
         } else if (THUMB_URI.equals(value)) {
-            Node node = getFirstElement().getFirstChild();
-            if (node == null) {
-                return null;
-            }
-            if (Node.TEXT_NODE == node.getNodeType()) {
+            String text = XMLUtils.getElementText(getFirstElement());
+            if (text != null) {
                 byte[] thumb;
                 try {
-                    thumb = Base64.decode(((Text) node).getData());
+                    thumb = Base64.decode(text);
                 } catch (Base64DecodingException e) {
                     throw new WSSecurityException(
                         WSSecurityException.ErrorCode.FAILURE, "decoding.general", e
@@ -513,13 +504,7 @@ public class SecurityTokenReference {
     
     public String getKeyIdentifierValue() {
         if (containsKeyIdentifier()) {
-            Node node = getFirstElement().getFirstChild();
-            if (node == null) {
-                return null;
-            }
-            if (node.getNodeType() == Node.TEXT_NODE) {
-                return ((Text) node).getData();
-            }
+            return XMLUtils.getElementText(getFirstElement());
         } 
         return null;
     }
@@ -564,13 +549,10 @@ public class SecurityTokenReference {
         if (skiBytes != null) {
             return skiBytes;
         }
-        Node node = getFirstElement().getFirstChild();
-        if (node == null) {
-            return null;
-        }
-        if (node.getNodeType() == Node.TEXT_NODE) {
+        String text = XMLUtils.getElementText(getFirstElement());
+        if (text != null) {
             try {
-                skiBytes = Base64.decode(((Text) node).getData());
+                skiBytes = Base64.decode(text);
             } catch (Exception e) {
                 LOG.debug(e.getMessage(), e);
                 return null;
@@ -658,17 +640,7 @@ public class SecurityTokenReference {
      *         a <code>wsse:Reference</code> element
      */
     public boolean containsReference() {
-        return lengthReference() > 0;
-    }
-
-    /**
-     * Method lengthReference.
-     *
-     * @return number of <code>wsse:Reference</code> elements in
-     *         the <code>SecurityTokenReference</code>
-     */
-    public int lengthReference() {
-        return length(WSConstants.WSSE_NS, "Reference");
+        return containsElement(WSConstants.WSSE_NS, "Reference");
     }
 
     /**
@@ -678,7 +650,7 @@ public class SecurityTokenReference {
      *         a <code>ds:IssuerSerial</code> element
      */
     public boolean containsX509IssuerSerial() {
-        return lengthX509IssuerSerial() > 0;
+        return containsElement(WSConstants.SIG_NS, WSConstants.X509_ISSUER_SERIAL_LN);
     }
 
     /**
@@ -688,27 +660,7 @@ public class SecurityTokenReference {
      *         a <code>ds:X509Data</code> element
      */
     public boolean containsX509Data() {
-        return lengthX509Data() > 0;
-    }
-    
-    /**
-     * Method lengthX509IssuerSerial.
-     *
-     * @return number of <code>ds:IssuerSerial</code> elements in
-     *         the <code>SecurityTokenReference</code>
-     */
-    public int lengthX509IssuerSerial() {
-        return length(WSConstants.SIG_NS, WSConstants.X509_ISSUER_SERIAL_LN);
-    }
-
-    /**
-     * Method lengthX509Data.
-     *
-     * @return number of <code>ds:IssuerSerial</code> elements in
-     *         the <code>SecurityTokenReference</code>
-     */
-    public int lengthX509Data() {
-        return length(WSConstants.SIG_NS, WSConstants.X509_DATA_LN);
+        return containsElement(WSConstants.SIG_NS, WSConstants.X509_DATA_LN);
     }
     
     /**
@@ -718,28 +670,10 @@ public class SecurityTokenReference {
      *         a <code>wsse:KeyIdentifier</code> element
      */
     public boolean containsKeyIdentifier() {
-        return lengthKeyIdentifier() > 0;
+        return containsElement(WSConstants.WSSE_NS, "KeyIdentifier");
     }
     
-    /**
-     * Method lengthKeyIdentifier.
-     *
-     * @return number of <code>wsse:KeyIdentifier</code> elements in
-     *         the <code>SecurityTokenReference</code>
-     */
-    public int lengthKeyIdentifier() {
-        return length(WSConstants.WSSE_NS, "KeyIdentifier");
-    }
-
-    /**
-     * Method length.
-     *
-     * @param namespace
-     * @param localname
-     * @return number of elements with matching localname and namespace
-     */
-    public int length(String namespace, String localname) {
-        int result = 0;
+    private boolean containsElement(String namespace, String localname) {
         Node node = element.getFirstChild();
         while (node != null) {
             if (Node.ELEMENT_NODE == node.getNodeType()) {
@@ -749,12 +683,12 @@ public class SecurityTokenReference {
                     || namespace == null && ns == null)
                     && localname.equals(name)
                 ) {
-                    result++;
+                    return true;
                 }
             }
             node = node.getNextSibling();
         }
-        return result;
+        return false;
     }
 
     /**

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
Fri Mar  6 10:44:21 2015
@@ -21,9 +21,7 @@ package org.apache.wss4j.dom.message.tok
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 
@@ -53,7 +51,6 @@ import org.w3c.dom.Text;
 public class Timestamp {
     
     private Element element;
-    private List<Element> customElements = new ArrayList<>();
     private Date createdDate;
     private Date expiresDate;
     
@@ -110,7 +107,6 @@ public class Timestamp {
                     }
                 } else {
                     bspEnforcer.handleBSPRule(BSPRule.R3222);
-                    customElements.add(currentChildElement);
                 }
             }
         }
@@ -264,23 +260,6 @@ public class Timestamp {
     }
 
     /**
-     * Creates and adds a custom element to this Timestamp
-     */
-    public void addCustomElement(Document doc, Element customElement) {
-        customElements.add(customElement);
-        element.appendChild(customElement);
-    }
-
-    /**
-     * Get the the custom elements from this Timestamp
-     *
-     * @return the list containing the custom elements.
-     */
-    public List<Element> getCustomElements() {
-        return customElements;
-    }
-    
-    /**
      * Set wsu:Id attribute of this timestamp
      * @param id
      */

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java
Fri Mar  6 10:44:21 2015
@@ -42,6 +42,7 @@ import org.apache.wss4j.common.util.Date
 import org.apache.wss4j.common.util.UsernameTokenUtil;
 import org.apache.wss4j.common.util.WSCurrentTimeSource;
 import org.apache.wss4j.common.util.WSTimeSource;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
@@ -72,7 +73,7 @@ public class UsernameToken {
         org.slf4j.LoggerFactory.getLogger(UsernameToken.class);
     private static final boolean DO_DEBUG = LOG.isDebugEnabled();
 
-    private Element element ;
+    private Element element;
     private Element elementUsername;
     private Element elementPassword;
     private Element elementNonce;
@@ -164,7 +165,7 @@ public class UsernameToken {
         
         // Guard against a malicious user sending a bogus iteration value
         if (elementIteration != null) {
-            String iter = nodeString(elementIteration);
+            String iter = XMLUtils.getElementText(elementIteration);
             if (iter != null) {
                 int iterInt = Integer.parseInt(iter);
                 if (iterInt < 0 || iterInt > 10000) {
@@ -391,7 +392,7 @@ public class UsernameToken {
      * @return the data from the user name element.
      */
     public String getName() {
-        return nodeString(elementUsername);
+        return XMLUtils.getElementText(elementUsername);
     }
 
     /**
@@ -411,7 +412,7 @@ public class UsernameToken {
      * @return the data from the nonce element.
      */
     public String getNonce() {
-        return nodeString(elementNonce);
+        return XMLUtils.getElementText(elementNonce);
     }
 
     /**
@@ -420,7 +421,7 @@ public class UsernameToken {
      * @return the data from the created time element.
      */
     public String getCreated() {
-        return nodeString(elementCreated);
+        return XMLUtils.getElementText(elementCreated);
     }
     
     /**
@@ -439,7 +440,7 @@ public class UsernameToken {
      * @return the password string or <code>null</code> if no such node exists.
      */
     public String getPassword() {
-        String password = nodeString(elementPassword);
+        String password = XMLUtils.getElementText(elementPassword);
         // See WSS-219
         if (password == null && elementPassword != null) {
             return "";
@@ -462,7 +463,7 @@ public class UsernameToken {
      * @throws WSSecurityException
      */
     public byte[] getSalt() throws WSSecurityException {
-        String salt = nodeString(elementSalt);
+        String salt = XMLUtils.getElementText(elementSalt);
         if (salt != null) {
             try {
                 return Base64.decode(salt);
@@ -483,7 +484,7 @@ public class UsernameToken {
      *         is returned.
      */
     public int getIteration() {
-        String iter = nodeString(elementIteration);
+        String iter = XMLUtils.getElementText(elementIteration);
         if (iter != null) {
             return Integer.parseInt(iter);
         }
@@ -639,34 +640,6 @@ public class UsernameToken {
     }
 
     /**
-     * Returns the data of an element as String or null if either the the element
-     * does not contain a Text node or the node is empty.
-     * 
-     * @param e DOM element
-     * @return Element text node data as String
-     */
-    private String nodeString(Element e) {
-        if (e != null) {
-            Node node = e.getFirstChild();
-            StringBuilder builder = new StringBuilder();
-            boolean found = false;
-            while (node != null) {
-                if (Node.TEXT_NODE == node.getNodeType()) {
-                    found = true;
-                    builder.append(((Text)node).getData());
-                }
-                node = node.getNextSibling();
-            }
-            
-            if (!found) {
-                return null;
-            }
-            return builder.toString();
-        }
-        return null;
-    }
-
-    /**
      * Returns the dom element of this <code>UsernameToken</code> object.
      * 
      * @return the <code>wsse:UsernameToken</code> element
@@ -725,7 +698,7 @@ public class UsernameToken {
             // we must have an iteration element to use this token for a derived key
             bspEnforcer.handleBSPRule(BSPRule.R4218);
         } else {
-            String iter = nodeString(elementIteration);
+            String iter = XMLUtils.getElementText(elementIteration);
             if (iter == null || Integer.parseInt(iter) < 1000) {
                 bspEnforcer.handleBSPRule(BSPRule.R4218);
             }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedKeyProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedKeyProcessor.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedKeyProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedKeyProcessor.java
Fri Mar  6 10:44:21 2015
@@ -39,13 +39,13 @@ import javax.crypto.spec.PSource;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.Text;
 import org.apache.wss4j.common.bsp.BSPRule;
 import org.apache.wss4j.common.crypto.AlgorithmSuite;
 import org.apache.wss4j.common.crypto.AlgorithmSuiteValidator;
 import org.apache.wss4j.common.crypto.CryptoType;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.KeyUtils;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDataRef;
 import org.apache.wss4j.dom.WSDocInfo;
@@ -306,10 +306,7 @@ public class EncryptedKeyProcessor imple
                         && WSConstants.ENC_NS.equals(node.getNamespaceURI())
                         && "DataReference".equals(node.getLocalName())) {
                     String dataRefURI = ((Element) node).getAttributeNS(null, "URI");
-                    if (dataRefURI.charAt(0) == '#') {
-                        dataRefURI = dataRefURI.substring(1);
-                    }
-                    return dataRefURI;
+                    return WSSecurityUtil.getIDFromReference(dataRefURI);
                 }
             }
         }
@@ -324,17 +321,12 @@ public class EncryptedKeyProcessor imple
      * @throws WSSecurityException
      */
     private static byte[] getDecodedBase64EncodedData(Element element) throws WSSecurityException
{
-        StringBuilder sb = new StringBuilder();
-        Node node = element.getFirstChild();
-        while (node != null) {
-            if (Node.TEXT_NODE == node.getNodeType()) {
-                sb.append(((Text) node).getData());
-            }
-            node = node.getNextSibling();
-        }
-        String encodedData = sb.toString();
         try {
-            return Base64.decode(encodedData);
+            String text = XMLUtils.getElementText(element);
+            if (text == null) {
+                return null;
+            }
+            return Base64.decode(text);
         } catch (Base64DecodingException e) {
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, "decoding.general", e
@@ -438,7 +430,7 @@ public class EncryptedKeyProcessor imple
                     cryptoType.setIssuerSerial(issuerSerial.getIssuer(), issuerSerial.getSerialNumber());
                     return data.getDecCrypto().getX509Certificates(cryptoType);
                 } else if (WSConstants.X509_CERT_LN.equals(x509Child.getLocalName())) {
-                    byte[] token = getToken(x509Child);
+                    byte[] token = getDecodedBase64EncodedData(x509Child);
                     if (token == null) {
                         throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidCertData", 0);
                     }
@@ -471,26 +463,6 @@ public class EncryptedKeyProcessor imple
         return null;
     }
     
-    private byte[] getToken(Element element) {
-        Node node = element.getFirstChild();
-        StringBuilder builder = new StringBuilder();
-        while (node != null) {
-            if (Node.TEXT_NODE == node.getNodeType()) {
-                builder.append(((Text)node).getData());
-            }
-            node = node.getNextSibling();
-        }
-                
-        try {
-            return Base64.decode(builder.toString());
-        } catch (Exception ex) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug(ex.getMessage(), ex);
-            }
-            return null;
-        }
-    }
-    
     /**
      * Decrypt all data references
      */
@@ -511,9 +483,7 @@ public class EncryptedKeyProcessor imple
                     && WSConstants.ENC_NS.equals(node.getNamespaceURI())
                     && "DataReference".equals(node.getLocalName())) {
                 String dataRefURI = ((Element) node).getAttributeNS(null, "URI");
-                if (dataRefURI.charAt(0) == '#') {
-                    dataRefURI = dataRefURI.substring(1);
-                }
+                dataRefURI = WSSecurityUtil.getIDFromReference(dataRefURI);
                 
                 WSDataRef dataRef = 
                     decryptDataRef(refList.getOwnerDocument(), dataRefURI, docInfo, decryptedBytes,
data);

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/ReferenceListProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/ReferenceListProcessor.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/ReferenceListProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/ReferenceListProcessor.java
Fri Mar  6 10:44:21 2015
@@ -109,9 +109,7 @@ public class ReferenceListProcessor impl
                 && WSConstants.ENC_NS.equals(node.getNamespaceURI())
                 && "DataReference".equals(node.getLocalName())) {
                 String dataRefURI = ((Element) node).getAttributeNS(null, "URI");
-                if (dataRefURI.charAt(0) == '#') {
-                    dataRefURI = dataRefURI.substring(1);
-                }
+                dataRefURI = WSSecurityUtil.getIDFromReference(dataRefURI);
                 
                 // See whether we have already processed the encrypted node 
                 if (!wsDocInfo.hasResult(WSConstants.ENCR, dataRefURI)) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SecurityContextTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SecurityContextTokenProcessor.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SecurityContextTokenProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SecurityContextTokenProcessor.java
Fri Mar  6 10:44:21 2015
@@ -26,6 +26,7 @@ import org.apache.wss4j.common.ext.WSPas
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.message.token.SecurityContextToken;
+import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.wss4j.dom.validate.Credential;
 import org.apache.wss4j.dom.validate.Validator;
 import org.w3c.dom.Element;
@@ -69,9 +70,8 @@ public class SecurityContextTokenProcess
             result.put(WSSecurityEngineResult.TAG_SECRET, returnedCredential.getSecretKey());
         } else {
             String id = sct.getID();
-            if (!"".equals(id) && id.charAt(0) == '#') {
-                id = id.substring(1);
-            }
+            id = WSSecurityUtil.getIDFromReference(id);
+
             byte[] secret = null;
             try {
                 secret = getSecret(data.getCallbackHandler(), sct.getIdentifier());

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/X509Util.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/X509Util.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/X509Util.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/X509Util.java
Fri Mar  6 10:44:21 2015
@@ -23,10 +23,10 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.KeyUtils;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.Text;
 
 import javax.crypto.SecretKey;
 import javax.security.auth.callback.Callback;
@@ -84,16 +84,7 @@ public final class X509Util {
                 keyInfoElem, "KeyName", WSConstants.SIG_NS
             );
         if (keyNmElem != null) {
-            
-            Node node = keyNmElem.getFirstChild();
-            StringBuilder builder = new StringBuilder();
-            while (node != null) {
-                if (Node.TEXT_NODE == node.getNodeType()) {
-                    builder.append(((Text)node).getData());
-                }
-                node = node.getNextSibling();
-            }
-            keyName = builder.toString();
+            keyName = XMLUtils.getElementText(keyNmElem);
         }
         if (keyName == null || keyName.length() <= 0) {
             LOG.debug("No Key Name available");

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/DerivedKeyTokenSTRParser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/DerivedKeyTokenSTRParser.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/DerivedKeyTokenSTRParser.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/DerivedKeyTokenSTRParser.java
Fri Mar  6 10:44:21 2015
@@ -65,9 +65,7 @@ public class DerivedKeyTokenSTRParser im
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            if (uri.charAt(0) == '#') {
-                uri = uri.substring(1);
-            }
+            uri = WSSecurityUtil.getIDFromReference(uri);
         } else if (secRef.containsKeyIdentifier()) {
             uri = secRef.getKeyIdentifierValue();
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/EncryptedKeySTRParser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/EncryptedKeySTRParser.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/EncryptedKeySTRParser.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/EncryptedKeySTRParser.java
Fri Mar  6 10:44:21 2015
@@ -37,6 +37,7 @@ import org.apache.wss4j.dom.message.toke
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.message.token.X509Security;
 import org.apache.wss4j.dom.saml.WSSSAMLKeyInfoProcessor;
+import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Element;
 
 /**
@@ -66,9 +67,7 @@ public class EncryptedKeySTRParser imple
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            if (uri.charAt(0) == '#') {
-                uri = uri.substring(1);
-            }
+            uri = WSSecurityUtil.getIDFromReference(uri);
         } else if (secRef.containsKeyIdentifier()) {
             uri = secRef.getKeyIdentifierValue();
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/STRParserUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/STRParserUtil.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/STRParserUtil.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/STRParserUtil.java
Fri Mar  6 10:44:21 2015
@@ -39,6 +39,7 @@ import org.apache.wss4j.dom.message.toke
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.message.token.X509Security;
 import org.apache.wss4j.dom.processor.Processor;
+import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Element;
 
 /**
@@ -264,11 +265,9 @@ public final class STRParserUtil {
         int identifier,
         RequestData data
     ) throws WSSecurityException {
-        if (id.charAt(0) == '#') {
-            id = id.substring(1);
-        }
+        String uri = WSSecurityUtil.getIDFromReference(id);
         WSPasswordCallback pwcb = 
-            new WSPasswordCallback(id, null, type, identifier);
+            new WSPasswordCallback(uri, null, type, identifier);
         try {
             Callback[] callbacks = new Callback[]{pwcb};
             if (data.getCallbackHandler() != null) {
@@ -278,7 +277,7 @@ public final class STRParserUtil {
         } catch (Exception e) {
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE,
-                "noPassword", e, id);
+                "noPassword", e, uri);
         }
 
         return null;

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SecurityTokenRefSTRParser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SecurityTokenRefSTRParser.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SecurityTokenRefSTRParser.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SecurityTokenRefSTRParser.java
Fri Mar  6 10:44:21 2015
@@ -72,9 +72,7 @@ public class SecurityTokenRefSTRParser i
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            if (uri.charAt(0) == '#') {
-                uri = uri.substring(1);
-            }
+            uri = WSSecurityUtil.getIDFromReference(uri);
         } else if (secRef.containsKeyIdentifier()) {
             uri = secRef.getKeyIdentifierValue();
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java?rev=1664582&r1=1664581&r2=1664582&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java
Fri Mar  6 10:44:21 2015
@@ -87,9 +87,7 @@ public class SignatureSTRParser implemen
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            if (uri.charAt(0) == '#') {
-                uri = uri.substring(1);
-            }
+            uri = WSSecurityUtil.getIDFromReference(uri);
         } else if (secRef.containsKeyIdentifier()) {
             uri = secRef.getKeyIdentifierValue();
         }



Mime
View raw message