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 2018/06/06 15:09:43 UTC
svn commit: r1833038 [3/7] - in
/santuario/xml-security-java/branches/2.0.x-fixes: ./
src/main/java/org/apache/jcp/xml/dsig/internal/dom/
src/main/java/org/apache/xml/security/
src/main/java/org/apache/xml/security/c14n/
src/main/java/org/apache/xml/se...
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java Wed Jun 6 15:09:42 2018
@@ -46,7 +46,7 @@ public class XMLX509CertificateTest exte
SEP + "signature-x509-crt.xml");
FileInputStream fis = new FileInputStream(f);
- Document doc = XMLUtils.parse(fis, false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(fis);
NodeList nl = doc.getElementsByTagNameNS
(Constants.SignatureSpecNS, "X509Certificate");
XMLX509Certificate xmlCert =
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java Wed Jun 6 15:09:42 2018
@@ -22,6 +22,8 @@ import java.io.FileInputStream;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.content.x509.XMLX509Digest;
import org.apache.xml.security.utils.Base64;
@@ -37,6 +39,8 @@ public class XMLX509DigestTest extends A
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder documentBuilder;
+
private X509Certificate certControl;
private final String algorithmURIControl = "http://www.w3.org/2001/04/xmlenc#sha256";
@@ -45,6 +49,8 @@ public class XMLX509DigestTest extends A
private final byte[] digestControl;
public XMLX509DigestTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
certControl = loadCertificate("cert-X509Digest.crt");
digestControl = Base64.decode(digestBase64Control);
@@ -56,7 +62,7 @@ public class XMLX509DigestTest extends A
@org.junit.Test
public void testSchema() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(false), digestControl, algorithmURIControl);
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), digestControl, algorithmURIControl);
Element element = x509Digest.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -76,14 +82,14 @@ public class XMLX509DigestTest extends A
@org.junit.Test
public void testDigestOnConstructionWithCert() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(false), certControl, algorithmURIControl);
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), certControl, algorithmURIControl);
assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@org.junit.Test
public void testDigestOnConstructionWithBytes() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(false), digestControl, algorithmURIControl);
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), digestControl, algorithmURIControl);
assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@@ -104,7 +110,7 @@ public class XMLX509DigestTest extends A
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.parse(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private X509Certificate loadCertificate(String fileName) throws Exception {
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java Wed Jun 6 15:09:42 2018
@@ -32,7 +32,7 @@ public class XMLX509IssuerSerialTest ext
private Document doc;
public XMLX509IssuerSerialTest() throws Exception {
- doc = XMLUtils.newDocument(false);
+ doc = XMLUtils.createDocumentBuilder(false).newDocument();
}
@org.junit.Test
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java Wed Jun 6 15:09:42 2018
@@ -25,6 +25,8 @@ import java.security.cert.CertificateFac
import java.security.cert.X509Certificate;
import java.security.spec.X509EncodedKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.Base64;
@@ -41,7 +43,11 @@ public class KeyInfoReferenceResolverTes
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder documentBuilder;
+
public KeyInfoReferenceResolverTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
if (!Init.isInitialized()) {
Init.init();
}
@@ -132,7 +138,7 @@ public class KeyInfoReferenceResolverTes
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.parse(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private PublicKey loadPublicKey(String filePath, String algorithm) throws Exception {
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java Wed Jun 6 15:09:42 2018
@@ -35,6 +35,7 @@ import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.algorithms.JCEMapper;
import org.apache.xml.security.encryption.EncryptedData;
@@ -104,7 +105,8 @@ public class KeyResolverTest extends org
KeyResolverSpi privateKeyResolver = new PrivateKeyResolver(ks, pwd);
KeyResolverSpi secretKeyResolver = new SecretKeyResolver(ks, pwd);
- Document doc = XMLUtils.newDocument(false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
KeyInfo ki;
X509Data x509data;
@@ -214,7 +216,7 @@ public class KeyResolverTest extends org
}
// Create a sample XML document
- Document document = XMLUtils.newDocument(false);
+ Document document = XMLUtils.createDocumentBuilder(false).newDocument();
Element rootElement = document.createElement("root");
document.appendChild(rootElement);
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java Wed Jun 6 15:09:42 2018
@@ -21,6 +21,8 @@ package org.apache.xml.security.test.dom
import java.io.FileInputStream;
import java.security.Security;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.XMLUtils;
@@ -50,7 +52,8 @@ public class RetrievalMethodResolverTest
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.parse(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
@@ -69,7 +72,8 @@ public class RetrievalMethodResolverTest
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.parse(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java Wed Jun 6 15:09:42 2018
@@ -22,6 +22,8 @@ import java.io.FileInputStream;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.keys.storage.StorageResolver;
@@ -36,11 +38,15 @@ public class X509DigestResolverTest exte
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder documentBuilder;
+
private X509Certificate certControl;
private StorageResolver storageResolver;
public X509DigestResolverTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
certControl = loadCertificate("cert-X509Digest.crt");
storageResolver = new StorageResolver(new SingleCertificateResolver(certControl));
@@ -77,7 +83,7 @@ public class X509DigestResolverTest exte
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.parse(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private X509Certificate loadCertificate(String fileName) throws Exception {
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java Wed Jun 6 15:09:42 2018
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.secure_val;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -70,7 +69,8 @@ public class ForbiddenAlgorithmTest exte
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.parse(new FileInputStream(f), false, false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java Wed Jun 6 15:09:42 2018
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.secure_val;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.Manifest;
@@ -70,7 +69,8 @@ public class ForbiddenRefCountTest exten
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.parse(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(f);
Element manifestElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java Wed Jun 6 15:09:42 2018
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.secure_val;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.Manifest;
import org.apache.xml.security.signature.MissingResourceFailureException;
@@ -70,7 +69,8 @@ public class ForbiddenReferenceTest exte
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.parse(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(f);
Element manifestElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java Wed Jun 6 15:09:42 2018
@@ -20,6 +20,8 @@ package org.apache.xml.security.test.dom
import java.io.FileInputStream;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -48,7 +50,8 @@ public class ForbiddenRetrievalMethodTes
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.parse(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
keyInfo.setSecureValidation(true);
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java Wed Jun 6 15:09:42 2018
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.secure_val;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -75,7 +74,8 @@ public class WrappingAttackTest extends
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.parse(new FileInputStream(f), false, false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -94,7 +94,8 @@ public class WrappingAttackTest extends
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.parse(new FileInputStream(f), false, false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java Wed Jun 6 15:09:42 2018
@@ -61,9 +61,11 @@ public class CreateSignatureTest extends
private static final String BASEDIR = System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
- private KeyPair kp;
+ private KeyPair kp = null;
+ private javax.xml.parsers.DocumentBuilder db;
public CreateSignatureTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
org.apache.xml.security.Init.init();
kp = KeyPairGenerator.getInstance("RSA").genKeyPair();
}
@@ -74,7 +76,7 @@ public class CreateSignatureTest extends
*/
@org.junit.Test
public void testEmptyNodeSet() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = db.newDocument();
Element envelope = doc.createElementNS("http://www.usps.gov/", "Envelope");
envelope.appendChild(doc.createTextNode("\n"));
doc.appendChild(envelope);
@@ -149,7 +151,7 @@ public class CreateSignatureTest extends
@org.junit.Test
public void testXFilter2Signature() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -191,7 +193,7 @@ public class CreateSignatureTest extends
String signedDoc = new String(bos.toByteArray());
// Now Verify
- doc = XMLUtils.parse(new ByteArrayInputStream(signedDoc.getBytes()), false);
+ doc = db.parse(new ByteArrayInputStream(signedDoc.getBytes()));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -209,7 +211,7 @@ public class CreateSignatureTest extends
public void testCanonicalizedOctetStream() throws Exception {
String signedXML = doSign();
- Document doc = XMLUtils.parse(new ByteArrayInputStream(signedXML.getBytes()), false);
+ Document doc = db.parse(new ByteArrayInputStream(signedXML.getBytes()));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -244,9 +246,10 @@ public class CreateSignatureTest extends
assertTrue(si.verify(false));
}
+
private String doSign() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument(false);
+ Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -291,7 +294,7 @@ public class CreateSignatureTest extends
}
ks.load(fis, "changeit".toCharArray());
PrivateKey privateKey = (PrivateKey) ks.getKey("mullan", "changeit".toCharArray());
- Document doc = XMLUtils.newDocument(false);
+ Document doc = db.newDocument();
X509Certificate signingCert = (X509Certificate) ks.getCertificate("mullan");
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -328,7 +331,7 @@ public class CreateSignatureTest extends
}
private void doVerify(String signedXML) throws Exception {
- Document doc = XMLUtils.parse(new ByteArrayInputStream(signedXML.getBytes()), false);
+ Document doc = db.parse(new ByteArrayInputStream(signedXML.getBytes()));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java Wed Jun 6 15:09:42 2018
@@ -59,6 +59,8 @@ public class ECDSASignatureTest extends
private KeyStore keyStore;
+ private javax.xml.parsers.DocumentBuilder db;
+
public ECDSASignatureTest() throws Exception {
//
// If the BouncyCastle provider is not installed, then try to load it
@@ -84,6 +86,8 @@ public class ECDSASignatureTest extends
//String id = "http://apache.org/xml/properties/dom/document-class-name";
//dbf.setAttribute(id, IndexedDocument.class.getName());
+
+ db = XMLUtils.createDocumentBuilder(false);
org.apache.xml.security.Init.init();
}
@@ -143,7 +147,7 @@ public class ECDSASignatureTest extends
private byte[] doSign() throws Exception {
PrivateKey privateKey =
(PrivateKey)keyStore.getKey("ECDSA", ECDSA_JKS_PASSWORD.toCharArray());
- org.w3c.dom.Document doc = XMLUtils.newDocument(false);
+ org.w3c.dom.Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -183,7 +187,7 @@ public class ECDSASignatureTest extends
}
private void doVerify(InputStream is) throws Exception {
- org.w3c.dom.Document doc = XMLUtils.parse(is, false);
+ org.w3c.dom.Document doc = this.db.parse(is);
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java Wed Jun 6 15:09:42 2018
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.signature;
import java.io.File;
-import java.io.FileInputStream;
import javax.crypto.SecretKey;
@@ -74,7 +73,7 @@ public class HMACOutputLengthTest extend
@org.junit.Test
public void test_generate_hmac_sha1_40() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
XMLSignature sig =
new XMLSignature(
doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
@@ -96,7 +95,7 @@ public class HMACOutputLengthTest extend
new File(BASEDIR + SEP + "src/test/resources" + SEP + "javax" + SEP + "xml"
+ SEP + "crypto" + SEP + "dsig" + SEP, data);
- Document doc = XMLUtils.parse(new FileInputStream(file), false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(file);
NodeList nl =
doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
if (nl.getLength() == 0) {
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java Wed Jun 6 15:09:42 2018
@@ -65,7 +65,7 @@ public class InvalidKeyTest extends org.
FileInputStream is = new FileInputStream(BASEDIR + SEP +
"src/test/resources/org/apache/xml/security/samples/input/test-assertion.xml");
- Document e = XMLUtils.parse(is, false);
+ Document e = XMLUtils.createDocumentBuilder(false).parse(is);
Node assertion = e.getFirstChild();
while (!(assertion instanceof Element)) {
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java Wed Jun 6 15:09:42 2018
@@ -22,6 +22,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.security.PublicKey;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -37,10 +39,16 @@ public class KeyValueTest extends org.ju
private static final String BASEDIR = System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder db;
+
static {
Init.init();
}
+ public KeyValueTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
+ }
+
@org.junit.Test
public void testDSAPublicKey() throws Exception {
File f = null;
@@ -51,7 +59,7 @@ public class KeyValueTest extends org.ju
} else {
f = new File(filename);
}
- Document doc = XMLUtils.parse(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
XMLSignature sig = new XMLSignature
((Element) nl.item(0), f.toURI().toURL().toString());
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java Wed Jun 6 15:09:42 2018
@@ -21,6 +21,8 @@ package org.apache.xml.security.test.dom
import java.io.File;
import java.io.FileInputStream;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -39,6 +41,12 @@ public class NoKeyInfoTest extends org.j
Init.init();
}
+ private DocumentBuilder db;
+
+ public NoKeyInfoTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
+ }
+
@org.junit.Test
public void testNullKeyInfo() throws Exception {
File f = null;
@@ -49,7 +57,7 @@ public class NoKeyInfoTest extends org.j
} else {
f = new File(filename);
}
- Document doc = XMLUtils.parse(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
XMLSignature sig = new XMLSignature
((Element) nl.item(0), f.toURI().toURL().toString());
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java Wed Jun 6 15:09:42 2018
@@ -139,7 +139,8 @@ public class PreCalculatedDigestSignatur
}
private XMLSignature createXmlSignature() throws ParserConfigurationException, XMLSecurityException {
- Document signatureDocument = XMLUtils.newDocument(false);
+ DocumentBuilder documentBuilder = createDocumentBuilder();
+ Document signatureDocument = documentBuilder.newDocument();
Element root = createSignatureRoot(signatureDocument);
String baseURI = "";
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java Wed Jun 6 15:09:42 2018
@@ -24,6 +24,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -62,8 +63,9 @@ public class ProcessingInstructionTest e
@org.junit.Test
public void testProcessingInstruction() throws Exception {
String signatureFileName = dir + "upp_sign.xml";
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
File f = new File(signatureFileName);
- Document doc = XMLUtils.parse(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
Node obj =
doc.getElementsByTagNameNS("http://uri.etsi.org/01903/v1.3.2#", "QualifyingProperties").item(0);
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java Wed Jun 6 15:09:42 2018
@@ -26,6 +26,7 @@ import java.security.PublicKey;
import java.util.Enumeration;
import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
@@ -93,7 +94,8 @@ public class SignatureReferenceTest exte
// See SANTUARIO-465
@org.junit.Test
public void testNoReferenceChildren() throws ParserConfigurationException, XMLSecurityException {
- Document doc = XMLUtils.newDocument(true, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(true);
+ Document doc = db.newDocument();
Element referenceElement = doc.createElementNS(Constants.SignatureSpecNS, "Reference");
referenceElement.setAttributeNS(null, "URI", "#_12345");
@@ -164,7 +166,8 @@ public class SignatureReferenceTest exte
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument(false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java Wed Jun 6 15:09:42 2018
@@ -25,6 +25,8 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Enumeration;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -168,7 +170,8 @@ public class SignatureTest extends org.j
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument(false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java Wed Jun 6 15:09:42 2018
@@ -28,6 +28,7 @@ import java.security.PublicKey;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPath;
@@ -164,7 +165,9 @@ public class UnknownAlgoSignatureTest ex
public static Document getDocument(File file)
throws ParserConfigurationException, SAXException, IOException {
- return XMLUtils.parse(new FileInputStream(file), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new FileInputStream(file));
+ return doc;
}
}
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java Wed Jun 6 15:09:42 2018
@@ -36,53 +36,55 @@ public class X509DataTest extends org.ju
private static final String BASEDIR = System.getProperty("basedir");
KeyStore ks = null;
-
+
@org.junit.Test
public void testAddX509SubjectName() throws Exception {
Init.init();
- Document doc = XMLUtils.newDocument(false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
XMLSignature sig = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_DSA);
-
+
doc.appendChild(sig.getElement());
sig.addDocument("");
-
- //Add in the KeyInfo for the certificate that we used the private key of
- X509Certificate cert = getCertificate();
+
+ //Add in the KeyInfo for the certificate that we used the private key of
+ X509Certificate cert =getCertificate();
sig.addKeyInfo(cert);
sig.addKeyInfo(cert.getPublicKey());
-
+
// Add these three lines
org.apache.xml.security.keys.KeyInfo ki = sig.getKeyInfo();
ki.itemX509Data(0).addSubjectName(cert.getSubjectX500Principal().getName());
ki.itemX509Data(0).addIssuerSerial(cert.getIssuerX500Principal().getName(), cert.getSerialNumber());
-
+
sig.sign(getPrivateKey());
ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLUtils.outputDOM(doc, os);
XMLSignature newSig = getSignature(os.toByteArray());
-
+
assertNotNull(newSig.getKeyInfo().itemX509Data(0));
assertEquals(cert.getSubjectX500Principal().getName(),
newSig.getKeyInfo().itemX509Data(0).itemSubjectName(0).getSubjectName());
assertEquals(cert.getIssuerX500Principal().getName(),
newSig.getKeyInfo().itemX509Data(0).itemIssuerSerial(0).getIssuerName());
}
-
+
private XMLSignature getSignature(byte[] s) throws Exception {
- Document doc = XMLUtils.parse(new ByteArrayInputStream(s), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new ByteArrayInputStream(s));
Element el = (Element)doc.getFirstChild();
return new XMLSignature(el, "");
}
-
+
private KeyStore getKeyStore() throws Exception {
if (ks != null) {
return ks;
}
String keystoreType = "JKS";
String keystoreFile = "src/test/resources/org/apache/xml/security/samples/input/keystore.jks";
- String keystorePass = "xmlsecurity";
+ String keystorePass = "xmlsecurity";
ks = KeyStore.getInstance(keystoreType);
FileInputStream fis = null;
if (BASEDIR != null && !"".equals(BASEDIR)) {
@@ -94,18 +96,18 @@ public class X509DataTest extends org.ju
ks.load(fis, keystorePass.toCharArray());
return ks;
}
-
+
private X509Certificate getCertificate() throws Exception {
- String certificateAlias = "test";
+ String certificateAlias = "test";
X509Certificate cert =
(X509Certificate) getKeyStore().getCertificate(certificateAlias);
return cert;
}
-
+
private PrivateKey getPrivateKey() throws Exception {
String privateKeyAlias = "test";
- String privateKeyPass = "xmlsecurity";
- PrivateKey privateKey =
+ String privateKeyPass = "xmlsecurity";
+ PrivateKey privateKey =
(PrivateKey) getKeyStore().getKey(privateKeyAlias, privateKeyPass.toCharArray());
return privateKey;
}
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java Wed Jun 6 15:09:42 2018
@@ -26,6 +26,7 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -69,7 +70,8 @@ public class XmlSecTest extends org.juni
private void checkXmlSignatureSoftwareStack(boolean cert) throws Exception {
Init.init();
- Document testDocument = XMLUtils.newDocument(false);
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(false);
+ Document testDocument = documentBuilder.newDocument();
Element rootElement =
testDocument.createElementNS("urn:namespace", "tns:document");
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java Wed Jun 6 15:09:42 2018
@@ -20,6 +20,7 @@ package org.apache.xml.security.test.dom
import java.io.ByteArrayInputStream;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -103,8 +104,11 @@ public class TransformBase64DecodeTest e
+ "</Object>\n"
;
//J+
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
- Document doc = XMLUtils.parse(new ByteArrayInputStream(input.getBytes()), false, true, true);
+ db.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler());
+
+ Document doc = db.parse(new ByteArrayInputStream(input.getBytes()));
//XMLUtils.circumventBug2650(doc);
XPathFactory xpf = XPathFactory.newInstance();
@@ -132,7 +136,8 @@ public class TransformBase64DecodeTest e
}
private static Document createDocument() throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument(false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
if (doc == null) {
throw new RuntimeException("Could not create a Document");
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java Wed Jun 6 15:09:42 2018
@@ -88,7 +88,7 @@ public class TransformXSLTTest extends o
private static Document getDocument(File file)
throws ParserConfigurationException, SAXException, IOException {
- return XMLUtils.parse(new FileInputStream(file), false);
+ return XMLUtils.createDocumentBuilder(false).parse(new FileInputStream(file));
}
}
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java Wed Jun 6 15:09:42 2018
@@ -1,155 +1,156 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.xml.security.test.dom.transforms.implementations;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-
-import org.apache.xml.security.Init;
-import org.apache.xml.security.signature.XMLSignature;
-import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.XMLUtils;
-import org.w3c.dom.Element;
-
-public class Xpath2TransformationTest {
-
- static {
- Init.init();
- }
-
- @org.junit.Test
- public void testXpath2Transform() throws Exception {
- String sig="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
- "<edoc:EDOC xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:edoc=\"http://www.imtf.com/hypersuite/edoc/2.0/\" sysid=\"CC9CC230-C0A8024E01A3CA10-AC154F78\">\r\n" +
- " <edoc:Version>2.0</edoc:Version>\r\n" +
- " <edoc:Object edocVersion=\"2.0\">\r\n" +
- " <edoc:ObjectMetadata>\r\n" +
- " <edoc:ObjectType>Record</edoc:ObjectType>\r\n" +
- " <edoc:ObjectCreationDate>2004-12-13T14:27:35</edoc:ObjectCreationDate>\r\n" +
- " </edoc:ObjectMetadata>\r\n" +
- " <edoc:ObjectContent>\r\n" +
- " <edoc:Record>\r\n" +
- " <edoc:RecordMetadata></edoc:RecordMetadata>\r\n" +
- " <edoc:Document id=\"Revision-1-Document-1\">\r\n" +
- " <edoc:DocumentMetadata>\r\n" +
- " <dc:date>2003-07-20</dc:date>\r\n" +
- " <dc:type>20</dc:type>\r\n" +
- " <dc:format>PDF</dc:format>\r\n" +
- " <edoc:customer-number>222222</edoc:customer-number>\r\n" +
- " </edoc:DocumentMetadata>\r\n" +
- " <edoc:Encoding id=\"Revision-1-Document-1-Encoding-1\">\r\n" +
- " <edoc:EncodingMetadata>\r\n" +
- " </edoc:EncodingMetadata>\r\n" +
- " <edoc:ContentData encapsulation=\"Base64\" id=\"Revision-1-Document-1-Encoding-1-ContentData-1\" sourceFileSize=\"102550\">AAA</edoc:ContentData>\r\n" +
- " </edoc:Encoding>\r\n" +
- " </edoc:Document>\r\n" +
- " </edoc:Record>\r\n" +
- " </edoc:ObjectContent>\r\n" +
- " </edoc:Object>\r\n" +
- "<edoc:SignatureBlock id=\"Revision-1-Signature-1\"><edoc:SignatureDate>2006-08-09T17:21:35</edoc:SignatureDate><edoc:Signer>Hess Yvan (first signature)</edoc:Signer><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\r\n" +
- "<ds:SignedInfo>\r\n" +
- "<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"></ds:CanonicalizationMethod>\r\n" +
- "<ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"></ds:SignatureMethod>\r\n" +
- "<ds:Reference URI=\"\">\r\n" +
- "<ds:Transforms>\r\n" +
- "<ds:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\">\r\n" +
- "<dsig-xpath:XPath xmlns:dsig-xpath=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">/edoc:EDOC/edoc:Object</dsig-xpath:XPath>\r\n" +
- "</ds:Transform>\r\n" +
- "</ds:Transforms>\r\n" +
- "<ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></ds:DigestMethod>\r\n" +
- "<ds:DigestValue>YMXHTYArDBcWDG99epurfdSEAWM=</ds:DigestValue>\r\n" +
- "</ds:Reference>\r\n" +
- "</ds:SignedInfo>\r\n" +
- "<ds:SignatureValue>\r\n" +
- "Un2HBIOcwGe36k8eDEJISKP8/EmCp813JlmV0qqxIPVgdMsIJXR5Wky6uqwP+E3wAXj4NykW76GV\r\n" +
- "1eSD9dTKw/M/bFMbId0nBp0ZFaFE5DKU/My4956qr2oyJqiFRKOokCxds0jMQvGcKeWVC9oAROxR\r\n" +
- "byZQbrtjGw9YS+D5afY=\r\n" +
- "</ds:SignatureValue>\r\n" +
- "<ds:KeyInfo>\r\n" +
- "<ds:X509Data>\r\n" +
- "<ds:X509Certificate>\r\n" +
- "MIIDADCCAmmgAwIBAgIGAQpEtx7tMA0GCSqGSIb3DQEBBQUAMIGXMRQwEgYDVQQGEwtTd2l0emVy\r\n" +
- "bGFuZDERMA8GA1UECBMIRnJpYm91cmcxETAPBgNVBAcTCEdpdmlzaWV6MRUwEwYDVQQLEwxIeXBl\r\n" +
- "cnN1aXRlIDUxGTAXBgNVBAoTEEluZm9ybWF0aXF1ZS1NVEYxJzAlBgNVBAMTHklNVEYgUm9vdENl\r\n" +
- "cnRpZmljYXRlIEF1dGhvcml0eTAeFw0wNjAzMjgyMjAwMDBaFw0xNjAzMTcyMzAwMDBaMIGMMRQw\r\n" +
- "EgYDVQQGEwtTd2l0emVybGFuZDERMA8GA1UECBMIRnJpYm91cmcxETAPBgNVBAcTCEdpdmlzaWV6\r\n" +
- "MRUwEwYDVQQLEwxIeXBlcnN1aXRlIDUxGTAXBgNVBAoTEEluZm9ybWF0aXF1ZS1NVEYxHDAaBgNV\r\n" +
- "BAMTE0lNVEYgRW5kQ2VydGlmaWNhdGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOxpALzU\r\n" +
- "r8TjtFB7ghScWXdaDuHHRM7bPOoyuDSCxCznCBQitrwT/Un/vkZjDxSTG1bLWObqUMf1Yf6ul30n\r\n" +
- "nU9NsHO2fr7+YwtGnCV5vZ+qzWSQBY7qS+Gg8Ft9z0PluNRe84ukcQt7mdqSYet2qKbYWLP8tyFc\r\n" +
- "XCYs0JL5E6aTAgMBAAGjYDBeMB8GA1UdIwQYMBaAFIeIxHkuiPSRw5OArsqR7wZYgVPlMB0GA1Ud\r\n" +
- "DgQWBBRrfNhYheJHag+VBqDPWEOQyt3rqDAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIFoDAN\r\n" +
- "BgkqhkiG9w0BAQUFAAOBgQB4OVKzObDkpadteusbvcEin2GdK3B2qz/HwqH07AEt/pQbJ/oQOsYL\r\n" +
- "qVyDFt3umJ5uHon15nkps3HRE4MoYNfVbtz1G+0nMcAbxVYJDIfC4YBJRUAm/aA0twfkiH6gFmLi\r\n" +
- "V8o5YRtkjXvZQKUtJ/Ps/m0DAC4A935jTHDd6F4FCw==\r\n" +
- "</ds:X509Certificate>\r\n" +
- "</ds:X509Data>\r\n" +
- "</ds:KeyInfo>\r\n" +
- "</ds:Signature></edoc:SignatureBlock></edoc:EDOC>";
-
- String correctC14n="<edoc:Object xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:edoc=\"http://www.imtf.com/hypersuite/edoc/2.0/\" edocVersion=\"2.0\">\n" +
- " <edoc:ObjectMetadata>\n" +
- " <edoc:ObjectType>Record</edoc:ObjectType>\n" +
- " <edoc:ObjectCreationDate>2004-12-13T14:27:35</edoc:ObjectCreationDate>\n" +
- " </edoc:ObjectMetadata>\n" +
- " <edoc:ObjectContent>\n" +
- " <edoc:Record>\n" +
- " <edoc:RecordMetadata></edoc:RecordMetadata>\n" +
- " <edoc:Document id=\"Revision-1-Document-1\">\n" +
- " <edoc:DocumentMetadata>\n" +
- " <dc:date>2003-07-20</dc:date>\n" +
- " <dc:type>20</dc:type>\n" +
- " <dc:format>PDF</dc:format>\n" +
- " <edoc:customer-number>222222</edoc:customer-number>\n" +
- " </edoc:DocumentMetadata>\n" +
- " <edoc:Encoding id=\"Revision-1-Document-1-Encoding-1\">\n" +
- " <edoc:EncodingMetadata>\n" +
- " </edoc:EncodingMetadata>\n" +
- " <edoc:ContentData encapsulation=\"Base64\" id=\"Revision-1-Document-1-Encoding-1-ContentData-1\" sourceFileSize=\"102550\">AAA</edoc:ContentData>\n" +
- " </edoc:Encoding>\n" +
- " </edoc:Document>\n" +
- " </edoc:Record>\n" +
- " </edoc:ObjectContent>\n" +
- " </edoc:Object>";
-
- org.w3c.dom.Document doc = XMLUtils.parse(new ByteArrayInputStream(sig.getBytes()), false);
- Element sigElement =
- (Element) doc.getElementsByTagNameNS(
- Constants.SignatureSpecNS, Constants._TAG_SIGNATURE).item(0);
- XMLSignature sign = new XMLSignature(sigElement, "");
- boolean verify =
- sign.checkSignatureValue(sign.getKeyInfo().getPublicKey());
- if (!verify) {
- for (int i = 0; i < sign.getSignedInfo().getLength(); i++) {
- boolean refVerify =
- sign.getSignedInfo().getVerificationResult(i);
- if (!refVerify) {
- byte[] contentBytes =
- sign.getSignedInfo().item(i).getContentsAfterTransformation().getBytes();
- assertEquals(
- correctC14n,
- new String(contentBytes)
- );
- }
- }
- }
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.xml.security.test.dom.transforms.implementations;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.xml.security.Init;
+import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.utils.Constants;
+import org.apache.xml.security.utils.XMLUtils;
+import org.w3c.dom.Element;
+
+public class Xpath2TransformationTest extends org.junit.Assert {
+
+ static {
+ Init.init();
+ }
+
+ @org.junit.Test
+ public void testXpath2Transform() throws Exception {
+ String sig="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
+ "<edoc:EDOC xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:edoc=\"http://www.imtf.com/hypersuite/edoc/2.0/\" sysid=\"CC9CC230-C0A8024E01A3CA10-AC154F78\">\r\n" +
+ " <edoc:Version>2.0</edoc:Version>\r\n" +
+ " <edoc:Object edocVersion=\"2.0\">\r\n" +
+ " <edoc:ObjectMetadata>\r\n" +
+ " <edoc:ObjectType>Record</edoc:ObjectType>\r\n" +
+ " <edoc:ObjectCreationDate>2004-12-13T14:27:35</edoc:ObjectCreationDate>\r\n" +
+ " </edoc:ObjectMetadata>\r\n" +
+ " <edoc:ObjectContent>\r\n" +
+ " <edoc:Record>\r\n" +
+ " <edoc:RecordMetadata></edoc:RecordMetadata>\r\n" +
+ " <edoc:Document id=\"Revision-1-Document-1\">\r\n" +
+ " <edoc:DocumentMetadata>\r\n" +
+ " <dc:date>2003-07-20</dc:date>\r\n" +
+ " <dc:type>20</dc:type>\r\n" +
+ " <dc:format>PDF</dc:format>\r\n" +
+ " <edoc:customer-number>222222</edoc:customer-number>\r\n" +
+ " </edoc:DocumentMetadata>\r\n" +
+ " <edoc:Encoding id=\"Revision-1-Document-1-Encoding-1\">\r\n" +
+ " <edoc:EncodingMetadata>\r\n" +
+ " </edoc:EncodingMetadata>\r\n" +
+ " <edoc:ContentData encapsulation=\"Base64\" id=\"Revision-1-Document-1-Encoding-1-ContentData-1\" sourceFileSize=\"102550\">AAA</edoc:ContentData>\r\n" +
+ " </edoc:Encoding>\r\n" +
+ " </edoc:Document>\r\n" +
+ " </edoc:Record>\r\n" +
+ " </edoc:ObjectContent>\r\n" +
+ " </edoc:Object>\r\n" +
+ "<edoc:SignatureBlock id=\"Revision-1-Signature-1\"><edoc:SignatureDate>2006-08-09T17:21:35</edoc:SignatureDate><edoc:Signer>Hess Yvan (first signature)</edoc:Signer><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\r\n" +
+ "<ds:SignedInfo>\r\n" +
+ "<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"></ds:CanonicalizationMethod>\r\n" +
+ "<ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"></ds:SignatureMethod>\r\n" +
+ "<ds:Reference URI=\"\">\r\n" +
+ "<ds:Transforms>\r\n" +
+ "<ds:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\">\r\n" +
+ "<dsig-xpath:XPath xmlns:dsig-xpath=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">/edoc:EDOC/edoc:Object</dsig-xpath:XPath>\r\n" +
+ "</ds:Transform>\r\n" +
+ "</ds:Transforms>\r\n" +
+ "<ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></ds:DigestMethod>\r\n" +
+ "<ds:DigestValue>YMXHTYArDBcWDG99epurfdSEAWM=</ds:DigestValue>\r\n" +
+ "</ds:Reference>\r\n" +
+ "</ds:SignedInfo>\r\n" +
+ "<ds:SignatureValue>\r\n" +
+ "Un2HBIOcwGe36k8eDEJISKP8/EmCp813JlmV0qqxIPVgdMsIJXR5Wky6uqwP+E3wAXj4NykW76GV\r\n" +
+ "1eSD9dTKw/M/bFMbId0nBp0ZFaFE5DKU/My4956qr2oyJqiFRKOokCxds0jMQvGcKeWVC9oAROxR\r\n" +
+ "byZQbrtjGw9YS+D5afY=\r\n" +
+ "</ds:SignatureValue>\r\n" +
+ "<ds:KeyInfo>\r\n" +
+ "<ds:X509Data>\r\n" +
+ "<ds:X509Certificate>\r\n" +
+ "MIIDADCCAmmgAwIBAgIGAQpEtx7tMA0GCSqGSIb3DQEBBQUAMIGXMRQwEgYDVQQGEwtTd2l0emVy\r\n" +
+ "bGFuZDERMA8GA1UECBMIRnJpYm91cmcxETAPBgNVBAcTCEdpdmlzaWV6MRUwEwYDVQQLEwxIeXBl\r\n" +
+ "cnN1aXRlIDUxGTAXBgNVBAoTEEluZm9ybWF0aXF1ZS1NVEYxJzAlBgNVBAMTHklNVEYgUm9vdENl\r\n" +
+ "cnRpZmljYXRlIEF1dGhvcml0eTAeFw0wNjAzMjgyMjAwMDBaFw0xNjAzMTcyMzAwMDBaMIGMMRQw\r\n" +
+ "EgYDVQQGEwtTd2l0emVybGFuZDERMA8GA1UECBMIRnJpYm91cmcxETAPBgNVBAcTCEdpdmlzaWV6\r\n" +
+ "MRUwEwYDVQQLEwxIeXBlcnN1aXRlIDUxGTAXBgNVBAoTEEluZm9ybWF0aXF1ZS1NVEYxHDAaBgNV\r\n" +
+ "BAMTE0lNVEYgRW5kQ2VydGlmaWNhdGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOxpALzU\r\n" +
+ "r8TjtFB7ghScWXdaDuHHRM7bPOoyuDSCxCznCBQitrwT/Un/vkZjDxSTG1bLWObqUMf1Yf6ul30n\r\n" +
+ "nU9NsHO2fr7+YwtGnCV5vZ+qzWSQBY7qS+Gg8Ft9z0PluNRe84ukcQt7mdqSYet2qKbYWLP8tyFc\r\n" +
+ "XCYs0JL5E6aTAgMBAAGjYDBeMB8GA1UdIwQYMBaAFIeIxHkuiPSRw5OArsqR7wZYgVPlMB0GA1Ud\r\n" +
+ "DgQWBBRrfNhYheJHag+VBqDPWEOQyt3rqDAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIFoDAN\r\n" +
+ "BgkqhkiG9w0BAQUFAAOBgQB4OVKzObDkpadteusbvcEin2GdK3B2qz/HwqH07AEt/pQbJ/oQOsYL\r\n" +
+ "qVyDFt3umJ5uHon15nkps3HRE4MoYNfVbtz1G+0nMcAbxVYJDIfC4YBJRUAm/aA0twfkiH6gFmLi\r\n" +
+ "V8o5YRtkjXvZQKUtJ/Ps/m0DAC4A935jTHDd6F4FCw==\r\n" +
+ "</ds:X509Certificate>\r\n" +
+ "</ds:X509Data>\r\n" +
+ "</ds:KeyInfo>\r\n" +
+ "</ds:Signature></edoc:SignatureBlock></edoc:EDOC>";
+
+ String correctC14n="<edoc:Object xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:edoc=\"http://www.imtf.com/hypersuite/edoc/2.0/\" edocVersion=\"2.0\">\n" +
+ " <edoc:ObjectMetadata>\n" +
+ " <edoc:ObjectType>Record</edoc:ObjectType>\n" +
+ " <edoc:ObjectCreationDate>2004-12-13T14:27:35</edoc:ObjectCreationDate>\n" +
+ " </edoc:ObjectMetadata>\n" +
+ " <edoc:ObjectContent>\n" +
+ " <edoc:Record>\n" +
+ " <edoc:RecordMetadata></edoc:RecordMetadata>\n" +
+ " <edoc:Document id=\"Revision-1-Document-1\">\n" +
+ " <edoc:DocumentMetadata>\n" +
+ " <dc:date>2003-07-20</dc:date>\n" +
+ " <dc:type>20</dc:type>\n" +
+ " <dc:format>PDF</dc:format>\n" +
+ " <edoc:customer-number>222222</edoc:customer-number>\n" +
+ " </edoc:DocumentMetadata>\n" +
+ " <edoc:Encoding id=\"Revision-1-Document-1-Encoding-1\">\n" +
+ " <edoc:EncodingMetadata>\n" +
+ " </edoc:EncodingMetadata>\n" +
+ " <edoc:ContentData encapsulation=\"Base64\" id=\"Revision-1-Document-1-Encoding-1-ContentData-1\" sourceFileSize=\"102550\">AAA</edoc:ContentData>\n" +
+ " </edoc:Encoding>\n" +
+ " </edoc:Document>\n" +
+ " </edoc:Record>\n" +
+ " </edoc:ObjectContent>\n" +
+ " </edoc:Object>";
+
+ ByteArrayInputStream is = new ByteArrayInputStream(sig.getBytes());
+
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(is);
+ Element sigElement =
+ (Element) doc.getElementsByTagNameNS(
+ Constants.SignatureSpecNS, Constants._TAG_SIGNATURE).item(0);
+ XMLSignature sign = new XMLSignature(sigElement, "");
+ boolean verify =
+ sign.checkSignatureValue(sign.getKeyInfo().getPublicKey());
+ if (!verify) {
+ for (int i = 0; i < sign.getSignedInfo().getLength(); i++) {
+ boolean refVerify =
+ sign.getSignedInfo().getVerificationResult(i);
+ if (!refVerify) {
+ byte[] contentBytes =
+ sign.getSignedInfo().item(i).getContentsAfterTransformation().getBytes();
+ assertEquals(
+ correctC14n,
+ new String(contentBytes)
+ );
+ }
+ }
+ }
+ }
+
+}
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java Wed Jun 6 15:09:42 2018
@@ -49,7 +49,7 @@ public class ResolverDirectHTTPTest exte
@Test
public void testBug40783() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("id");
uri.setNodeValue("urn:ddd:uuu");
doc.createElement("test").setAttributeNode(uri);
@@ -64,7 +64,7 @@ public class ResolverDirectHTTPTest exte
@Test
@Ignore
public void testProxyAuth() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -73,7 +73,7 @@ public class ResolverDirectHTTPTest exte
resolverDirectHTTP.engineSetProperty("http.proxy.port", proxyPort);
resolverDirectHTTP.engineSetProperty("http.proxy.username", proxyUsername);
resolverDirectHTTP.engineSetProperty("http.proxy.password", proxyPassword);
- ResourceResolverContext context =
+ ResourceResolverContext context =
new ResourceResolverContext(uri, url, true);
resolverDirectHTTP.engineResolveURI(context);
}
@@ -81,7 +81,7 @@ public class ResolverDirectHTTPTest exte
@Test
@Ignore
public void testProxyAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -90,7 +90,7 @@ public class ResolverDirectHTTPTest exte
resolverDirectHTTP.engineSetProperty("http.proxy.port", proxyPort);
resolverDirectHTTP.engineSetProperty("http.proxy.username", proxyUsername);
resolverDirectHTTP.engineSetProperty("http.proxy.password", "wrongPassword");
- ResourceResolverContext context =
+ ResourceResolverContext context =
new ResourceResolverContext(uri, url, true);
try {
resolverDirectHTTP.engineResolveURI(context);
@@ -103,14 +103,14 @@ public class ResolverDirectHTTPTest exte
@Test
@Ignore
public void testServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
resolverDirectHTTP.engineSetProperty("http.basic.password", serverPassword);
- ResourceResolverContext context =
+ ResourceResolverContext context =
new ResourceResolverContext(uri, url, true);
resolverDirectHTTP.engineResolveURI(context);
}
@@ -118,14 +118,14 @@ public class ResolverDirectHTTPTest exte
@Test
@Ignore
public void testServerAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
ResolverDirectHTTP resolverDirectHTTP = new ResolverDirectHTTP();
resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
resolverDirectHTTP.engineSetProperty("http.basic.password", "wrongPassword");
- ResourceResolverContext context =
+ ResourceResolverContext context =
new ResourceResolverContext(uri, url, true);
try {
resolverDirectHTTP.engineResolveURI(context);
@@ -138,7 +138,7 @@ public class ResolverDirectHTTPTest exte
@Test
@Ignore
public void testProxyAndServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -149,7 +149,7 @@ public class ResolverDirectHTTPTest exte
resolverDirectHTTP.engineSetProperty("http.proxy.password", proxyPassword);
resolverDirectHTTP.engineSetProperty("http.basic.username", serverUsername);
resolverDirectHTTP.engineSetProperty("http.basic.password", serverPassword);
- ResourceResolverContext context =
+ ResourceResolverContext context =
new ResourceResolverContext(uri, url, true);
resolverDirectHTTP.engineResolveURI(context);
}
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java Wed Jun 6 15:09:42 2018
@@ -48,7 +48,7 @@ public class ResourceResolverTest extend
String className =
"org.apache.xml.security.test.dom.utils.resolver.OfflineResolver";
ResourceResolver.registerAtStart(className);
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uriAttr = doc.createAttribute("URI");
uriAttr.setValue("http://www.apache.org");
ResourceResolver res =
@@ -72,7 +72,7 @@ public class ResourceResolverTest extend
@org.junit.Test
public void testLocalFileWithEmptyBaseURI() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uriAttr = doc.createAttribute("URI");
String basedir = System.getProperty("basedir");
String file = new File(basedir, "pom.xml").toURI().toString();
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java Wed Jun 6 15:09:42 2018
@@ -280,7 +280,7 @@ public class Canonicalizer11Test extends
// dfactory.setNamespaceAware(true);
//
// DocumentBuilder db = dfactory.newDocumentBuilder();
-// Document doc = XMLUtils.newDocument(false);
+// Document doc = db.newDocument();
//
// xpath = XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_XPATH);
//
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java Wed Jun 6 15:09:42 2018
@@ -233,7 +233,7 @@ public class Canonicalizer20010315Exclus
*/
@org.junit.Test
public void test24Aexcl() throws Exception {
- Document doc = XMLUtils.newDocument(false);
+ Document doc = XMLUtils.createDocumentBuilder(false).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");
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java Wed Jun 6 15:09:42 2018
@@ -316,7 +316,7 @@ public class Canonicalizer20010315Test e
// dfactory.setNamespaceAware(true);
//
// DocumentBuilder db = dfactory.newDocumentBuilder();
-// Document doc = XMLUtils.newDocument(false);
+// Document doc = db.newDocument();
//
// xpath = XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_XPATH);
//
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java?rev=1833038&r1=1833037&r2=1833038&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java Wed Jun 6 15:09:42 2018
@@ -30,6 +30,7 @@ import java.security.spec.DSAPublicKeySp
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -81,7 +82,8 @@ public class ExclusiveC14NInteropTest ex
// Read in plaintext document
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream("interop/c14n/Y1/exc-signature.xml");
- Document document = XMLUtils.parse(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey();
@@ -102,7 +104,7 @@ public class ExclusiveC14NInteropTest ex
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(XMLUtils.newDocument(false), securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
private static PublicKey getPublicKey()