Browse Source

2005-08-31 Sebastien Pouliot <[email protected]>

	* XmlDocument.cs: Added an InheritanceDemand for Unrestricted on 
	CreateDocumentType and ReadNode methods.
	* XmlException.cs: Added a Demand for SerializationFormatter on 
	GetObjectData method.
	* XmlResolver.cs: Added an InheritanceDemand for Unrestricted on 
	ResolveUri method.
	* XmlSecureResolver.cs: Fixed exception when creating evidences with 
	an empty URL in CreateEvidenceForUrl method. Only call ResolvePolicy 
	and PermitOnly if the security manager is enabled.
	* XmlTextReader.cs: Added an InheritanceDemand for Unrestricted on the
	class.
	* XmlTextReader2.cs: Added an InheritanceDemand for Unrestricted on 
	the class.
	* XmlValidatingReader.cs: Added an InheritanceDemand for Unrestricted 
	on the class.


svn path=/trunk/mcs/; revision=49179
Sebastien Pouliot 20 years ago
parent
commit
a17dea8630

+ 18 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,21 @@
+2005-08-31  Sebastien Pouliot  <[email protected]>
+
+	* XmlDocument.cs: Added an InheritanceDemand for Unrestricted on 
+	CreateDocumentType and ReadNode methods.
+	* XmlException.cs: Added a Demand for SerializationFormatter on 
+	GetObjectData method.
+	* XmlResolver.cs: Added an InheritanceDemand for Unrestricted on 
+	ResolveUri method.
+	* XmlSecureResolver.cs: Fixed exception when creating evidences with 
+	an empty URL in CreateEvidenceForUrl method. Only call ResolvePolicy 
+	and PermitOnly if the security manager is enabled.
+	* XmlTextReader.cs: Added an InheritanceDemand for Unrestricted on the
+	class.
+	* XmlTextReader2.cs: Added an InheritanceDemand for Unrestricted on 
+	the class.
+	* XmlValidatingReader.cs: Added an InheritanceDemand for Unrestricted 
+	on the class.
+
 2005-08-16  Atsushi Enomoto <[email protected]>
 
 	* DTDReader.cs : no need to skip text declaration for such entity

+ 4 - 3
mcs/class/System.XML/System.Xml/XmlDocument.cs

@@ -12,8 +12,7 @@
 // (C) 2001 Daniel Weber
 // (C) 2002 Kral Ferch, Jason Diamond, Miguel de Icaza, Duncan Mak,
 //   Atsushi Enomoto
-//
-
+// Copyright (C) 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
@@ -35,9 +34,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Globalization;
 using System.IO;
+using System.Security.Permissions;
 using System.Text;
 using System.Xml.XPath;
 using System.Diagnostics;
@@ -327,6 +326,7 @@ namespace System.Xml
 			return new XmlDocumentFragment (this);
 		}
 
+		[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 		public virtual XmlDocumentType CreateDocumentType (string name, string publicId,
 								   string systemId, string internalSubset)
 		{
@@ -773,6 +773,7 @@ namespace System.Xml
 			}
 		}
 
