瀏覽代碼

2004-03-23 Atsushi Enomoto <[email protected]>

	* SignedInfo.cs : It holds input element and directly returns it
	  unless the properties are not set.
	  Throw CryptographicException when Reference is empty *and* GetXml()
	  is *created*. (when just returning input element, no exception is
	  thrown).

svn path=/trunk/mcs/; revision=24465
Atsushi Eno 22 年之前
父節點
當前提交
1cc064583f

+ 9 - 1
mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog

@@ -1,6 +1,14 @@
 2004-03-23  Atsushi Enomoto <[email protected]>
 
-	* DataObject.cs : It now hold element instead of each parameters.
+	* SignedInfo.cs : It holds input element and directly returns it
+	  unless the properties are not set.
+	  Throw CryptographicException when Reference is empty *and* GetXml()
+	  is *created*. (when just returning input element, no exception is
+	  thrown).
+
+2004-03-23  Atsushi Enomoto <[email protected]>
+
+	* DataObject.cs : It now holds element instead of each parameters.
 	  Avoid loading element content to different document unless its
 	  properties were modified (to keep namespace node context).
 

+ 29 - 5
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedInfo.cs

@@ -20,6 +20,7 @@ namespace System.Security.Cryptography.Xml {
 		private string id;
 		private string signatureMethod;
 		private string signatureLength;
+		private XmlElement element;
 
 		public SignedInfo() 
 		{
@@ -29,7 +30,10 @@ namespace System.Security.Cryptography.Xml {
 
 		public string CanonicalizationMethod {
 			get { return c14nMethod; }
-			set { c14nMethod = value; }
+			set {
+				c14nMethod = value;
+				element = null;
+			}
 		}
 
 		// documented as not supported (and throwing exception)
@@ -39,7 +43,10 @@ namespace System.Security.Cryptography.Xml {
 
 		public string Id {
 			get { return id; }
-			set { id = value; }
+			set {
+				element = null;
+				id = value;
+			}
 		}
 
 		// documented as not supported (and throwing exception)
@@ -52,18 +59,27 @@ namespace System.Security.Cryptography.Xml {
 			get { throw new NotSupportedException (); }
 		}
 
+		// Manipulating this array never affects GetXml() when 
+		// LoadXml() was used. 
+		// (Actually, there is no way to detect modification.)
 		public ArrayList References {
 			get { return references; }
 		}
 
 		public string SignatureLength {
 			get { return signatureLength; }
-			set { signatureLength = value; }
+			set {
+				element = null;
+				signatureLength = value;
+			}
 		}
 
 		public string SignatureMethod {
 			get { return signatureMethod; }
-			set { signatureMethod = value; }
+			set {
+				element = null;
+				signatureMethod = value;
+			}
 		}
 
 		// documented as not supported (and throwing exception)
@@ -87,8 +103,11 @@ namespace System.Security.Cryptography.Xml {
 			return references.GetEnumerator ();
 		}
 
-		public XmlElement GetXml() 
+		public XmlElement GetXml ()
 		{
+			if (element != null)
+				return element;
+
 			if (signatureMethod == null)
 				throw new CryptographicException ("SignatureMethod");
 			if (references.Count == 0)
@@ -115,6 +134,10 @@ namespace System.Security.Cryptography.Xml {
 				xel.AppendChild (sm);
 			}
 
+			// This check is only done when element is created here.
+			if (references.Count == 0)
+				throw new CryptographicException ("At least one Reference element is required in SignedInfo.");
+
 			// we add References afterward so we don't end up with extraneous
 			// xmlns="..." in each reference elements.
 			foreach (Reference r in references) {
@@ -162,6 +185,7 @@ namespace System.Security.Cryptography.Xml {
 					AddReference (r);
 				}
 			}
+			element = value;
 		}
 	}
 }