2007-01-12 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 12 Jan 2007 14:35:05 +0000 (14:35 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 12 Jan 2007 14:35:05 +0000 (14:35 -0000)
* SignedXml.cs : when there is an envelope document and no referenced
  DataObject was found, then look for the target element from the
  envelope.

* SignedXmlTest.cs : added DataReferenceToNonDataObject().

* xmldsig.cs : signature-big.xml also depends on the input document.

svn path=/trunk/mcs/; revision=70919

mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
mcs/class/System.Security/Test/standalone_tests/ChangeLog
mcs/class/System.Security/Test/standalone_tests/xmldsig.cs

index 51c1f0ecea90aa59c2294ddfa503d2f144170917..b3a0152248451b0cba9e7396a20448f39a195731 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SignedXml.cs : when there is an envelope document and no referenced
+         DataObject was found, then look for the target element from the
+         envelope.
+
 2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataObject.cs : don't clear attributes or children unnecessarily.
index 1005fe522381ee1bcce7ae11ed6adb53a5a15ed3..065636e3c704bb88c7075668abe83641116be882 100644 (file)
@@ -314,17 +314,25 @@ namespace System.Security.Cryptography.Xml {
                                        }
                                }
                                if (objectName != null) {
-                                       bool found = false;
+                                       XmlElement found = null;
                                        foreach (DataObject obj in m_signature.ObjectList) {
                                                if (obj.Id == objectName) {
-                                                       XmlElement xel = obj.GetXml ();
-                                                       doc.LoadXml (xel.OuterXml);
-                                                       FixupNamespaceNodes (xel, doc.DocumentElement);
-                                                       found = true;
+                                                       found = obj.GetXml ();
                                                        break;
                                                }
                                        }
-                                       if (!found)
+                                       if (found == null && envdoc != null) {
+                                               foreach (XmlElement el in envdoc.SelectNodes ("//*[@Id]"))
+                                                       if (el.GetAttribute ("Id") == objectName) {
+                                                               found = el;
+                                                               break;
+                                                       }
+                                       }
+                                       if (found != null) {
+                                               doc.LoadXml (found.OuterXml);
+                                               FixupNamespaceNodes (found, doc.DocumentElement);
+                                       }
+                                       else
                                                throw new CryptographicException (String.Format ("Malformed reference object: {0}", objectName));
                                }
                        }
index ba124e8a45f6c59420be1512d95b52edb4d33555..ac635a97a96651140d2343834e1c50bd7293ca62 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SignedXmlTest.cs : added DataReferenceToNonDataObject().
+
 2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataObjectTest.cs : test to make sure to not clear attributes or
index 89e5fb53e3ca3cc2485d432d26d123b7f4af8bc6..f5b883620121d29a031544d203c6d1f96b7d8e3a 100644 (file)
@@ -519,6 +519,25 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        signedXml.ComputeSignature ();
                }
 
+               [Test]
+               public void DataReferenceToNonDataObject ()
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml ("<foo Id='id:1'/>");
+                       SignedXml signedXml = new SignedXml (doc);
+                       DSA key = DSA.Create ();
+                       signedXml.SigningKey = key;
+
+                       Reference reference = new Reference ();
+                       reference.Uri = "#id:1";
+
+                       XmlDsigC14NTransform t = new XmlDsigC14NTransform ();
+                       reference.AddTransform (t);
+                       signedXml.AddReference (reference);
+
+                       signedXml.ComputeSignature ();
+               }
+
 #if NET_2_0
                [Test]
                [Category ("NotWorking")] // bug #79483
index bd4fa3abaf342292436c49f972fe76ec4d180420..e7f47423b00470116d9b69835f9bd159184dfc3f 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * xmldsig.cs : signature-big.xml also depends on the input document.
+
 2005-04-04  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Makefile : Fixed reference to Mono.Security.dll. Added decent-reader
index 74baed01bfa0ec2facbbb91e3e094e90ac7616c8..4c96f2a08d82afc42945b5da733bc064591b14d7 100644 (file)
@@ -146,6 +146,8 @@ public class MyClass {
                        SignedXml s = null;
                        if (filename.IndexOf ("enveloped") >= 0)
                                s = new SignedXml (doc);
+                       else if (filename.IndexOf ("signature-big") >= 0)
+                               s = new SignedXml (doc);
                        else
                                s = new SignedXml ();