src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
equal
deleted
inserted
replaced
31 import java.util.ArrayList; |
31 import java.util.ArrayList; |
32 import java.util.LinkedHashSet; |
32 import java.util.LinkedHashSet; |
33 import java.util.List; |
33 import java.util.List; |
34 import java.util.Set; |
34 import java.util.Set; |
35 |
35 |
36 import javax.xml.parsers.DocumentBuilder; |
|
37 import javax.xml.parsers.ParserConfigurationException; |
36 import javax.xml.parsers.ParserConfigurationException; |
38 |
37 |
39 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
38 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
40 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments; |
39 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments; |
41 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments; |
40 import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments; |
572 isNodeSet = b; |
571 isNodeSet = b; |
573 } |
572 } |
574 |
573 |
575 void convertToNodes() throws CanonicalizationException, |
574 void convertToNodes() throws CanonicalizationException, |
576 ParserConfigurationException, IOException, SAXException { |
575 ParserConfigurationException, IOException, SAXException { |
577 DocumentBuilder db = XMLUtils.createDocumentBuilder(false, secureValidation); |
|
578 // select all nodes, also the comments. |
576 // select all nodes, also the comments. |
579 try { |
577 try { |
580 db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils.IgnoreAllErrorHandler()); |
578 Document doc = XMLUtils.read(this.getOctetStream(), secureValidation); |
581 |
|
582 Document doc = db.parse(this.getOctetStream()); |
|
583 this.subNode = doc; |
579 this.subNode = doc; |
584 } catch (SAXException ex) { |
580 } catch (SAXException ex) { |
585 byte[] result = null; |
581 byte[] result = null; |
586 // if a not-wellformed nodeset exists, put a container around it... |
582 // if a not-wellformed nodeset exists, put a container around it... |
587 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { |
583 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { |
591 baos.write("</container>".getBytes(StandardCharsets.UTF_8)); |
587 baos.write("</container>".getBytes(StandardCharsets.UTF_8)); |
592 |
588 |
593 result = baos.toByteArray(); |
589 result = baos.toByteArray(); |
594 } |
590 } |
595 try (InputStream is = new ByteArrayInputStream(result)) { |
591 try (InputStream is = new ByteArrayInputStream(result)) { |
596 Document document = db.parse(is); |
592 Document document = XMLUtils.read(is, secureValidation); |
597 this.subNode = document.getDocumentElement().getFirstChild().getFirstChild(); |
593 this.subNode = document.getDocumentElement().getFirstChild().getFirstChild(); |
598 } |
594 } |
599 } finally { |
595 } finally { |
600 if (this.inputOctetStreamProxy != null) { |
596 if (this.inputOctetStreamProxy != null) { |
601 this.inputOctetStreamProxy.close(); |
597 this.inputOctetStreamProxy.close(); |