public ApacheOctetStreamData(XMLSignatureInput xi) throws CanonicalizationException, IOException { super(xi.getOctetStream(), xi.getSourceURI(), xi.getMIMEType()); this.xi = xi; }
XMLUtils.createDocumentBuilder(false, secureValidation).parse(input.getOctetStream());
void convertToNodes() throws CanonicalizationException, ParserConfigurationException, IOException, SAXException { DocumentBuilder db = XMLUtils.createDocumentBuilder(false, secureValidation); // select all nodes, also the comments. try { db.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler()); Document doc = db.parse(this.getOctetStream()); this.subNode = doc; } catch (SAXException ex) { byte[] result = null; // if a not-wellformed nodeset exists, put a container around it... try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { baos.write("<container>".getBytes(StandardCharsets.UTF_8)); baos.write(this.getBytes()); baos.write("</container>".getBytes(StandardCharsets.UTF_8)); result = baos.toByteArray(); } try (InputStream is = new ByteArrayInputStream(result)) { Document document = db.parse(is); this.subNode = document.getDocumentElement().getFirstChild().getFirstChild(); } } finally { XMLUtils.repoolDocumentBuilder(db); if (this.inputOctetStreamProxy != null) { this.inputOctetStreamProxy.close(); } this.inputOctetStreamProxy = null; this.bytes = null; } }
return null; return new OctetStreamData(output.getOctetStream()); } catch (Exception ex) { throw new TransformException(ex);
return null; return new OctetStreamData(output.getOctetStream()); } catch (Exception ex) { throw new TransformException(ex);
private void addToDigestInput(XMLSignatureInput refData, Document doc) throws CannotAddDataToDigestInputException { try { if (refData.isNodeSet() || refData.isElement()) { Transform c14nTransform = TransformUtils.createTransform(this.c14n, this.parametersMarshallingProvider, doc); refData = c14nTransform.performTransform(refData); // Fall through to add the bytes resulting from the canonicalization. } if (refData.isByteArray()) { digestInput.write(refData.getBytes()); } else if (refData.isOctetStream()) { StreamUtils.readWrite(refData.getOctetStream(), digestInput); } } catch (Exception ex) { throw new CannotAddDataToDigestInputException(ex); } }
try { referenceData = new ReferenceOctetStreamData (input.getOctetStream(), input.getSourceURI(), input.getMIMEType()); } catch (IOException ioe) {
return new OctetStreamData(new ByteArrayInputStream( apacheCanonicalizer.canonicalize( Utils.readBytesFromStream(in.getOctetStream()))));
try { return new OctetStreamData (xsi.getOctetStream(), xsi.getSourceURI(), xsi.getMIMEType()); } catch (IOException ioe) {