Browse Source

2005-05-04 Sebastien Pouliot <[email protected]>

	* SignedXml.cs: Return an empty (not null) KeyInfo by default and
	don't throw a CryptographicException in CheckSignature (both NET_2_0).
	* KeyInfoRetrievalMethod.cs: Don't include an empty URI attribute
	in the XML output for NET_2_0.
	* XmlDsigXPathTransform.cs: Throw an XPathException in NET_2_0 if no
	xpath expression has been supplied to the transform.


svn path=/trunk/mcs/; revision=44034
Sebastien Pouliot 20 years ago
parent
commit
5faed2987b

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

@@ -1,3 +1,12 @@
+2005-05-04  Sebastien Pouliot  <[email protected]>
+
+	* SignedXml.cs: Return an empty (not null) KeyInfo by default and
+	don't throw a CryptographicException in CheckSignature (both NET_2_0).
+	* KeyInfoRetrievalMethod.cs: Don't include an empty URI attribute
+	in the XML output for NET_2_0.
+	* XmlDsigXPathTransform.cs: Throw an XPathException in NET_2_0 if no
+	xpath expression has been supplied to the transform.
+
 2005-05-03  Sebastien Pouliot  <[email protected]>
 
 	* XmlDsigXsltTransform.cs: Fixed 2 test cases (that nows throws 

+ 5 - 2
mcs/class/System.Security/System.Security.Cryptography.Xml/KeyInfoRetrievalMethod.cs

@@ -84,11 +84,14 @@ namespace System.Security.Cryptography.Xml {
 
 			XmlDocument document = new XmlDocument ();
 			XmlElement xel = document.CreateElement (XmlSignature.ElementNames.RetrievalMethod, XmlSignature.NamespaceURI);
-			if (URI != null)
-				xel.SetAttribute (XmlSignature.AttributeNames.URI, URI);
 #if NET_2_0
+			if ((URI != null) && (URI.Length > 0))
+				xel.SetAttribute (XmlSignature.AttributeNames.URI, URI);
 			if (Type != null)
 				xel.SetAttribute (XmlSignature.AttributeNames.Type, Type);
+#else
+			if (URI != null)
+				xel.SetAttribute (XmlSignature.AttributeNames.URI, URI);
 #endif
 			return xel;
 		}

+ 13 - 7
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs

@@ -119,7 +119,13 @@ namespace System.Security.Cryptography.Xml {
 #endif
 
 		public KeyInfo KeyInfo {
-			get { return m_signature.KeyInfo; }
+			get {
+#if NET_2_0
+				if (m_signature.KeyInfo == null)
+					m_signature.KeyInfo = new KeyInfo ();
+#endif
+				return m_signature.KeyInfo;
+			}
 			set { m_signature.KeyInfo = value; }
 		}
 
@@ -156,10 +162,6 @@ namespace System.Security.Cryptography.Xml {
 
 		public void AddObject (DataObject dataObject) 
 		{
-#if NET_2_0
-			if (dataObject == null)
-				throw new ArgumentNullException ("dataObject");
-#endif
 			m_signature.AddObject (dataObject);
 		}
 
@@ -480,10 +482,14 @@ namespace System.Security.Cryptography.Xml {
 				// check with supplied key
 				if (!CheckSignatureWithKey (key))
 					return null;
-			}
-			else {
+			} else {
+#if NET_2_0
+				if (Signature.KeyInfo == null)
+					return null;
+#else
 				if (Signature.KeyInfo == null)
 					throw new CryptographicException ("At least one KeyInfo is required.");
+#endif
 				// no supplied key, iterates all KeyInfo
 				while ((key = GetPublicKey ()) != null) {
 					if (CheckSignatureWithKey (key)) {

+ 6 - 4
mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigXPathTransform.cs

@@ -8,9 +8,7 @@
 //	Atsushi Enomoto <[email protected]>
 //
 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
-//
-
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -100,9 +98,13 @@ namespace System.Security.Cryptography.Xml
 		[MonoTODO ("Evaluation of extension function here() results in different from MS.NET (is MS.NET really correct??).")]
 		public override object GetOutput () 
 		{
+#if NET_2_0
+			if (xpath == null)
+				throw new XPathException (Locale.GetText ("No XPath expression provided."));
+#else
 			if (xpath == null)
 				return new XmlDsigNodeList (new ArrayList ());
-
+#endif
 			// evaluate every time since input or xpath might have changed.
 			string x = null;
 			for (int i = 0; i < xpath.Count; i++) {