Produce Canonical Form of XML Message

Discussions

XML & Web services: Produce Canonical Form of XML Message

  1. Produce Canonical Form of XML Message (7 messages)

    Can anyone tell me (or point me to an article that tells me) how to produce a canonical form of an XML message using Java. I need to do this before I produce a public / private key pair signature for the message.

    If anyone knows of a good article on Canonical form I would be interested in that too. The only document that I have managed to find is the W3C white paper and that is completely illegable.

    Thanks in advance,
    Adrian

    Threaded Messages (7)

  2. Produce Canonical Form of XML Message[ Go to top ]

    One of the obvious approaches to this problem would be with an XSLT stylesheet and perform a transform on the XML. Anyone know where I might find a stylesheet for this? I can't help feeling that this is a standard transform and that there therefore should be a standard stylesheet for it.

    Adrian
  3. http://xml.apache.org/security/Java/api/org/apache/xml/security/transforms/Transforms.html

    There are some transform classes that automatically do that for you. There are examples on how to do this in the Axis 1.1 samples directory. Tried searching but looks like I have deleted them out of my machine. Download that and I am sure there is an example showing u how to do that.
  4. This looks like the exact sort of thing that we have been looking for. Thanks very much. Now all I have to do is work out how to use it.

    There appear to be four types of canonical form:

    EXCL_OMIT_COMMENTS
    EXCL_WITH_COMMENTS
    OMIT_COMMENTS
    WITH_COMMENTS


    I understand the dfifference between with and without comments but what doies the EXCL bit mean?

    Adrian
  5. Produce Canonical Form of XML Message[ Go to top ]

    As far as I can see this is something to do with signing sub parts of the message within a message that is already signed.

    It would appear from the examples that come with the above specified API that you would specifiy the type of canonical form that you want by passing in the URI of the W3C specification. e.g.:

    Canonicalizer c14n = Canonicalizer.getInstance(
    "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments");

    1) Anyone know if this is right?
    2) Anyone know the URI for the without comments form?

    Adrian
  6. Produce Canonical Form of XML Message[ Go to top ]

    Ok, the following produces the canonical form without comments:

    Canonicalizer c14n = Canonicalizer.getInstance(
    "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");

    So that leaves just one problem. To get this to work I have had to use java 5. When I tried it with Java 1.4 I got a NoClassDef exception on DocumentRange. Does anyone know why I am getting this and what I can do about it.

    I have read about the Xalan problem and I have placed xalan.jar in the endorsed directoy of my java 1.4 as required so I don't think this is the problem.

    Please help, I really do have to use 1.4 for this.

    Thanks,
    Adrian
  7. Finally found the solution. It was just me beiong stupid, as usual.

    I hadn't included the xml-apis.jar file on the classpath.

    Adrian
  8. xml canonicalizer[ Go to top ]

    Can anyone tell me (or point me to an article that tells me) how to produce a canonical form of an XML message using Java.

    How about using an XML Canonicalizer?

    Sincerly,
    The Stylus Studio Team
    --
    --
    About Stylus Studio: Stylus Studio is the industry's most innovative XML IDE providing advanced support for XML and its related technologies: XSL, XSLT, XML Schema , DTD , SOAP, WSDL, EDI , EDIFACT, SQL/XML, XML Mapping , Web services, Legacy data integration and XQuery. Used by leading software developers world-wide, Stylus Studio simplifies XML programming and enhances developer productivity through innovation. Visit the Stylus Studio Web site to learn more, or download a free trial today.