You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2019/09/04 17:01:15 UTC

svn commit: r1866406 - in /poi/trunk/src: ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java testcases/org/apache/poi/POIDataSamples.java

Author: fanningpj
Date: Wed Sep  4 17:01:15 2019
New Revision: 1866406

URL: http://svn.apache.org/viewvc?rev=1866406&view=rev
Log:
remove debug code

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java
    poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java
    poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java?rev=1866406&r1=1866405&r2=1866406&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java Wed Sep  4 17:01:15 2019
@@ -19,7 +19,6 @@ package org.apache.poi.ooxml.util;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.util.concurrent.TimeUnit;
 
@@ -28,11 +27,6 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.events.Namespace;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -102,33 +96,6 @@ public final class DocumentHelper {
         }
     }
 
-    public static String domToString(Node node) throws Exception {
-        TransformerFactory tf = TransformerFactory.newInstance();
-        Transformer t = tf.newTransformer();
-        t.setOutputProperty(OutputKeys.INDENT, "yes");
-        StringWriter sw = new StringWriter();
-        t.transform(new DOMSource(node), new StreamResult(sw));
-        return sw.toString();
-    }
-
-    public static Attr findIdAttr(Element e, String name) throws Exception {
-        Attr att = e.getAttributeNode("Id");
-        if(att != null && name.equals(att.getValue())) {
-            return att;
-        }
-        NodeList nl = e.getChildNodes();
-        for (int i = 0; i < nl.getLength(); i++) {
-            Node child = nl.item(i);
-            if (child instanceof Element) {
-                Attr x = findIdAttr((Element)child, name);
-                if (x != null) {
-                    return x;
-                }
-            }
-        }
-        return null;
-    }
-
     static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
     static {
         documentBuilderFactory.setNamespaceAware(true);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java?rev=1866406&r1=1866405&r2=1866406&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java Wed Sep  4 17:01:15 2019
@@ -70,7 +70,8 @@ import org.etsi.uri.x01903.v13.SignedSig
 import org.etsi.uri.x01903.v13.SignerRoleType;
 import org.w3.x2000.x09.xmldsig.DigestMethodType;
 import org.w3.x2000.x09.xmldsig.X509IssuerSerialType;
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 /**
  * XAdES Signature Facet. Implements XAdES v1.4.1 which is compatible with XAdES
@@ -223,32 +224,10 @@ public class XAdESSignatureFacet extends
     private XMLObject addXadesObject(Document document, QualifyingPropertiesType qualifyingProperties) {
         Node qualDocElSrc = qualifyingProperties.getDomNode();
         Node qualDocEl = document.importNode(qualDocElSrc, true);
-        markIds(qualDocEl);
         List<XMLStructure> xadesObjectContent = Arrays.asList(new DOMStructure(qualDocEl));
         return getSignatureFactory().newXMLObject(xadesObjectContent, null, null, null);
     }
 
-    private void markIds(Node node) {
-        if (node instanceof Element) {
-            markIds((Element)node);
-        } else if (node instanceof Document) {
-            markIds(((Document)node).getDocumentElement());
-        }
-    }
-
-    private void markIds(Element element) {
-        if (element != null) {
-            Attr att = element.getAttributeNode("Id");
-            if (att != null) {
-                element.setIdAttributeNode(att, true);
-            }
-            NodeList nl = element.getChildNodes();
-            for (int i = 0; i < nl.getLength(); i++) {
-                markIds(nl.item(i));
-            }
-        }
-    }
-
     private Reference addXadesReference() throws XMLSignatureException {
         List<Transform> transforms = singletonList(newTransform(CanonicalizationMethod.INCLUSIVE));
         return newReference("#"+signatureConfig.getXadesSignatureId(), transforms, XADES_TYPE, null, null);

Modified: poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java?rev=1866406&r1=1866405&r2=1866406&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java Wed Sep  4 17:01:15 2019
@@ -117,9 +117,6 @@ public final class POIDataSamples {
     }
 
     public static POIDataSamples getXmlDSignInstance() {
-        if (System.getProperty(TEST_PROPERTY) == null) {
-            System.setProperty(TEST_PROPERTY, "../../test-data");
-        }
         if(_instXmlDSign == null) _instXmlDSign = new POIDataSamples("xmldsign");
         return _instXmlDSign;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org