|
From: <pe...@us...> - 2004-03-02 23:42:50
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/java/org/neuclear/xml/c14 Modified Files: Canonicalizer.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. Index: Canonicalizer.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Canonicalizer.java 19 Feb 2004 19:37:33 -0000 1.9 --- Canonicalizer.java 2 Mar 2004 23:30:43 -0000 1.10 *************** *** 8,11 **** --- 8,18 ---- * $Id$ * $Log$ + * Revision 1.10 2004/03/02 23:30:43 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.9 2004/02/19 19:37:33 pelle * At times IntelliJ IDEA can cause some real hassle. On my last checkin it optimized away all of the dom4j and command line imports. *************** *** 126,131 **** */ - import org.dom4j.tree.NamespaceStack; import org.dom4j.*; import org.neuclear.xml.ElementProxy; import org.neuclear.xml.XMLTools; --- 133,139 ---- */ import org.dom4j.*; + import org.dom4j.tree.NamespaceStack; + import org.neuclear.commons.Utility; import org.neuclear.xml.ElementProxy; import org.neuclear.xml.XMLTools; *************** *** 331,336 **** final int previouslyDeclaredNamespaces = namespaceStack.size(); - final Namespace ns = element.getNamespace(); final TreeMap sorted = new TreeMap(); if (isNamespaceDeclaration(ns)) { namespaceStack.push(ns); --- 339,348 ---- final int previouslyDeclaredNamespaces = namespaceStack.size(); final TreeMap sorted = new TreeMap(); + + if (previouslyDeclaredNamespaces == 0) { + writeParentNS(element, sorted); + } + final Namespace ns = element.getNamespace(); if (isNamespaceDeclaration(ns)) { namespaceStack.push(ns); *************** *** 373,376 **** --- 385,400 ---- } + private void writeParentNS(final Element element, final TreeMap sorted) throws IOException { + Element parent = element.getParent(); + if (parent != null) { + final Namespace ns = parent.getNamespace(); + if (isNamespaceDeclaration(ns)) { + namespaceStack.push(ns); + writeNamespace(ns, sorted); + } + writeParentNS(parent, sorted); + } + } + private void writeNamespace(final Namespace namespace, final TreeMap sorted) throws IOException { if (namespace != null) { *************** *** 417,420 **** --- 441,449 ---- private void writeNSAttribute(final Namespace namespace) throws IOException { final String prefix = namespace.getPrefix(); + + // TODO This breaks example 3 from the Merlin Eight, but I'm not sure how to go about fixing it, due to DOM4J's + // nondifferentiation between <test/> and <test xmlns=""/> + if (Utility.isEmpty(prefix) && Utility.isEmpty(namespace.getURI())) + return; writer.write(" xmlns"); if (prefix != null && prefix.length() > 0) { |