You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2020/05/12 14:46:44 UTC
svn commit: r1877660 - in
/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms:
implementations/ params/
Author: coheigea
Date: Tue May 12 14:46:44 2020
New Revision: 1877660
URL: http://svn.apache.org/viewvc?rev=1877660&view=rev
Log:
Code coverage work for the transformers
Removed:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPointer.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11_WithComments.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14NWithComments.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N.java?rev=1877660&r1=1877659&r2=1877660&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N.java Tue May 12 14:46:44 2020
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.OutputStream;
import org.apache.xml.security.c14n.CanonicalizationException;
+import org.apache.xml.security.c14n.implementations.Canonicalizer20010315;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315OmitComments;
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.transforms.TransformSpi;
@@ -53,7 +54,7 @@ public class TransformC14N extends Trans
String baseURI, boolean secureValidation
) throws CanonicalizationException {
- Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
+ Canonicalizer20010315 c14n = getCanonicalizer();
if (os == null) {
try (ByteArrayOutputStream writer = new ByteArrayOutputStream()) {
@@ -73,4 +74,8 @@ public class TransformC14N extends Trans
return output;
}
}
+
+ protected Canonicalizer20010315 getCanonicalizer() {
+ return new Canonicalizer20010315OmitComments();
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11.java?rev=1877660&r1=1877659&r2=1877660&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11.java Tue May 12 14:46:44 2020
@@ -18,23 +18,15 @@
*/
package org.apache.xml.security.transforms.implementations;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.xml.security.c14n.CanonicalizationException;
import org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments;
-import org.apache.xml.security.signature.XMLSignatureInput;
-import org.apache.xml.security.transforms.TransformSpi;
+import org.apache.xml.security.c14n.implementations.Canonicalizer20010315;
import org.apache.xml.security.transforms.Transforms;
-import org.w3c.dom.Element;
/**
* Implements the <CODE>http://www.w3.org/2006/12/xml-c14n11</CODE>
* (C14N 1.1) transform.
- *
*/
-public class TransformC14N11 extends TransformSpi {
+public class TransformC14N11 extends TransformC14N {
/**
* {@inheritDoc}
@@ -48,29 +40,8 @@ public class TransformC14N11 extends Tra
* {@inheritDoc}
*/
@Override
- protected XMLSignatureInput enginePerformTransform(
- XMLSignatureInput input, OutputStream os, Element transformElement,
- String baseURI, boolean secureValidation
- ) throws CanonicalizationException {
-
- Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
-
- if (os == null) {
- try (ByteArrayOutputStream writer = new ByteArrayOutputStream()) {
- c14n.engineCanonicalize(input, writer, secureValidation);
- writer.flush();
- XMLSignatureInput output = new XMLSignatureInput(writer.toByteArray());
- output.setSecureValidation(secureValidation);
- return output;
- } catch (IOException ex) {
- throw new CanonicalizationException("empty", new Object[] {ex.getMessage()});
- }
- } else {
- c14n.engineCanonicalize(input, os, secureValidation);
- XMLSignatureInput output = new XMLSignatureInput((byte[])null);
- output.setSecureValidation(secureValidation);
- output.setOutputStream(os);
- return output;
- }
+ protected Canonicalizer20010315 getCanonicalizer() {
+ return new Canonicalizer11_OmitComments();
}
+
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11_WithComments.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11_WithComments.java?rev=1877660&r1=1877659&r2=1877660&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11_WithComments.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14N11_WithComments.java Tue May 12 14:46:44 2020
@@ -18,23 +18,16 @@
*/
package org.apache.xml.security.transforms.implementations;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.xml.security.c14n.CanonicalizationException;
import org.apache.xml.security.c14n.implementations.Canonicalizer11_WithComments;
-import org.apache.xml.security.signature.XMLSignatureInput;
-import org.apache.xml.security.transforms.TransformSpi;
+import org.apache.xml.security.c14n.implementations.Canonicalizer20010315;
import org.apache.xml.security.transforms.Transforms;
-import org.w3c.dom.Element;
/**
* Implements the <CODE>http://www.w3.org/2006/12/xml-c14n-11#WithComments</CODE>
* (C14N 1.1 With Comments) transform.
*
*/
-public class TransformC14N11_WithComments extends TransformSpi {
+public class TransformC14N11_WithComments extends TransformC14N {
/**
* {@inheritDoc}
@@ -48,28 +41,7 @@ public class TransformC14N11_WithComment
* {@inheritDoc}
*/
@Override
- protected XMLSignatureInput enginePerformTransform(
- XMLSignatureInput input, OutputStream os, Element transformElement,
- String baseURI, boolean secureValidation
- ) throws CanonicalizationException {
-
- Canonicalizer11_WithComments c14n = new Canonicalizer11_WithComments();
- if (os == null) {
- try (ByteArrayOutputStream writer = new ByteArrayOutputStream()) {
- c14n.engineCanonicalize(input, writer, secureValidation);
- writer.flush();
- XMLSignatureInput output = new XMLSignatureInput(writer.toByteArray());
- output.setSecureValidation(secureValidation);
- return output;
- } catch (IOException ex) {
- throw new CanonicalizationException("empty", new Object[] {ex.getMessage()});
- }
- } else {
- c14n.engineCanonicalize(input, os, secureValidation);
- XMLSignatureInput output = new XMLSignatureInput((byte[])null);
- output.setSecureValidation(secureValidation);
- output.setOutputStream(os);
- return output;
- }
+ protected Canonicalizer20010315 getCanonicalizer() {
+ return new Canonicalizer11_WithComments();
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14NWithComments.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14NWithComments.java?rev=1877660&r1=1877659&r2=1877660&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14NWithComments.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformC14NWithComments.java Tue May 12 14:46:44 2020
@@ -18,23 +18,15 @@
*/
package org.apache.xml.security.transforms.implementations;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.xml.security.c14n.CanonicalizationException;
+import org.apache.xml.security.c14n.implementations.Canonicalizer20010315;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315WithComments;
-import org.apache.xml.security.signature.XMLSignatureInput;
-import org.apache.xml.security.transforms.TransformSpi;
import org.apache.xml.security.transforms.Transforms;
-import org.w3c.dom.Element;
/**
* Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CODE>
* transform.
- *
*/
-public class TransformC14NWithComments extends TransformSpi {
+public class TransformC14NWithComments extends TransformC14N {
/**
* {@inheritDoc}
@@ -48,29 +40,8 @@ public class TransformC14NWithComments e
* {@inheritDoc}
*/
@Override
- protected XMLSignatureInput enginePerformTransform(
- XMLSignatureInput input, OutputStream os, Element transformElement,
- String baseURI, boolean secureValidation
- ) throws CanonicalizationException {
-
- Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
-
- if (os == null) {
- try (ByteArrayOutputStream writer = new ByteArrayOutputStream()) {
- c14n.engineCanonicalize(input, writer, secureValidation);
- writer.flush();
- XMLSignatureInput output = new XMLSignatureInput(writer.toByteArray());
- output.setSecureValidation(secureValidation);
- return output;
- } catch (IOException ex) {
- throw new CanonicalizationException("empty", new Object[] {ex.getMessage()});
- }
- } else {
- c14n.engineCanonicalize(input, os, secureValidation);
- XMLSignatureInput output = new XMLSignatureInput((byte[])null);
- output.setSecureValidation(secureValidation);
- output.setOutputStream(os);
- return output;
- }
+ protected Canonicalizer20010315 getCanonicalizer() {
+ return new Canonicalizer20010315WithComments();
}
+
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java?rev=1877660&r1=1877659&r2=1877660&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java Tue May 12 14:46:44 2020
@@ -90,6 +90,7 @@ public class TransformXPath2Filter exten
inputDoc = XMLUtils.getOwnerDocument(input.getNodeSet());
}
+ XPathFactory xpathFactory = XPathFactory.newInstance();
for (int i = 0; i < xpathElements.length; i++) {
Element xpathElement = xpathElements[i];
@@ -99,7 +100,6 @@ public class TransformXPath2Filter exten
String str =
XMLUtils.getStrFromNode(xpathContainer.getXPathFilterTextNode());
- XPathFactory xpathFactory = XPathFactory.newInstance();
XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
NodeList subtreeRoots =