protected void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException { if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty() || inclusiveNSSet.isEmpty()) { return; } Document doc = null; if (input.getSubNode() != null) { doc = XMLUtils.getOwnerDocument(input.getSubNode()); } else { doc = XMLUtils.getOwnerDocument(input.getNodeSet()); } XMLUtils.circumventBug2650(doc); } }
protected void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException { if (!input.isNeedsToBeExpanded()) { return; } Document doc = null; if (input.getSubNode() != null) { doc = XMLUtils.getOwnerDocument(input.getSubNode()); } else { doc = XMLUtils.getOwnerDocument(input.getNodeSet()); } XMLUtils.circumventBug2650(doc); }
private Set getNodeSet(List nodeFilters) { if (xi.isNeedsToBeExpanded()) { XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(xi.getSubNode())); } Set inputSet = new LinkedHashSet(); XMLUtils.getSet(xi.getSubNode(), inputSet, null, !xi.isExcludeComments()); Set nodeSet = new LinkedHashSet(); Iterator i = inputSet.iterator(); while (i.hasNext()) { Node currentNode = (Node) i.next(); Iterator it = nodeFilters.iterator(); boolean skipNode = false; while (it.hasNext() && !skipNode) { NodeFilter nf = (NodeFilter) it.next(); if (nf.isNodeInclude(currentNode) != 1) { skipNode = true; } } if (!skipNode) { nodeSet.add(currentNode); } } return nodeSet; } }
private Set<Node> getNodeSet(List<NodeFilter> nodeFilters) { if (xi.isNeedsToBeExpanded()) { XMLUtils.circumventBug2650 (XMLUtils.getOwnerDocument(xi.getSubNode())); } Set<Node> inputSet = new LinkedHashSet<Node>(); XMLUtils.getSet(xi.getSubNode(), inputSet, null, !xi.isExcludeComments()); Set<Node> nodeSet = new LinkedHashSet<Node>(); for (Node currentNode : inputSet) { Iterator<NodeFilter> it = nodeFilters.iterator(); boolean skipNode = false; while (it.hasNext() && !skipNode) { NodeFilter nf = it.next(); if (nf.isNodeInclude(currentNode) != 1) { skipNode = true; } } if (!skipNode) { nodeSet.add(currentNode); } } return nodeSet; } }
private <TObj> TObj getReferencedElement( String objReference, Map<Element, TObj> mapper) { if (!objReference.startsWith("#")) throw new IllegalArgumentException(); if (mapper.isEmpty()) return null; // A little workaround to be able to use the ResourceResolver. Attr refAttr = this.signatureDoc.createAttributeNS(null, "ref"); refAttr.setNodeValue(objReference); this.signatureDoc.createElementNS(null, "dummy").setAttributeNodeNS(refAttr); try { XMLSignatureInput refData = ResourceResolver.getInstance(refAttr, "", true).resolve(refAttr, "", true); // This has to be a NodeSet data because it is a same-document reference. Node refNode = refData.getSubNode(); if (refNode.getNodeType() != Node.ELEMENT_NODE) return null; // May return null. return mapper.get((Element)refNode); } catch (ResourceResolverException ex) { // Maybe an exception should be thrown... return null; } } }
/** * 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; }
Node sPropsNode = signedPropsRef.getNodesetBeforeFirstCanonicalization().getSubNode(); if (sPropsNode == null || sPropsNode.getNodeType() != Node.ELEMENT_NODE)
XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(((OctetStreamData)data).getOctetStream()); str = (Element)xmlSignatureInput.getSubNode(); } catch (Exception ex) { throw new TransformException(ex);
XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(((OctetStreamData)data).getOctetStream()); str = (Element)xmlSignatureInput.getSubNode(); } catch (Exception ex) { throw new TransformException(ex);
XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(((OctetStreamData)data).getOctetStream()); str = (Element)xmlSignatureInput.getSubNode(); } catch (Exception ex) { throw new TransformException(ex);
return engineCanonicalizeSubTree(input.getSubNode(), input.getExcludeNode()); } else if (input.isNodeSet()) { nodeFilter = input.getNodeFilters(); if (input.getSubNode() != null) { return engineCanonicalizeXPathNodeSetInternal(input.getSubNode()); } else { return engineCanonicalizeXPathNodeSet(input.getNodeSet());
return new OctetStreamData(new ByteArrayInputStream (apacheCanonicalizer.canonicalizeSubtree (in.getSubNode(), inclusiveNamespaces))); } else { return new OctetStreamData(new ByteArrayInputStream (apacheCanonicalizer.canonicalizeSubtree (in.getSubNode())));
) throws IOException, CanonicalizationException, TransformationException { if (input.isElement()) { Node el = input.getSubNode(); if (input.getSubNode().getNodeType() == Node.TEXT_NODE) { el = el.getParentNode();
(input.getSubNode(), input.isExcludeComments()); } else if (input.isOctetStream() || input.isByteArray()) { try {
(xsi.getSubNode(), xsi.isExcludeComments()); } else if (xsi.isOctetStream() || xsi.isByteArray()) { try {
if (input.getSubNode() != null) { inputDoc = XMLUtils.getOwnerDocument(input.getSubNode()); } else { inputDoc = XMLUtils.getOwnerDocument(input.getNodeSet());
if (r.getContentsAfterTransformation().getSubNode() == targetSigValueElem) else if (r.getContentsBeforeTransformation().getSubNode() == targetSigValueElem && CanonicalizerUtils.allTransformsAreC14N(r))