diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2007-01-25 12:57:57 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2007-01-25 12:57:57 +0300 |
commit | b2f49647aaa8a62b90c21db8211cbe15723dd132 (patch) | |
tree | d54e4c345846a6d0fdc13b9048a39c028b4041a2 /mcs/class/System.Security/System.Security.Cryptography.Xml | |
parent | 7a2a2a92225f55a8610c38a5c6ea619c84204dfd (diff) |
2007-01-25 Atsushi Enomoto <atsushi@ximian.com>
* SignedXml.cs : for DataObject, copy namespaces in Data into Object
element itself. I haven't solved the puzzle on why it is needed
though.
* SignedXmlTest.cs : enable SignElementWithPrefixedNamespace().
svn path=/trunk/mcs/; revision=71658
Diffstat (limited to 'mcs/class/System.Security/System.Security.Cryptography.Xml')
-rw-r--r-- | mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs | 21 |
2 files changed, 18 insertions, 9 deletions
diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog b/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog index 4f62ac57972..ede1181f27f 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog @@ -1,3 +1,9 @@ +2007-01-25 Atsushi Enomoto <atsushi@ximian.com> + + * SignedXml.cs : for DataObject, copy namespaces in Data into Object + element itself. I haven't solved the puzzle on why it is needed + though. + 2007-01-23 Atsushi Enomoto <atsushi@ximian.com> * DataObject.cs : it should not append created DataObject element to diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs b/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs index 065636e3c70..22cd24a0107 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs @@ -237,7 +237,7 @@ namespace System.Security.Cryptography.Xml { if (xel == null) throw new CryptographicException ("Manifest targeted by Reference was not found: " + r.Uri.Substring (1)); doc.LoadXml (xel.OuterXml); - FixupNamespaceNodes (xel, doc.DocumentElement); + FixupNamespaceNodes (xel, doc.DocumentElement, false); } } else if (xmlResolver != null) { @@ -257,19 +257,18 @@ namespace System.Security.Cryptography.Xml { return null; } - private void FixupNamespaceNodes (XmlElement src, XmlElement dst) + private void FixupNamespaceNodes (XmlElement src, XmlElement dst, bool ignoreDefault) { // add namespace nodes foreach (XmlAttribute attr in src.SelectNodes ("namespace::*")) { if (attr.LocalName == "xml") continue; - if (attr.OwnerElement == src) + if (ignoreDefault && attr.LocalName == "xmlns") continue; dst.SetAttributeNode (dst.OwnerDocument.ImportNode (attr, true) as XmlAttribute); } } - [MonoTODO ("Need testing")] private byte[] GetReferenceHash (Reference r) { Stream s = null; @@ -318,6 +317,13 @@ namespace System.Security.Cryptography.Xml { foreach (DataObject obj in m_signature.ObjectList) { if (obj.Id == objectName) { found = obj.GetXml (); + found.SetAttribute ("xmlns", SignedXml.XmlDsigNamespaceUrl); + doc.LoadXml (found.OuterXml); + // FIXME: there should be theoretical justification of copying namespace declaration nodes this way. + foreach (XmlNode n in found.ChildNodes) + // Do not copy default namespace as it must be xmldsig namespace for "Object" element. + if (n.NodeType == XmlNodeType.Element) + FixupNamespaceNodes (n as XmlElement, doc.DocumentElement, true); break; } } @@ -325,14 +331,11 @@ namespace System.Security.Cryptography.Xml { foreach (XmlElement el in envdoc.SelectNodes ("//*[@Id]")) if (el.GetAttribute ("Id") == objectName) { found = el; + doc.LoadXml (found.OuterXml); break; } } - if (found != null) { - doc.LoadXml (found.OuterXml); - FixupNamespaceNodes (found, doc.DocumentElement); - } - else + if (found == null) throw new CryptographicException (String.Format ("Malformed reference object: {0}", objectName)); } } |