コード例 #1
0
 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);
 }
コード例 #2
0
  protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, OutputStream os)
      throws CanonicalizationException {
    try {
      String inclusiveNamespaces = null;

      if (this._transformObject.length(
              InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
              InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES)
          == 1) {
        Element inclusiveElement =
            XMLUtils.selectNode(
                this._transformObject.getElement().getFirstChild(),
                InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
                InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,
                0);

        inclusiveNamespaces =
            new InclusiveNamespaces(inclusiveElement, this._transformObject.getBaseURI())
                .getInclusiveNamespaces();
      }

      Canonicalizer20010315ExclOmitComments c14n = new Canonicalizer20010315ExclOmitComments();
      if (os != null) {
        c14n.setWriter(os);
      }
      byte[] result;
      if (input.isOctetStream()) {
        result = c14n.engineCanonicalize(input.get_Bytes());
      } else if (input.isElement()) {
        org.w3c.dom.Node excl = input.getExcludeNode();
        result = c14n.engineCanonicalizeSubTree(input.getSubNode(), inclusiveNamespaces, excl);
      } else {
        result = c14n.engineCanonicalizeXPathNodeSet(input.getNodeSet(), inclusiveNamespaces);
      }
      XMLSignatureInput output = new XMLSignatureInput(result);
      if (os != null) {
        output.setOutputStream(os);
      }
      return output;
    } catch (IOException ex) {
      throw new CanonicalizationException("empty", ex);
    } catch (ParserConfigurationException ex) {
      throw new CanonicalizationException("empty", ex);
    } catch (XMLSecurityException ex) {
      throw new CanonicalizationException("empty", ex);
    } catch (SAXException ex) {
      throw new CanonicalizationException("empty", ex);
    }
  }