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/03/23 15:42:55 UTC

svn commit: r1668656 [2/2] - in /webservices/wss4j/trunk: ws-security-common/src/main/java/org/apache/wss4j/common/token/ ws-security-common/src/main/java/org/apache/wss4j/common/util/ ws-security-dom/src/main/java/org/apache/wss4j/dom/ ws-security-dom...

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=1668656&r1=1668655&r2=1668656&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 Mon Mar 23 14:42:53 2015
@@ -29,6 +29,7 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
 import org.apache.wss4j.common.saml.SAMLKeyInfo;
 import org.apache.wss4j.common.saml.SAMLUtil;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSSecurityEngineResult;
 import org.apache.wss4j.dom.handler.RequestData;
@@ -65,7 +66,7 @@ public class DerivedKeyTokenSTRParser im
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            uri = WSSecurityUtil.getIDFromReference(uri);
+            uri = XMLUtils.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=1668656&r1=1668655&r2=1668656&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 Mon Mar 23 14:42:53 2015
@@ -28,6 +28,7 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
 import org.apache.wss4j.common.saml.SAMLKeyInfo;
 import org.apache.wss4j.common.saml.SAMLUtil;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSecurityEngine;
@@ -37,7 +38,6 @@ 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;
 
 /**
@@ -67,7 +67,7 @@ public class EncryptedKeySTRParser imple
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            uri = WSSecurityUtil.getIDFromReference(uri);
+            uri = XMLUtils.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=1668656&r1=1668655&r2=1668656&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 Mon Mar 23 14:42:53 2015
@@ -27,6 +27,7 @@ import org.apache.wss4j.common.bsp.BSPRu
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSecurityEngine;
@@ -39,7 +40,6 @@ 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;
 
 /**
@@ -265,7 +265,7 @@ public final class STRParserUtil {
         int identifier,
         RequestData data
     ) throws WSSecurityException {
-        String uri = WSSecurityUtil.getIDFromReference(id);
+        String uri = XMLUtils.getIDFromReference(id);
         WSPasswordCallback pwcb = 
             new WSPasswordCallback(uri, null, type, identifier);
         try {

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=1668656&r1=1668655&r2=1668656&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 Mon Mar 23 14:42:53 2015
@@ -29,6 +29,7 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
 import org.apache.wss4j.common.saml.SAMLKeyInfo;
 import org.apache.wss4j.common.saml.SAMLUtil;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSecurityEngine;
@@ -72,7 +73,7 @@ public class SecurityTokenRefSTRParser i
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            uri = WSSecurityUtil.getIDFromReference(uri);
+            uri = XMLUtils.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=1668656&r1=1668655&r2=1668656&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 Mon Mar 23 14:42:53 2015
@@ -38,6 +38,7 @@ import org.apache.wss4j.common.saml.Open
 import org.apache.wss4j.common.saml.SAMLKeyInfo;
 import org.apache.wss4j.common.saml.SAMLUtil;
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSecurityEngine;
@@ -87,7 +88,7 @@ public class SignatureSTRParser implemen
         String uri = null;
         if (secRef.containsReference()) {
             uri = secRef.getReference().getURI();
-            uri = WSSecurityUtil.getIDFromReference(uri);
+            uri = XMLUtils.getIDFromReference(uri);
         } else if (secRef.containsKeyIdentifier()) {
             uri = secRef.getKeyIdentifierValue();
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransform.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransform.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransform.java Mon Mar 23 14:42:53 2015
@@ -19,17 +19,15 @@
 
 package org.apache.wss4j.dom.transform;
 
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
 import org.apache.wss4j.dom.message.token.PKIPathSecurity;
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.message.token.X509Security;
-import org.apache.wss4j.dom.util.WSSecurityUtil;
-
 import org.apache.xml.security.c14n.Canonicalizer;
 import org.apache.xml.security.signature.XMLSignatureInput;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -135,12 +133,12 @@ public class STRTransform extends Transf
         // Canonicalizer
         //
         String canonAlgo = null;
-        Element transformParams = WSSecurityUtil.getDirectChildElement(
+        Element transformParams = XMLUtils.getDirectChildElement(
             transformElement, "TransformationParameters", WSConstants.WSSE_NS
         );
         if (transformParams != null) {
             Element canonElem = 
-                WSSecurityUtil.getDirectChildElement(
+                XMLUtils.getDirectChildElement(
                     transformParams, "CanonicalizationMethod", WSConstants.SIG_NS
                 );
             canonAlgo = canonElem.getAttributeNS(null, "Algorithm");
@@ -205,10 +203,10 @@ public class STRTransform extends Transf
                     //
                     // Add the WSSE/WSU namespaces to the element for C14n
                     //
-                    WSSecurityUtil.setNamespace(
+                    XMLUtils.setNamespace(
                         dereferencedToken, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX
                     );
-                    WSSecurityUtil.setNamespace(
+                    XMLUtils.setNamespace(
                         dereferencedToken, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
                     );
                 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransformUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransformUtil.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransformUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/STRTransformUtil.java Mon Mar 23 14:42:53 2015
@@ -25,9 +25,9 @@ import java.security.cert.X509Certificat
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.message.token.SecurityTokenReference;
 import org.apache.wss4j.dom.message.token.X509Security;
-import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.apache.xml.security.utils.Base64;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -122,12 +122,12 @@ public final class STRTransformUtil {
                 WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, "encodeError", e
             );
         }
-        String prefix = WSSecurityUtil.getPrefixNS(WSConstants.WSSE_NS, secRefE);
+        String prefix = XMLUtils.getPrefixNS(WSConstants.WSSE_NS, secRefE);
         if (prefix == null) {
             prefix = WSConstants.WSSE_PREFIX;
         }
         Element elem = doc.createElementNS(WSConstants.WSSE_NS, prefix + ":BinarySecurityToken");
-        WSSecurityUtil.setNamespace(elem, WSConstants.WSSE_NS, prefix);
+        XMLUtils.setNamespace(elem, WSConstants.WSSE_NS, prefix);
         // elem.setAttributeNS(WSConstants.XMLNS_NS, "xmlns", "");
         elem.setAttributeNS(null, "ValueType", X509Security.X509_V3_TYPE);
         if (secRefEncType != null) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java Mon Mar 23 14:42:53 2015
@@ -29,24 +29,19 @@ import org.apache.wss4j.dom.WSSecurityEn
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.common.WSEncryptionPart;
 import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.util.XMLUtils;
 import org.apache.wss4j.dom.handler.HandlerAction;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.dom.message.CallbackLookup;
-import org.apache.xml.security.algorithms.JCEMapper;
 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
 import org.apache.xml.security.utils.Base64;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-
 import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -79,7 +74,7 @@ public final class WSSecurityUtil {
     public static Element getSecurityHeader(Document doc, String actor) throws WSSecurityException {
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
         Element soapHeaderElement = 
-            getDirectChildElement(
+            XMLUtils.getDirectChildElement(
                 doc.getDocumentElement(), 
                 WSConstants.ELEM_HEADER, 
                 soapNamespace
@@ -159,38 +154,6 @@ public final class WSSecurityUtil {
         return false;
     }
 
-    
-    /**
-     * Gets a direct child with specified localname and namespace. <p/>
-     * 
-     * @param parentNode the node where to start the search
-     * @param localName local name of the child to get
-     * @param namespace the namespace of the child to get
-     * @return the node or <code>null</code> if not such node found
-     */
-    public static Element getDirectChildElement(
-        Node parentNode, 
-        String localName,
-        String namespace
-    ) {
-        if (parentNode == null) {
-            return null;
-        }
-        for (
-            Node currentChild = parentNode.getFirstChild(); 
-            currentChild != null; 
-            currentChild = currentChild.getNextSibling()
-        ) {
-            if (Node.ELEMENT_NODE == currentChild.getNodeType()
-                && localName.equals(currentChild.getLocalName())
-                && namespace.equals(currentChild.getNamespaceURI())) {
-                return (Element)currentChild;
-            }
-        }
-        return null;
-    }
-    
-    
     /**
      * Gets all direct children with specified localname and namespace. <p/>
      * 
@@ -230,7 +193,7 @@ public final class WSSecurityUtil {
     public static Element findBodyElement(Document doc) {
         Element docElement = doc.getDocumentElement();
         String ns = docElement.getNamespaceURI();
-        return getDirectChildElement(docElement, WSConstants.ELEM_BODY, ns);
+        return XMLUtils.getDirectChildElement(docElement, WSConstants.ELEM_BODY, ns);
     }
     
     
@@ -261,290 +224,8 @@ public final class WSSecurityUtil {
         return callbackLookup.getElements(part.getName(), part.getNamespace());
     }
     
-    /**
-     * Returns the first element that matches <code>name</code> and
-     * <code>namespace</code>. <p/> This is a replacement for a XPath lookup
-     * <code>//name</code> with the given namespace. It's somewhat faster than
-     * XPath, and we do not deal with prefixes, just with the real namespace URI
-     * 
-     * @param startNode Where to start the search
-     * @param name Local name of the element
-     * @param namespace Namespace URI of the element
-     * @return The found element or <code>null</code>
-     */
-    public static Element findElement(Node startNode, String name, String namespace) {
-        //
-        // Replace the formerly recursive implementation with a depth-first-loop
-        // lookup
-        //
-        if (startNode == null) {
-            return null;
-        }
-        Node startParent = startNode.getParentNode();
-        Node processedNode = null;
-
-        while (startNode != null) {
-            // start node processing at this point
-            if (startNode.getNodeType() == Node.ELEMENT_NODE
-                && startNode.getLocalName().equals(name)) {
-                String ns = startNode.getNamespaceURI();
-                if (ns != null && ns.equals(namespace)) {
-                    return (Element)startNode;
-                }
-
-                if ((namespace == null || namespace.length() == 0)
-                    && (ns == null || ns.length() == 0)) {
-                    return (Element)startNode;
-                }
-            }
-            processedNode = startNode;
-            startNode = startNode.getFirstChild();
-
-            // no child, this node is done.
-            if (startNode == null) {
-                // close node processing, get sibling
-                startNode = processedNode.getNextSibling();
-            }
-            // no more siblings, get parent, all children
-            // of parent are processed.
-            while (startNode == null) {
-                processedNode = processedNode.getParentNode();
-                if (processedNode == startParent) {
-                    return null;
-                }
-                // close parent node processing (processed node now)
-                startNode = processedNode.getNextSibling();
-            }
-        }
-        return null;
-    }
     
