XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Java 1.5.5
    • None
    • Java
    • None

    Description

      When using an XPath2 filter, and you don't add:
      domSignContext.putNamespacePrefix(Transform.XPATH2, "xpath2");
      the marshalling completely fails as XPath receives a ds: prefix, instead of a prefix pointing to
      http://www.w3.org/2002/06/xmldsig-filter2

      This should not happen.

      Example code:
      DOMSignContext domSignContext = new DOMSignContext(privateKey, parentElement);
      domSignContext.setDefaultNamespacePrefix("ds");
      // next is required for correct marshalling
      domSignContext.putNamespacePrefix(Transform.XPATH2, "xpath2");

      XMLSignatureFactory xmlSignatureFactory = XMLSignatureFactory
      .getInstance("DOM", new XMLDSigRI());

      List<Reference> references = new LinkedList<Reference>();
      List<Transform> transforms = new LinkedList<Transform>();
      List<XPathType> types = new LinkedList<XPathType>();
      Map<String, String> xpathNamespaceMap = new HashMap<String, String>();
      xpathNamespaceMap.put("ds", "http://www.w3.org/2000/09/xmldsig#");
      types.add(new XPathType("/descendant::*[name()='ds:Signature']",
      XPathType.Filter.SUBTRACT, xpathNamespaceMap));
      Transform envelopedTransform = xmlSignatureFactory.newTransform(
      CanonicalizationMethod.XPATH2, new XPathFilter2ParameterSpec(
      types));
      transforms.add(envelopedTransform);
      transforms.add(xmlSignatureFactory.newTransform(
      CanonicalizationMethod.EXCLUSIVE,
      (C14NMethodParameterSpec) null));
      Reference reference = xmlSignatureFactory.newReference("",
      xmlSignatureFactory.newDigestMethod(DigestMethod.SHA256, null),
      transforms, null, null);
      references.add(reference);
      ...

      Attachments

        1. SANTUARIO-370-test-case.patch
          14 kB
          Frank Cornelis
        2. DOMUtils-SANTUARIO-370.patch
          0.9 kB
          Frank Cornelis

        Activity

          People

            coheigea Colm O hEigeartaigh
            frank.cornelis Frank Cornelis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: