You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2020/01/20 12:55:10 UTC
svn commit: r1872998 - in /santuario/xml-security-java/trunk/src:
main/java/org/apache/xml/security/c14n/
test/java/org/apache/xml/security/test/dom/c14n/implementations/
Author: coheigea
Date: Mon Jan 20 12:55:09 2020
New Revision: 1872998
URL: http://svn.apache.org/viewvc?rev=1872998&view=rev
Log:
Removing NodeList methods from Canonicalizer
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java?rev=1872998&r1=1872997&r2=1872998&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java Mon Jan 20 12:55:09 2020
@@ -35,7 +35,6 @@ import org.apache.xml.security.exception
import org.apache.xml.security.utils.ClassLoaderUtils;
import org.apache.xml.security.utils.JavaUtils;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
*
@@ -287,35 +286,6 @@ public final class Canonicalizer {
}
/**
- * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
- * as a list of XPath nodes, not as a list of subtrees.
- *
- * @param xpathNodeSet
- * @return the result of the c14n.
- * @throws CanonicalizationException
- */
- public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
- throws CanonicalizationException {
- return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
- }
-
- /**
- * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
- * as a list of XPath nodes, not as a list of subtrees.
- *
- * @param xpathNodeSet
- * @param inclusiveNamespaces
- * @return the result of the c14n.
- * @throws CanonicalizationException
- */
- public byte[] canonicalizeXPathNodeSet(
- NodeList xpathNodeSet, String inclusiveNamespaces
- ) throws CanonicalizationException {
- return
- canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
- }
-
- /**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
@@ -338,8 +308,7 @@ public final class Canonicalizer {
public byte[] canonicalizeXPathNodeSet(
Set<Node> xpathNodeSet, String inclusiveNamespaces
) throws CanonicalizationException {
- return
- canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
+ return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
}
/**
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java?rev=1872998&r1=1872997&r2=1872998&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java Mon Jan 20 12:55:09 2020
@@ -25,7 +25,6 @@ import java.util.Set;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Base class which all Canonicalization algorithms extend.
@@ -60,35 +59,6 @@ public abstract class CanonicalizerSpi {
}
/**
- * Method engineCanonicalizeXPathNodeSet
- *
- * @param xpathNodeSet
- * @return the c14n bytes
- * @throws CanonicalizationException
- */
- public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet)
- throws CanonicalizationException {
- return this.engineCanonicalizeXPathNodeSet(
- XMLUtils.convertNodelistToSet(xpathNodeSet)
- );
- }
-
- /**
- * Method engineCanonicalizeXPathNodeSet
- *
- * @param xpathNodeSet
- * @param inclusiveNamespaces
- * @return the c14n bytes
- * @throws CanonicalizationException
- */
- public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet, String inclusiveNamespaces)
- throws CanonicalizationException {
- return this.engineCanonicalizeXPathNodeSet(
- XMLUtils.convertNodelistToSet(xpathNodeSet), inclusiveNamespaces
- );
- }
-
- /**
* Returns the URI of this engine.
* @return the URI
*/
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java?rev=1872998&r1=1872997&r2=1872998&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java Mon Jan 20 12:55:09 2020
@@ -32,6 +32,7 @@ import javax.xml.xpath.XPathFactory;
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.utils.JavaUtils;
+import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -249,17 +250,15 @@ public class Canonicalizer11Test {
if (xpath == null) {
c14nBytes = c14n.canonicalizeSubtree(doc);
} else {
- NodeList nl = null;
-
XPathFactory xpf = XPathFactory.newInstance();
XPath xPath = xpf.newXPath();
DSNamespaceContext namespaceContext =
new DSNamespaceContext(namespaces);
xPath.setNamespaceContext(namespaceContext);
- nl = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
+ NodeList nl = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
- c14nBytes = c14n.canonicalizeXPathNodeSet(nl);
+ c14nBytes = c14n.canonicalizeXPathNodeSet(XMLUtils.convertNodelistToSet(nl));
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java?rev=1872998&r1=1872997&r2=1872998&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java Mon Jan 20 12:55:09 2020
@@ -203,7 +203,7 @@ public class Canonicalizer20010315Exclus
getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_3_c14nized_exclusive.xml")
);
- byte[] result = c.engineCanonicalizeXPathNodeSet(nodes);
+ byte[] result = c.engineCanonicalizeXPathNodeSet(XMLUtils.convertNodelistToSet(nodes));
assertEquals(new String(reference), new String(result));
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java?rev=1872998&r1=1872997&r2=1872998&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java Mon Jan 20 12:55:09 2020
@@ -409,7 +409,7 @@ public class Canonicalizer20010315Test {
NodeList nodes = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
Canonicalizer c14n =
Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
- byte[] c14nBytes = c14n.canonicalizeXPathNodeSet(nodes);
+ byte[] c14nBytes = c14n.canonicalizeXPathNodeSet(XMLUtils.convertNodelistToSet(nodes));
InputStream refStream = new FileInputStream(fileRef);
byte[] refBytes = JavaUtils.getBytesFromStream(refStream);
assertEquals(new String(refBytes),new String(c14nBytes));
@@ -669,7 +669,7 @@ public class Canonicalizer20010315Test {
NodeList nodes =
(NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
- byte[] result = c14nizer.canonicalizeXPathNodeSet(nodes);
+ byte[] result = c14nizer.canonicalizeXPathNodeSet(XMLUtils.convertNodelistToSet(nodes));
byte[] defined = definedOutput.getBytes();
assertEquals(definedOutput, new String(result));
return java.security.MessageDigest.isEqual(defined, result);
@@ -708,17 +708,15 @@ public class Canonicalizer20010315Test {
if (xpath == null) {
c14nBytes = c14n.canonicalizeSubtree(doc);
} else {
- NodeList nl = null;
-
XPathFactory xpf = XPathFactory.newInstance();
XPath xPath = xpf.newXPath();
DSNamespaceContext namespaceContext =
new DSNamespaceContext(namespaces);
xPath.setNamespaceContext(namespaceContext);
- nl = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
+ NodeList nl = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
- c14nBytes = c14n.canonicalizeXPathNodeSet(nl);
+ c14nBytes = c14n.canonicalizeXPathNodeSet(XMLUtils.convertNodelistToSet(nl));
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);