-    /**
-     * Returns all elements that match <code>name</code> and <code>namespace</code>. 
-     * <p/> This is a replacement for a XPath lookup
-     * <code>//name</code> with the given namespace. It's somewhat faster than
-     * XPath, and we do not deal with prefixes, just with the real namespace URI
-     * 
-     * @param startNode Where to start the search
-     * @param name Local name of the element
-     * @param namespace Namespace URI of the element
-     * @return The found elements (or an empty list)
-     */
-    public static List<Element> findElements(Node startNode, String name, String namespace) {
-        //
-        // Replace the formerly recursive implementation with a depth-first-loop
-        // lookup
-        //
-        if (startNode == null) {
-            return null;
-        }
-        Node startParent = startNode.getParentNode();
-        Node processedNode = null;
-
-        List<Element> foundNodes = new ArrayList<>();
-        while (startNode != null) {
-            // start node processing at this point
-            if (startNode.getNodeType() == Node.ELEMENT_NODE
-                && startNode.getLocalName().equals(name)) {
-                String ns = startNode.getNamespaceURI();
-                if (ns != null && ns.equals(namespace)) {
-                    foundNodes.add((Element)startNode);
-                }
-
-                if ((namespace == null || namespace.length() == 0)
-                    && (ns == null || ns.length() == 0)) {
-                    foundNodes.add((Element)startNode);
-                }
-            }
-            processedNode = startNode;
-            startNode = startNode.getFirstChild();
 
-            // no child, this node is done.
-            if (startNode == null) {
-                // close node processing, get sibling
-                startNode = processedNode.getNextSibling();
-            }
-            // no more siblings, get parent, all children
-            // of parent are processed.
-            while (startNode == null) {
-                processedNode = processedNode.getParentNode();
-                if (processedNode == startParent) {
-                    return foundNodes;
-                }
-                // close parent node processing (processed node now)
-                startNode = processedNode.getNextSibling();
-            }
-        }
-        return foundNodes;
-    }
-    
-    /**
-     * Returns the single SAMLAssertion element that contains an AssertionID/ID that
-     * matches the supplied parameter.
-     * 
-     * @param startNode Where to start the search
-     * @param value Value of the AssertionID/ID attribute
-     * @return The found element if there was exactly one match, or
-     *         <code>null</code> otherwise
-     */
-    public static Element findSAMLAssertionElementById(Node startNode, String value) {
-        Element foundElement = null;
-
-        //
-        // Replace the formerly recursive implementation with a depth-first-loop
-        // lookup
-        //
-        if (startNode == null) {
-            return null;
-        }
-        Node startParent = startNode.getParentNode();
-        Node processedNode = null;
-
-        while (startNode != null) {
-            // start node processing at this point
-            if (startNode.getNodeType() == Node.ELEMENT_NODE) {
-                Element se = (Element) startNode;
-                if (se.hasAttributeNS(null, "ID") && value.equals(se.getAttributeNS(null, "ID"))
-                    || se.hasAttributeNS(null, "AssertionID") 
-                        && value.equals(se.getAttributeNS(null, "AssertionID"))) {
-                    if (foundElement == null) {
-                        foundElement = se; // Continue searching to find duplicates
-                    } else {
-                        LOG.warn("Multiple elements with the same 'ID' attribute value!");
-                        return null;
-                    }
-                }
-            }
-
-            processedNode = startNode;
-            startNode = startNode.getFirstChild();
-
-            // no child, this node is done.
-            if (startNode == null) {
-                // close node processing, get sibling
-                startNode = processedNode.getNextSibling();
-            }
-            // no more siblings, get parent, all children
-            // of parent are processed.
-            while (startNode == null) {
-                processedNode = processedNode.getParentNode();
-                if (processedNode == startParent) {
-                    return foundElement;
-                }
-                // close parent node processing (processed node now)
-                startNode = processedNode.getNextSibling();
-            }
-        }
-        return foundElement;
-    }
-    
-
-    /**
-     * Returns the single element that contains an Id with value
-     * <code>uri</code> and <code>namespace</code>. The Id can be either a wsu:Id or an Id
-     * with no namespace. This is a replacement for a XPath Id lookup with the given namespace. 
-     * It's somewhat faster than XPath, and we do not deal with prefixes, just with the real
-     * namespace URI
-     * 
-     * If checkMultipleElements is true and there are multiple elements, we LOG.a 
-     * warning and return null as this can be used to get around the signature checking.
-     * 
-     * @param startNode Where to start the search
-     * @param value Value of the Id attribute
-     * @param checkMultipleElements If true then go through the entire tree and return 
-     *        null if there are multiple elements with the same Id
-     * @return The found element if there was exactly one match, or
-     *         <code>null</code> otherwise
-     */
-    public static Element findElementById(
-        Node startNode, String value, boolean checkMultipleElements
-    ) {
-        //
-        // Replace the formerly recursive implementation with a depth-first-loop lookup
-        //
-        Node startParent = startNode.getParentNode();
-        Node processedNode = null;
-        Element foundElement = null;
-        String id = getIDFromReference(value);
-
-        while (startNode != null) {
-            // start node processing at this point
-            if (startNode.getNodeType() == Node.ELEMENT_NODE) {
-                Element se = (Element) startNode;
-                // Try the wsu:Id first
-                String attributeNS = se.getAttributeNS(WSConstants.WSU_NS, "Id");
-                if ("".equals(attributeNS) || !id.equals(attributeNS)) {
-                    attributeNS = se.getAttributeNS(null, "Id");
-                }
-                if (!"".equals(attributeNS) && id.equals(attributeNS)) {
-                    if (!checkMultipleElements) {
-                        return se;
-                    } else if (foundElement == null) {
-                        foundElement = se; // Continue searching to find duplicates
-                    } else {
-                        LOG.warn("Multiple elements with the same 'Id' attribute value!");
-                        return null;
-                    }
-                }
-            }
-
-            processedNode = startNode;
-            startNode = startNode.getFirstChild();
-
-            // no child, this node is done.
-            if (startNode == null) {
-                // close node processing, get sibling
-                startNode = processedNode.getNextSibling();
-            }
-            // no more siblings, get parent, all children
-            // of parent are processed.
-            while (startNode == null) {
-                processedNode = processedNode.getParentNode();
-                if (processedNode == startParent) {
-                    return foundElement;
-                }
-                // close parent node processing (processed node now)
-                startNode = processedNode.getNextSibling();
-            }
-        }
-        return foundElement;
-    }
-
-    /**
-     * Set a namespace/prefix on an element if it is not set already. First off, it
-     * searches for the element for the prefix associated with the specified
-     * namespace. If the prefix isn't null, then this is returned. Otherwise, it
-     * creates a new attribute using the namespace/prefix passed as parameters.
-     * 
-     * @param element
-     * @param namespace
-     * @param prefix
-     * @return the prefix associated with the set namespace
-     */
-    public static String setNamespace(Element element, String namespace, String prefix) {
-        String pre = getPrefixNS(namespace, element);
-        if (pre != null) {
-            return pre;
-        }
-        element.setAttributeNS(WSConstants.XMLNS_NS, "xmlns:" + prefix, namespace);
-        return prefix;
-    }
-
-    public static String getPrefixNS(String uri, Node e) {
-        while (e != null && e.getNodeType() == Element.ELEMENT_NODE) {
-            NamedNodeMap attrs = e.getAttributes();
-            for (int n = 0; n < attrs.getLength(); n++) {
-                Attr a = (Attr) attrs.item(n);
-                String name = a.getName();
-                if (name.startsWith("xmlns:") && a.getNodeValue().equals(uri)) {
-                    return name.substring("xmlns:".length());
-                }
-            }
-            e = e.getParentNode();
-        }
-        return null;
-    }
-    
     /**
      * Get the default encryption part - the SOAP Body of type "Content".
      */
