/** * Resolve the Element effectively represented by the XML signature input source. * * @param resource * @return the Element effectively represented by the XML signature input source. * @throws CanonicalizationException * @throws ParserConfigurationException * @throws IOException * @throws SAXException * @throws KeyResolverException */ private Element obtainReferenceElement(XMLSignatureInput resource) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException, KeyResolverException { Element e; if (resource.isElement()){ e = (Element) resource.getSubNode(); } else if (resource.isNodeSet()) { LOG.debug("De-reference of KeyInfoReference returned an unsupported NodeSet"); return null; } else { // Retrieved resource is a byte stream byte inputBytes[] = resource.getBytes(); e = getDocFromBytes(inputBytes, this.secureValidation); } return e; } }
private static Element obtainReferenceElement(XMLSignatureInput resource, boolean secureValidation) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException, KeyResolverException { Element e; if (resource.isElement()){ e = (Element) resource.getSubNode(); } else if (resource.isNodeSet()) { // Retrieved resource is a nodeSet e = getDocumentElement(resource.getNodeSet()); } else { // Retrieved resource is an inputStream byte inputBytes[] = resource.getBytes(); e = getDocFromBytes(inputBytes, secureValidation); // otherwise, we parse the resource, create an Element and delegate LOG.debug("we have to parse {} bytes", inputBytes.length); } return e; }
/** * Method toString * {@inheritDoc} */ public String toString() { if (isNodeSet()) { return "XMLSignatureInput/NodeSet/" + inputNodeSet.size() + " nodes/" + getSourceURI(); } if (isElement()) { return "XMLSignatureInput/Element/" + subNode + " exclude "+ excludeNode + " comments:" + excludeComments +"/" + getSourceURI(); } try { return "XMLSignatureInput/OctetStream/" + getBytes().length + " octets/" + getSourceURI(); } catch (IOException iex) { return "XMLSignatureInput/OctetStream//" + getSourceURI(); } catch (CanonicalizationException cex) { return "XMLSignatureInput/OctetStream//" + getSourceURI(); } }
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); } }
XMLSignatureInput in = ((ApacheData)data).getXMLSignatureInput(); if (in.isElement()) { if (inclusiveNamespaces != null) { return new OctetStreamData(new ByteArrayInputStream
return null; } else if (xsi.isElement()) { return new DOMSubTreeData (xsi.getSubNode(), xsi.isExcludeComments());
} else if (input.isElement()) { referenceData = new ReferenceSubTreeData (input.getSubNode(), input.isExcludeComments());
protected XMLSignatureInput enginePerformTransform( XMLSignatureInput input, OutputStream os, Transform transformObject ) throws IOException, CanonicalizationException, TransformationException { if (input.isElement()) { Node el = input.getSubNode(); if (input.getSubNode().getNodeType() == Node.TEXT_NODE) {
if (!in.isNodeSet() && !in.isElement()) { return null;
if (os != null) { in = apacheTransform.performTransform(in, os); if (!in.isNodeSet() && !in.isElement()) { return null;
return engineCanonicalize(input.getBytes()); if (input.isElement()) { return engineCanonicalizeSubTree(input.getSubNode(), input.getExcludeNode()); } else if (input.isNodeSet()) {