More pruning of parsing methods in XMLUtils
git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk@1872555 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/xml/security/utils/XMLUtils.java b/src/main/java/org/apache/xml/security/utils/XMLUtils.java
index df3d2ec..bef7ca1 100644
--- a/src/main/java/org/apache/xml/security/utils/XMLUtils.java
+++ b/src/main/java/org/apache/xml/security/utils/XMLUtils.java
@@ -1008,24 +1008,6 @@
return true;
}
- public static Document newDocument() throws ParserConfigurationException {
- ClassLoader loader = getContextClassLoader();
- if (loader == null) {
- loader = getClassLoader(XMLUtils.class);
- }
- // If the ClassLoader is null then just create a DocumentBuilder and use it
- if (loader == null) {
- DocumentBuilder documentBuilder = createDocumentBuilder(true);
- return documentBuilder.newDocument();
- }
-
- Queue<DocumentBuilder> queue = getDocumentBuilderQueue(true, loader);
- DocumentBuilder documentBuilder = getDocumentBuilder(true, queue);
- Document doc = documentBuilder.newDocument();
- repoolDocumentBuilder(documentBuilder, queue);
- return doc;
- }
-
public static Document read(InputStream inputStream, boolean disAllowDocTypeDeclarations) throws ParserConfigurationException, SAXException, IOException {
ClassLoader loader = getContextClassLoader();
if (loader == null) {
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
index e4e7412..5c70a2f 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
@@ -136,7 +136,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, dsa);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element envelope = doc.createElementNS
("http://example.org/envelope", "Envelope");
envelope.setAttributeNS
@@ -434,7 +434,7 @@
(Transform.XPATH, xpf)));
KeyInfo ki = kifac.newKeyInfo(Collections.singletonList(rm), null);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create objects
List<XMLObject> objs = new ArrayList<>();
@@ -658,7 +658,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, ki);
@@ -710,7 +710,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create Objects
XMLObject obj = fac.newXMLObject(Collections.singletonList
(new DOMStructure(doc.createTextNode("some text"))),
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
index c449a63..6081a52 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
@@ -33,7 +33,6 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
@@ -138,7 +137,7 @@
KeyInfo ki = kifac.newKeyInfo(kits);
// create Objects
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element baz = doc.createElementNS("urn:bar", "bar:Baz");
Comment com = doc.createComment(" comment ");
baz.appendChild(com);
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
index e254f96..4091473 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
@@ -33,7 +33,6 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
@@ -128,7 +127,7 @@
XMLSignature sig = fac.newXMLSignature
(si, ki, null, null, "signature-value");
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element tbs1 = doc.createElementNS(null, "ToBeSigned");
Comment tbs1Com = doc.createComment(" comment ");
Element tbs1Data = doc.createElementNS(null, "Data");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
index 7ea2b60..7f3b173 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
@@ -30,7 +30,6 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
@@ -294,7 +293,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
index 763db35..12855f8 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
@@ -45,8 +45,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.apache.xml.security.utils.XMLUtils;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -112,7 +110,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, null);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
DOMSignContext dsc = new DOMSignContext
(new KeySelectors.SecretKeySelector
("test".getBytes(StandardCharsets.US_ASCII)), doc);
@@ -154,7 +152,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, null);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element player = doc.createElementNS(null, "player");
player.setAttributeNS(null, "bats", "left");
player.setAttributeNS(null, "id", "10012");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java b/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
index 2255b95..38ad69a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
@@ -32,7 +32,6 @@
import java.security.*;
import java.util.*;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -137,7 +136,7 @@
// Create an XMLSignContext and set the
// DSA PrivateKey for signing
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
DOMSignContext signContext = new DOMSignContext(kp.getPrivate(), doc);
signContext.putNamespacePrefix(XMLSignature.XMLNS, "ds");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/EnvelopingSignatureTest.java b/src/test/java/javax/xml/crypto/test/dsig/EnvelopingSignatureTest.java
index a88e473..75768a5 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/EnvelopingSignatureTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/EnvelopingSignatureTest.java
@@ -162,7 +162,7 @@
XMLObject obj = fac.newXMLObject(
Collections.singletonList(new DOMStructure(child)),
"object", null, "UTF-8");
-
+
// Create a KeyInfo and add the KeyValue to it
KeyValue kv = kif.newKeyValue(rsaKeyPair.getPublic());
KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));
@@ -170,7 +170,7 @@
XMLSignature sig = fac.newXMLSignature(si, ki,
Collections.singletonList(obj),
"signature", null);
- DOMSignContext dsc = new DOMSignContext(rsaKeyPair.getPrivate(), doc);
+ DOMSignContext dsc = new DOMSignContext(rsaKeyPair.getPrivate(), doc);
sig.sign(dsc);
// validate signature
diff --git a/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java b/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
index 3d5b9a3..4518f39 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
@@ -41,7 +41,6 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
-import org.apache.xml.security.utils.XMLUtils;
import org.junit.jupiter.api.Assumptions;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -164,7 +163,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java b/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
index 769cd8d..d61271a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
@@ -45,7 +45,6 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
-import org.apache.xml.security.utils.XMLUtils;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.w3c.dom.Document;
@@ -291,7 +290,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
index 224c93e..f3f0a80 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
@@ -39,7 +39,6 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
-import org.apache.xml.security.utils.XMLUtils;
import org.junit.jupiter.api.Assumptions;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -183,7 +182,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
index a1252a0..ed04b0c 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
@@ -63,6 +63,8 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
@@ -110,6 +112,18 @@
private static final String RSA_PRIV =
"0161169735844219697954459962296126719476357984292128166117072108359155865913405986839960884870654387514883422519600695753920562880636800379454345804879553";
+ private static final DocumentBuilderFactory DBF = DocumentBuilderFactory.newInstance();
+
+ static {
+ DBF.setNamespaceAware(true);
+ try {
+ DBF.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ } catch (ParserConfigurationException e) {
+ // Ignore: DocumentBuilderFactory is required to support the secure processing feature
+ e.printStackTrace(); // NOPMD
+ }
+ }
+
private TestUtils() {}
public static PublicKey getPublicKey(String algo)
@@ -214,7 +228,7 @@
public static Document newDocument() {
try {
- return XMLUtils.newDocument();
+ return DBF.newDocumentBuilder().newDocument();
} catch (Exception ex) {
return null;
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
index 4f4c3ca..a2a49ba 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
@@ -33,7 +33,7 @@
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import org.apache.jcp.xml.dsig.internal.dom.DOMUtils;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -120,7 +120,7 @@
fail("Should raise a NullPointerException");
} catch (NullPointerException npe) {}
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element elem = doc.createElementNS("http://acme.org", "parent");
doc.appendChild(elem);
DOMStructure parent = new DOMStructure(elem);
@@ -140,7 +140,7 @@
}
// check if key info is inserted before nextSibling
- doc = XMLUtils.newDocument();
+ doc = TestUtils.newDocument();
elem = doc.createElementNS("http://acme.org", "parent");
doc.appendChild(elem);
Element nextSib = doc.createElementNS("http://acme.org", "nextSib");
diff --git a/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java b/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
index ca46809..15bde8e 100644
--- a/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
+++ b/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
@@ -50,7 +50,7 @@
org.apache.xml.security.Init.init();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
String directory = "data/org/apache/xml/security/c14n/outExcl/";
File signatureFile = new File(directory + "apacheSignature.xml");
XMLSignature xmlSignature = new XMLSignature(doc,
diff --git a/src/test/java/org/apache/xml/security/test/dom/TestUtils.java b/src/test/java/org/apache/xml/security/test/dom/TestUtils.java
index 8bdacc2..db16854 100644
--- a/src/test/java/org/apache/xml/security/test/dom/TestUtils.java
+++ b/src/test/java/org/apache/xml/security/test/dom/TestUtils.java
@@ -18,12 +18,27 @@
*/
package org.apache.xml.security.test.dom;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.xml.security.utils.Constants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class TestUtils {
+ private static final DocumentBuilderFactory DBF = DocumentBuilderFactory.newInstance();
+
+ static {
+ DBF.setNamespaceAware(true);
+ try {
+ DBF.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ } catch (ParserConfigurationException e) {
+ // Ignore: DocumentBuilderFactory is required to support the secure processing feature
+ e.printStackTrace(); // NOPMD
+ }
+ }
+
/**
* Method createDSctx
*
@@ -42,4 +57,7 @@
return ctx;
}
+ public static Document newDocument() throws ParserConfigurationException {
+ return DBF.newDocumentBuilder().newDocument();
+ }
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
index dcb3f0b..f0bab65 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
@@ -25,7 +25,7 @@
import java.security.Security;
import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.junit.jupiter.api.Assumptions;
import org.w3c.dom.Document;
@@ -74,7 +74,7 @@
@org.junit.jupiter.api.Test
public void testSHA1() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
@@ -92,7 +92,7 @@
@org.junit.jupiter.api.Test
public void testSHA224() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA224);
@@ -110,7 +110,7 @@
@org.junit.jupiter.api.Test
public void testSHA256() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256);
@@ -128,7 +128,7 @@
@org.junit.jupiter.api.Test
public void testSHA384() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA384);
@@ -146,7 +146,7 @@
@org.junit.jupiter.api.Test
public void testSHA512() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512);
@@ -164,7 +164,7 @@
@org.junit.jupiter.api.Test
public void testMD5() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5);
@@ -183,7 +183,7 @@
@org.junit.jupiter.api.Test
public void testRIPEMD160() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160);
@@ -202,7 +202,7 @@
@org.junit.jupiter.api.Test
public void testWhirlpool() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_WHIRLPOOL);
@@ -221,7 +221,7 @@
@org.junit.jupiter.api.Test
public void testSHA3_224() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_224);
@@ -240,7 +240,7 @@
@org.junit.jupiter.api.Test
public void testSHA3_256() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_256);
@@ -259,7 +259,7 @@
@org.junit.jupiter.api.Test
public void testSHA3_384() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_384);
@@ -278,7 +278,7 @@
@org.junit.jupiter.api.Test
public void testSHA3_512() throws Exception {
Assumptions.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_512);
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
index 2f23f6b..014ef01 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
@@ -27,7 +27,7 @@
import org.apache.xml.security.algorithms.SignatureAlgorithm;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.w3c.dom.Document;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -44,7 +44,7 @@
@org.junit.jupiter.api.Test
public void testSameKeySeveralAlgorithmSigning() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
SignatureAlgorithm signatureAlgorithm =
new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
PrivateKey pk = KeyPairGenerator.getInstance("RSA").genKeyPair().getPrivate();
@@ -76,7 +76,7 @@
Map<String, Class<?>> algorithmHash = (Map<String, Class<?>>)algorithmHashField.get(null);
assertFalse(algorithmHash.isEmpty());
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Provider provider = new org.bouncycastle.jce.provider.BouncyCastleProvider();
for (String algorithmURI : algorithmHash.keySet()) {
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
index 4ed5c14..9715f02 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
@@ -22,8 +22,8 @@
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.c14n.helper.AttrCompare;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -220,7 +220,7 @@
private static Document createDoc(
String documentElement
) throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element root = doc.createElementNS(null, documentElement);
doc.appendChild(root);
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
index 4bc4be9..ffa4525 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
@@ -30,9 +30,9 @@
import org.apache.xml.security.signature.ObjectContainer;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -83,7 +83,7 @@
X509Certificate signingCert = (X509Certificate) ks
.getCertificate(ALIAS);
- Document document = XMLUtils.newDocument();
+ Document document = TestUtils.newDocument();
XMLSignature signature = new XMLSignature(document, null,
XMLSignature.ALGO_ID_SIGNATURE_DSA,
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
index 97d0031..41b5182 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
@@ -38,6 +38,7 @@
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
@@ -279,7 +280,7 @@
*/
@org.junit.jupiter.api.Test
public void test24Aexcl() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element local = doc.createElementNS("foo:bar", "dsig:local");
Element test = doc.createElementNS("http://example.net", "etsi:test");
Element elem2 = doc.createElementNS("http://example.net", "etsi:elem2");
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
index 183a1b4..32aaa52 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
@@ -23,7 +23,7 @@
import java.util.List;
import org.apache.xml.security.c14n.implementations.NameSpaceSymbTable;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -38,7 +38,7 @@
static Attr node1, node2;
static {
try {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
node1 = doc.createAttributeNS("a","b");
node2 = doc.createAttributeNS("b","c");
} catch (Exception e) {
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
index e00ace9..a2c46a1 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
@@ -24,8 +24,8 @@
import org.apache.xml.security.encryption.Reference;
import org.apache.xml.security.encryption.ReferenceList;
import org.apache.xml.security.encryption.XMLCipher;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.EncryptionConstants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -46,7 +46,7 @@
@org.junit.jupiter.api.Test
public void testReferenceList() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
XMLCipher dataCipher = XMLCipher.getInstance();
dataCipher.init(XMLCipher.DECRYPT_MODE, null);
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
index 32e8b5e..28a1eab 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
@@ -57,6 +57,7 @@
import org.apache.xml.security.utils.XMLUtils;
import org.junit.jupiter.api.Assumptions;
import org.apache.xml.security.keys.KeyInfo;
+import org.apache.xml.security.test.dom.TestUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -634,7 +635,7 @@
public void testSameDocumentCipherReference() throws Exception {
if (haveISOPadding) {
- Document d = XMLUtils.newDocument();
+ Document d = TestUtils.newDocument();
Element docElement = d.createElement("EncryptedDoc");
d.appendChild(docElement);
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
index b0bf962..7bc5dd2 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
@@ -24,6 +24,7 @@
import java.security.spec.X509EncodedKeySpec;
import org.apache.xml.security.keys.content.DEREncodedKeyValue;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
@@ -56,7 +57,7 @@
@org.junit.jupiter.api.Test
public void testSchema() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(TestUtils.newDocument(), rsaKeyControl);
Element element = derEncodedKeyValue.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -101,28 +102,28 @@
@org.junit.jupiter.api.Test
public void testRSAPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(TestUtils.newDocument(), rsaKeyControl);
assertEquals(rsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(rsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.jupiter.api.Test
public void testDSAPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), dsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(TestUtils.newDocument(), dsaKeyControl);
assertEquals(dsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(dsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.jupiter.api.Test
public void testECPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), ecKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(TestUtils.newDocument(), ecKeyControl);
assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.jupiter.api.Test
public void testId() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(TestUtils.newDocument(), rsaKeyControl);
assertEquals("", derEncodedKeyValue.getId());
assertNull(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID));
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
index d21bf5a..793bc8b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
@@ -21,6 +21,7 @@
import java.io.FileInputStream;
import org.apache.xml.security.keys.content.KeyInfoReference;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -42,7 +43,7 @@
@org.junit.jupiter.api.Test
public void testSchema() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
+ KeyInfoReference keyInfoReference = new KeyInfoReference(TestUtils.newDocument(), URI_CONTROL);
Element element = keyInfoReference.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -62,13 +63,13 @@
@org.junit.jupiter.api.Test
public void testURIOnConstruction() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
+ KeyInfoReference keyInfoReference = new KeyInfoReference(TestUtils.newDocument(), URI_CONTROL);
assertEquals(URI_CONTROL, keyInfoReference.getURI());
}
@org.junit.jupiter.api.Test
public void testId() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
+ KeyInfoReference keyInfoReference = new KeyInfoReference(TestUtils.newDocument(), URI_CONTROL);
assertEquals("", keyInfoReference.getId());
assertNull(keyInfoReference.getElement().getAttributeNodeNS(null, Constants._ATT_ID));
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
index 7c7c353..26f83f2 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
@@ -24,6 +24,7 @@
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.content.x509.XMLX509Digest;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -57,7 +58,7 @@
@org.junit.jupiter.api.Test
public void testSchema() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), digestControl, ALG_URI_CONTROL);
+ XMLX509Digest x509Digest = new XMLX509Digest(TestUtils.newDocument(), digestControl, ALG_URI_CONTROL);
Element element = x509Digest.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -77,14 +78,14 @@
@org.junit.jupiter.api.Test
public void testDigestOnConstructionWithCert() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), certControl, ALG_URI_CONTROL);
+ XMLX509Digest x509Digest = new XMLX509Digest(TestUtils.newDocument(), certControl, ALG_URI_CONTROL);
assertEquals(ALG_URI_CONTROL, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@org.junit.jupiter.api.Test
public void testDigestOnConstructionWithBytes() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), digestControl, ALG_URI_CONTROL);
+ XMLX509Digest x509Digest = new XMLX509Digest(TestUtils.newDocument(), digestControl, ALG_URI_CONTROL);
assertEquals(ALG_URI_CONTROL, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
index 13b551e..67bc97a 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
@@ -20,7 +20,7 @@
import org.apache.xml.security.keys.content.x509.XMLX509IssuerSerial;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.w3c.dom.Document;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -34,7 +34,7 @@
private Document doc;
public XMLX509IssuerSerialTest() throws Exception {
- doc = XMLUtils.newDocument();
+ doc = TestUtils.newDocument();
}
@org.junit.jupiter.api.Test
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
index a6a6f8c..ee379f4 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
@@ -55,8 +55,8 @@
import org.apache.xml.security.keys.keyresolver.implementations.SingleKeyResolver;
import org.apache.xml.security.keys.storage.StorageResolver;
import org.apache.xml.security.keys.storage.implementations.KeyStoreResolver;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
@@ -109,7 +109,7 @@
KeyResolverSpi privateKeyResolver = new PrivateKeyResolver(ks, pwd);
KeyResolverSpi secretKeyResolver = new SecretKeyResolver(ks, pwd);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
KeyInfo ki;
X509Data x509data;
@@ -219,7 +219,7 @@
}
// Create a sample XML document
- Document document = XMLUtils.newDocument();
+ Document document = TestUtils.newDocument();
Element rootElement = document.createElement("root");
document.appendChild(rootElement);
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
index 2fd76c7..daea5ab 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
@@ -31,10 +31,10 @@
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.test.dom.interop.InteropTestBase;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -79,7 +79,7 @@
}
private Document getOriginalDocument() throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
index 31eb496..d97a8f8 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
@@ -45,6 +45,7 @@
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.transforms.params.XPath2FilterContainer;
import org.apache.xml.security.transforms.params.XPathContainer;
@@ -82,7 +83,7 @@
*/
@org.junit.jupiter.api.Test
public void testEmptyNodeSet() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element envelope = doc.createElementNS("http://www.usps.gov/", "Envelope");
envelope.appendChild(doc.createTextNode("\n"));
doc.appendChild(envelope);
@@ -157,7 +158,7 @@
@org.junit.jupiter.api.Test
public void testXFilter2Signature() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -260,7 +261,7 @@
@org.junit.jupiter.api.Test
public void testSHA256Digest() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -299,7 +300,7 @@
@org.junit.jupiter.api.Test
public void testSignatureProperties() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element root = doc.createElementNS("", "RootElement");
doc.appendChild(root);
@@ -348,7 +349,7 @@
@org.junit.jupiter.api.Test
public void testAddDuplicateKeyInfo() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element root = doc.createElementNS("", "RootElement");
doc.appendChild(root);
@@ -395,7 +396,7 @@
@org.junit.jupiter.api.Test
public void testWrongSignatureName() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element root = doc.createElementNS("", "RootElement");
doc.appendChild(root);
@@ -462,7 +463,7 @@
private String doSign() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -507,7 +508,7 @@
}
ks.load(fis, "changeit".toCharArray());
PrivateKey privateKey = (PrivateKey) ks.getKey("mullan", "changeit".toCharArray());
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
X509Certificate signingCert = (X509Certificate) ks.getCertificate("mullan");
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
index 30a7add..8f18782 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
@@ -39,6 +39,7 @@
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
@@ -123,7 +124,7 @@
}
private byte[] doSign(PrivateKey privateKey, X509Certificate x509, PublicKey publicKey) throws Exception {
- org.w3c.dom.Document doc = XMLUtils.newDocument();
+ org.w3c.dom.Document doc = TestUtils.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
index 133ec4d..3813e3b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
@@ -32,6 +32,7 @@
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
@@ -78,7 +79,7 @@
@org.junit.jupiter.api.Test
public void test_generate_hmac_sha1_40() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
XMLSignature sig =
new XMLSignature(
doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
index 6f127f4..9f886eb 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
@@ -21,6 +21,7 @@
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureInput;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.TransformationException;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
@@ -137,7 +138,7 @@
}
private XMLSignature createXmlSignature() throws ParserConfigurationException, XMLSecurityException {
- Document signatureDocument = XMLUtils.newDocument();
+ Document signatureDocument = TestUtils.newDocument();
Element root = createSignatureRoot(signatureDocument);
String baseURI = "";
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
index c6686bf..1c65f89 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
@@ -47,6 +47,7 @@
import org.apache.xml.security.signature.reference.ReferenceData;
import org.apache.xml.security.signature.reference.ReferenceNodeSetData;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.ElementProxy;
@@ -112,7 +113,7 @@
// See SANTUARIO-465
@org.junit.jupiter.api.Test
public void testNoReferenceChildren() throws ParserConfigurationException, XMLSecurityException {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element referenceElement = doc.createElementNS(Constants.SignatureSpecNS, "Reference");
referenceElement.setAttributeNS(null, "URI", "#_12345");
@@ -230,7 +231,7 @@
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
index 574cdce..1c3a728 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
@@ -31,10 +31,10 @@
import org.apache.xml.security.Init;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.ElementProxy;
-import org.apache.xml.security.utils.XMLUtils;
import org.apache.xml.security.utils.resolver.implementations.ResolverXPointer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -200,7 +200,7 @@
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
index e44c5ba..659a16b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
@@ -29,6 +29,7 @@
import org.apache.xml.security.Init;
import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -47,7 +48,7 @@
public void testAddX509SubjectName() throws Exception {
Init.init();
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
XMLSignature sig = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_DSA);
doc.appendChild(sig.getElement());
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
index ee46044..cb6b603 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
@@ -35,10 +35,10 @@
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.transforms.params.XPathContainer;
import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -71,7 +71,7 @@
private void checkXmlSignatureSoftwareStack(boolean cert) throws Exception {
Init.init();
- Document testDocument = XMLUtils.newDocument();
+ Document testDocument = TestUtils.newDocument();
Element rootElement =
testDocument.createElementNS("urn:namespace", "tns:document");
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
index 44a0b32..41b0d12 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
@@ -29,6 +29,7 @@
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.transforms.implementations.TransformBase64Decode;
import org.apache.xml.security.utils.XMLUtils;
@@ -138,7 +139,7 @@
}
private static Document createDocument() throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
if (doc == null) {
throw new RuntimeException("Could not create a Document");
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
index b36b992..d1a8d3b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
@@ -19,7 +19,7 @@
package org.apache.xml.security.test.dom.utils.resolver;
import org.apache.xml.security.Init;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.resolver.ResourceResolver;
import org.apache.xml.security.utils.resolver.ResourceResolverContext;
import org.apache.xml.security.utils.resolver.ResourceResolverException;
@@ -52,7 +52,7 @@
@Test
public void testBug40783() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("id");
uri.setNodeValue("urn:ddd:uuu");
doc.createElement("test").setAttributeNode(uri);
@@ -67,7 +67,7 @@
@Test
@Disabled
public void testProxyAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -84,7 +84,7 @@
@Test
@Disabled
public void testProxyAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -106,7 +106,7 @@
@Test
@Disabled
public void testServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -121,7 +121,7 @@
@Test
@Disabled
public void testServerAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -141,7 +141,7 @@
@Test
@Disabled
public void testProxyAndServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
index 864c0dc..d12281e 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
@@ -21,7 +21,7 @@
import java.io.File;
-import org.apache.xml.security.utils.XMLUtils;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.utils.resolver.ResourceResolver;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -50,7 +50,7 @@
String className =
"org.apache.xml.security.test.dom.utils.resolver.OfflineResolver";
ResourceResolver.registerAtStart(className);
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uriAttr = doc.createAttribute("URI");
uriAttr.setValue("http://www.apache.org");
ResourceResolver res =
@@ -73,7 +73,7 @@
@org.junit.jupiter.api.Test
public void testLocalFileWithEmptyBaseURI() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Attr uriAttr = doc.createAttribute("URI");
String basedir = System.getProperty("basedir");
String file = new File(basedir, "pom.xml").toURI().toString();
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
index 8df417e..6571370 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
@@ -23,8 +23,8 @@
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclOmitCommentsTransformer;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclWithCommentsTransformer;
+import org.apache.xml.security.test.dom.TestUtils;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -236,7 +236,7 @@
*/
@org.junit.jupiter.api.Test
public void test24Aexcl() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = TestUtils.newDocument();
Element local = doc.createElementNS("foo:bar", "dsig:local");
Element test = doc.createElementNS("http://example.net", "etsi:test");
Element elem2 = doc.createElementNS("http://example.net", "etsi:elem2");
diff --git a/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java b/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
index cf6cf7b..7298b83 100644
--- a/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
+++ b/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
@@ -18,7 +18,6 @@
*/
package org.apache.xml.security.test.stax.utils;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
import javax.xml.parsers.ParserConfigurationException;
@@ -36,7 +35,7 @@
//skip possible text at the beginning of a document and go directly to the root tag
while (xmlStreamReader.hasNext() && xmlStreamReader.next() != XMLStreamConstants.START_ELEMENT) { //NOPMD
}
- Document document = XMLUtils.newDocument();
+ Document document = org.apache.xml.security.test.dom.TestUtils.newDocument();
StAX2DOM.readDocElements(document, document, xmlStreamReader, false, false);
xmlStreamReader.close();
return document;