@@ -555,27 +236,6 @@ public final class WSSecurityUtil {
     }
 
     /**
-     * Turn a reference (eg "#5") into an ID (eg "5").
-     * 
-     * @param ref
-     * @return ref trimmed and with the leading "#" removed, or null if not
-     *         correctly formed
-     */
-    public static String getIDFromReference(String ref) {
-        if (ref == null) {
-            return null;
-        }
-        String id = ref.trim();
-        if (id.length() == 0) {
-            return null;
-        }
-        if (id.charAt(0) == '#') {
-            id = id.substring(1);
-        }
-        return id;
-    }
-    
-    /**
      * create a new element in the same namespace <p/>
      * 
      * @param parent for the new element
@@ -647,7 +307,7 @@ public final class WSSecurityUtil {
     ) throws WSSecurityException {
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
         Element header = 
-            getDirectChildElement(
+            XMLUtils.getDirectChildElement(
                 doc.getDocumentElement(), 
                 WSConstants.ELEM_HEADER, 
                 soapNamespace
@@ -729,39 +389,6 @@ public final class WSSecurityUtil {
     public static String getSOAPNamespace(Element startElement) {
         return getSOAPConstants(startElement).getEnvelopeURI();
     }
-    
-    /**
-     * Translate the "cipherAlgo" URI to a JCE ID, and return a javax.crypto.Cipher instance
-     * of this type. 
-     */
-    public static Cipher getCipherInstance(String cipherAlgo)
-        throws WSSecurityException {
-        try {
-            String keyAlgorithm = JCEMapper.translateURItoJCEID(cipherAlgo);
-            return Cipher.getInstance(keyAlgorithm);
-        } catch (NoSuchPaddingException ex) {
-            throw new WSSecurityException(
-                WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp", 
-                ex, "No such padding: " + cipherAlgo);
-        } catch (NoSuchAlgorithmException ex) {
-            // Check to see if an RSA OAEP MGF-1 with SHA-1 algorithm was requested
-            // Some JDKs don't support RSA/ECB/OAEPPadding
-            if (WSConstants.KEYTRANSPORT_RSAOEP.equals(cipherAlgo)) {
-                try {
-                    return Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding");
-                } catch (Exception e) {
-                    throw new WSSecurityException(
-                        WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
-                        e, "No such algorithm: " + cipherAlgo);
-                }
-            } else {
-                throw new WSSecurityException(
-                    WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, "unsupportedKeyTransp",
-                    ex, "No such algorithm: " + cipherAlgo);
-            }
-        }
-    }
-    
 
     /**
      * Fetch the result of a given action from a given result list

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java Mon Mar 23 14:42:53 2015
@@ -328,7 +328,7 @@ public class ModifiedRequestTest extends
 
         Element body = WSSecurityUtil.findBodyElement(doc);
         Element encryptionMethod = 
-            WSSecurityUtil.findElement(body, "EncryptionMethod", WSConstants.ENC_NS);
+            XMLUtils.findElement(body, "EncryptionMethod", WSConstants.ENC_NS);
         encryptionMethod.setAttributeNS(null, "Algorithm", "http://new-algorithm");
         
         String outputString = 
@@ -363,7 +363,7 @@ public class ModifiedRequestTest extends
 
         Element body = WSSecurityUtil.findBodyElement(doc);
         Element cipherValue = 
-            WSSecurityUtil.findElement(body, "CipherValue", WSConstants.ENC_NS);
+            XMLUtils.findElement(body, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
         
         StringBuilder stringBuilder = new StringBuilder(cipherText);
@@ -424,9 +424,9 @@ public class ModifiedRequestTest extends
         Element securityHeader = 
             WSSecurityUtil.getSecurityHeader(encryptedDoc, "");
         Element encryptedTimestamp = 
-            WSSecurityUtil.findElement(securityHeader, "EncryptedData", WSConstants.ENC_NS);
+            XMLUtils.findElement(securityHeader, "EncryptedData", WSConstants.ENC_NS);
         Element cipherValue = 
-            WSSecurityUtil.findElement(encryptedTimestamp, "CipherValue", WSConstants.ENC_NS);
+            XMLUtils.findElement(encryptedTimestamp, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
         
         StringBuilder stringBuilder = new StringBuilder(cipherText);
@@ -471,9 +471,9 @@ public class ModifiedRequestTest extends
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         Element encryptedKey = 
-                WSSecurityUtil.findElement(doc.getDocumentElement(), "EncryptedKey", WSConstants.ENC_NS);
+            XMLUtils.findElement(doc.getDocumentElement(), "EncryptedKey", WSConstants.ENC_NS);
         Element cipherValue = 
-            WSSecurityUtil.findElement(encryptedKey, "CipherValue", WSConstants.ENC_NS);
+            XMLUtils.findElement(encryptedKey, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
         
         StringBuilder stringBuilder = new StringBuilder(cipherText);
@@ -531,7 +531,7 @@ public class ModifiedRequestTest extends
         // Modify the Created text of the Timestamp element
         Element timestampElement = timestamp.getElement();
         Element createdValue = 
-            WSSecurityUtil.findElement(timestampElement, "Created", WSConstants.WSU_NS);
+            XMLUtils.findElement(timestampElement, "Created", WSConstants.WSU_NS);
         DateFormat zulu = new XmlSchemaDateFormat();
         
         XMLGregorianCalendar createdCalendar = 

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java Mon Mar 23 14:42:53 2015
@@ -29,13 +29,13 @@ import org.apache.wss4j.common.crypto.Cr
 import org.apache.wss4j.common.crypto.CryptoFactory;
 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.dom.message.WSSecEncrypt;
 import org.apache.wss4j.dom.message.WSSecHeader;
 import org.apache.wss4j.dom.message.WSSecTimestamp;
 import org.apache.wss4j.dom.message.WSSecUsernameToken;
 import org.apache.wss4j.dom.message.token.Reference;
 import org.apache.wss4j.dom.message.token.UsernameToken;
-import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.Callback;
@@ -96,7 +96,7 @@ public class FaultCodeTest extends org.j
     public void testUnsupportedAlgorithm() throws Exception {
         try {
             secEngine.getWssConfig();
-            WSSecurityUtil.getCipherInstance("Bad Algorithm");
+            KeyUtils.getCipherInstance("Bad Algorithm");
             fail("Failure expected on an unsupported algorithm");
         } catch (WSSecurityException ex) {
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM);

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AbstractTestBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AbstractTestBase.java?rev=1668656&r1=1668655&r2=1668656&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AbstractTestBase.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AbstractTestBase.java Mon Mar 23 14:42:53 2015
@@ -467,7 +467,7 @@ public abstract class AbstractTestBase e
              */
             org.apache.wss4j.dom.SOAPConstants soapConstants =
                     WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
-            if (WSSecurityUtil.findElement(
+            if (XMLUtils.findElement(
                 doc.getDocumentElement(), "Fault", soapConstants.getEnvelopeURI()) != null
             ) {
                 return false;