Scott,

>
> Sorry, that's not the point. Is there a namespace *declaration* there? The
> fact that the DOM knows that it has that namespace is irrelevant to the c14n
> process, as far as I'm aware. If the DOM doesn't have the xmlns:ds
> attribute, you will not get it back out.
>

thanks for your hints :-) . Of course - the xmlns:ds attribute is the
important part. After checking the attributes of KeyInfo it turned out
that no xmlns:ds attribute was found.

The source code that creates the document uses the
org.apache.xml.security.keys.KeyInfo java class to create the keyinfo element
and to link it into the security header. Digging a bit deeper (via
"org.apache.xml.security.utils.SignatureElementProxy") I found the function
"createElementInSignatureSpace()" in "org.apache.xml.security.utils.XMLUtils".

This functions differs between 1.4.1 and 1.4.2 in some important lines when
it comes to add the xmlns:ds attribute to the KeyInfo element (see code
snippets below). Why was this modification done? I couldn't find documentation
about this on the xmlsec Web pages. Does KeyInfo expect the user of KeyInfo
to set the xmlns:ds attribute? Or is it just a simple, plain old bug? :-)

Regards,
Werner


Code snippets:

**** 1.4.1 :
   public static Element createElementInSignatureSpace(Document doc,
           String elementName) {

      if (doc == null) {
         throw new RuntimeException("Document is null");
      }


      if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
         Element element = doc.createElementNS(Constants.SignatureSpecNS,
                                               elementName);

         element.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
                                Constants.SignatureSpecNS);

         return element;
      }
      String namePrefix=(String) namePrefixes.get(elementName);
      if (namePrefix==null) {
          StringBuffer tag=new StringBuffer(dsPrefix);
          tag.append(':');
          tag.append(elementName);
          namePrefix=tag.toString();
          namePrefixes.put(elementName,namePrefix);
      }
         Element element = doc.createElementNS(Constants.SignatureSpecNS, 
namePrefix);
         element.setAttributeNS(Constants.NamespaceSpecNS, xmlnsDsPrefix,
                                Constants.SignatureSpecNS);

         return element;

   }

**** 1.4.2 :
   public static Element createElementInSignatureSpace(Document doc,
           String elementName) {

      if (doc == null) {
         throw new RuntimeException("Document is null");
      }

      if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
         return doc.createElementNS(Constants.SignatureSpecNS, elementName);
      }
      String namePrefix=(String) namePrefixes.get(elementName);
      if (namePrefix==null) {
          StringBuffer tag=new StringBuffer(dsPrefix);
          tag.append(':');
          tag.append(elementName);
          namePrefix=tag.toString();
          namePrefixes.put(elementName,namePrefix);
      }
      return doc.createElementNS(Constants.SignatureSpecNS, namePrefix);
   }

Reply via email to