Author: atsushi
Date: 2007-01-25 04:57:57 -0500 (Thu, 25 Jan 2007)
New Revision: 71658

Modified:
   trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog
   trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs
   
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
   
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
Log:
2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * 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().



Modified: 
trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog  
2007-01-25 09:53:00 UTC (rev 71657)
+++ trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog  
2007-01-25 09:57:57 UTC (rev 71658)
@@ -1,3 +1,9 @@
+2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * DataObject.cs : it should not append created DataObject element to

Modified: 
trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs
===================================================================
--- 
trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs   
    2007-01-25 09:53:00 UTC (rev 71657)
+++ 
trunk/mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs   
    2007-01-25 09:57:57 UTC (rev 71658)
@@ -237,7 +237,7 @@
                                        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 @@
                        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 @@
                                        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 @@
                                                foreach (XmlElement el in 
envdoc.SelectNodes ("//[EMAIL PROTECTED]"))
                                                        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));
                                }
                        }

Modified: 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
===================================================================
--- 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog 
    2007-01-25 09:53:00 UTC (rev 71657)
+++ 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog 
    2007-01-25 09:57:57 UTC (rev 71658)
@@ -1,3 +1,7 @@
+2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SignedXmlTest.cs : enable SignElementWithPrefixedNamespace().
+
 2007-01-23  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SignedXmlTest.cs : fixed ambiguous variable name in previous tests.

Modified: 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
===================================================================
--- 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
      2007-01-25 09:53:00 UTC (rev 71657)
+++ 
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
      2007-01-25 09:57:57 UTC (rev 71658)
@@ -553,7 +553,6 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void SignElementWithPrefixedNamespace ()
                {
                        string input = "<a:Action 
xmlns:a='urn:foo'>http://tempuri.org/IFoo/Echo</a:Action>";

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to