views:

134

answers:

0

Hi, I'm making a tool to create some xml files signed, and I need to use an XPath so my sign doesn't sign itself :

  <ds:Transforms>
    <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"&gt;
      <ds:XPath>not(ancestor-or-self::ds:Signature)</ds:XPath>
    </ds:Transform>
    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
  </ds:Transforms>

When I only set

List transforms = new ArrayList();   
transforms.add(fac.newTransform(CanonicalizationMethod.EXCLUSIVE,(TransformParameterSpec) null));

everything is fine, but when I add

List transforms = new ArrayList();
transforms.add(fac.newTransform(Transform.XPATH,
       new XPathFilterParameterSpec("not(ancestor-or-self::ds:Signature)",Collections.singletonMap("ds", XMLSignature.XMLNS))));*/
transforms.add(fac.newTransform(CanonicalizationMethod.EXCLUSIVE,(TransformParameterSpec) null));

it messes up with my xmlns tags by adding xmlns="" like this :

<KeyContainer xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Version="1.0" xmlns="urn:ietf:params:xml:ns:keyprov:pskc:1.0">
<EncryptionKey xmlns="">

It is like if I needed to set explicitely to all childrens of the document their namespaces... and if I set it here it what it does :

What did I miss