+		[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 		public virtual XmlNode ReadNode (XmlReader reader)
 		{
 			switch (reader.ReadState) {

+ 2 - 8
mcs/class/System.XML/System.Xml/XmlException.cs

@@ -6,9 +6,7 @@
 //   Atsushi Enomoto ([email protected])
 //
 // (C) 2002 Jason Diamond  http://injektilo.org/
-// (C) 2004 Novell Inc.
-//
-
+// 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
@@ -30,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Globalization;
 using System.Runtime.Serialization;
 using System.Security.Permissions;
@@ -131,10 +128,7 @@ namespace System.Xml
 
 		#region Methods
 
-#if NET_2_0
-		[SecurityPermission (SecurityAction.LinkDemand,
-			Flags=SecurityPermissionFlag.SerializationFormatter)]
-#endif
+		[SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
 		public override void GetObjectData (SerializationInfo info, StreamingContext context)
 		{
 			base.GetObjectData (info, context);

+ 2 - 2
mcs/class/System.XML/System.Xml/XmlResolver.cs

@@ -30,9 +30,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.IO;
 using System.Net;
+using System.Security.Permissions;
 
 namespace System.Xml
 {
@@ -45,7 +45,7 @@ namespace System.Xml
 			string role,
 			Type type);
 
-
+		[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 		public virtual Uri ResolveUri (Uri baseUri, string relativeUri)
 		{
 			if (baseUri == null) {

+ 25 - 22
mcs/class/System.XML/System.Xml/XmlSecureResolver.cs

@@ -28,8 +28,9 @@
 // Author: Atsushi Enomoto ([email protected])
 //
 // (C) 2003 Atsushi Enomoto
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
-using System;
+
 using System.Net;
 using System.Security;
 using System.Security.Policy;
@@ -45,43 +46,33 @@ namespace System.Xml
 		public static Evidence CreateEvidenceForUrl (string securityUrl)
 		{
 			Evidence e = new Evidence ();
-			Url url = null;
-			Zone zone = null;
-			Site site = null;
 
-			if (securityUrl != null) {
+			if ((securityUrl != null) && (securityUrl.Length > 0)) {
 				try {
-					if (securityUrl.Length > 0)
-						url = new Url (securityUrl);
+					Url url = new Url (securityUrl);
+					e.AddHost (url);
 				} catch (ArgumentException) {
 				}
 
 				try {
-					zone = Zone.CreateFromUrl (securityUrl);
+					Zone zone = Zone.CreateFromUrl (securityUrl);
+					e.AddHost (zone);
 				} catch (ArgumentException) {
 				}
 
 				try {
-					if (securityUrl.Length > 0)
-						site = Site.CreateFromUrl (securityUrl);
+					Site site = Site.CreateFromUrl (securityUrl);
+					e.AddHost (site);
 				} catch (ArgumentException) {
 				}
 			}
 
-			if (url != null)
-				e.AddHost (url);
-			if (zone != null)
-				e.AddHost (zone);
-			if (site != null)
-				e.AddHost (site);
-
 			return e;
 		}
 #endregion
 
 		XmlResolver resolver;
 		PermissionSet permissionSet;
-//		Evidence evidence;
 
 #region .ctor and Finalizer
 
@@ -89,8 +80,9 @@ namespace System.Xml
 			XmlResolver resolver, Evidence evidence)
 		{
 			this.resolver = resolver;
-//			this.evidence = evidence;
-			this.permissionSet = SecurityManager.ResolvePolicy (evidence);
+			if (SecurityManager.SecurityEnabled) {
+				this.permissionSet = SecurityManager.ResolvePolicy (evidence);
+			}
 		}
 
 		public XmlSecureResolver (
@@ -102,8 +94,11 @@ namespace System.Xml
 
 		public XmlSecureResolver (
 			XmlResolver resolver, string securityUrl)
-			: this (resolver, CreateEvidenceForUrl (securityUrl))
 		{
+			this.resolver = resolver;
+			if (SecurityManager.SecurityEnabled) {
+				this.permissionSet = SecurityManager.ResolvePolicy (CreateEvidenceForUrl (securityUrl));
+			}
 		}
 #endregion
 
@@ -117,10 +112,18 @@ namespace System.Xml
 
 #region Methods
 
+		[MonoTODO ("CAS: imperative PermitOnly isn't supported")]
 		public override object GetEntity (
 			Uri absoluteUri, string role, Type ofObjectToReturn)
 		{
-			permissionSet.PermitOnly ();
+			if (SecurityManager.SecurityEnabled) {
+				// in case the security manager was switched after the constructor was called
+				if (permissionSet == null) {
+					throw new SecurityException (Locale.GetText (
+						"Security Manager wasn't active when instance was created."));
+				}
+				permissionSet.PermitOnly ();
+			}
 			return resolver.GetEntity (absoluteUri, role, ofObjectToReturn);
 		}
 

+ 3 - 2
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -7,8 +7,7 @@
 //   Atsushi Enomoto  ([email protected])
 //
 // (C) 2001, 2002 Jason Diamond  http://injektilo.org/
-//
-
+// Copyright (C) 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
@@ -37,6 +36,7 @@ using System.Collections.Generic;
 #endif
 using System.Globalization;
 using System.IO;
+using System.Security.Permissions;
 using System.Text;
 using System.Xml.Schema;
 using Mono.Xml;
@@ -54,6 +54,7 @@ namespace System.Xml
 	internal class XmlTextReader : XmlReader,
 		IXmlLineInfo, IXmlNamespaceResolver, IHasXmlParserContext
 #else
+	[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 	public class XmlTextReader : XmlReader, IXmlLineInfo, IHasXmlParserContext
 #endif
 	{

+ 3 - 4
mcs/class/System.XML/System.Xml/XmlTextReader2.cs

@@ -4,9 +4,7 @@
 // Author:
 //   Atsushi Enomoto  ([email protected])
 //
-// Copyright (C) 2004 Novell, Inc.
-//
-
+// 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
@@ -32,16 +30,17 @@
 
 using XmlTextReaderImpl = Mono.Xml2.XmlTextReader;
 
-using System;
 using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
+using System.Security.Permissions;
 using System.Text;
 using System.Xml.Schema;
 using Mono.Xml;
 
 namespace System.Xml
 {
+	[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 	public class XmlTextReader : XmlReader,
 		IXmlLineInfo, IXmlNamespaceResolver, IHasXmlParserContext
 	{

+ 3 - 2
mcs/class/System.XML/System.Xml/XmlValidatingReader.cs

@@ -7,8 +7,7 @@
 //
 // Copyright (C) Tim Coleman, 2002
 // (C)2003 Atsushi Enomoto
-//
-
+// Copyright (C) 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
@@ -34,6 +33,7 @@
 using System.Collections.Generic;
 #endif
 using System.IO;
+using System.Security.Permissions;
 using System.Text;
 using System.Xml.Schema;
 using Mono.Xml;
@@ -41,6 +41,7 @@ using Mono.Xml.Schema;
 
 namespace System.Xml
 {
+	[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
 #if NET_2_0
 	[Obsolete("Use XmlReader created by XmlReader.Create() method using"
 		+ " appropriate XmlReaderSettings instead.")]