[Mono-list] System.Security

Gaurav Vaish gvaish@iitk.ac.in
Mon, 31 Dec 2001 09:02:44 +0530

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

    Though I cannot tell how to solve the problem but there seems to be a bug in the system provided. The function does not throw
NotImplementedException, yet, it always returns a "true"!
    I am attaching a code where I did the following:

    * Pass an empty WebPermission instance
    * Pass a null
    * Pass a WebPermission instance with permissions as "None", and you get a "true".

    Either I am testing it wrongly, or there's a bug. I am attaching the code.

Gaurav Vaish

----- Original Message -----
From: "Nick Drochak" <ndrochak@gol.com>
To: "'Miguel de Icaza'" <miguel@ximian.com>
Cc: <mono-list@ximian.com>
Sent: Monday, December 31, 2001 04:16
Subject: RE: [Mono-list] System.Security

: > For those bits, just bring the topics up on the mailing list,
: > and we can discuss them here.  Paolo and Dietmar are coming
: > back from holidays the next week.
: >
: For implementing System.Security.SecurityManger.IsGranted(Ipermission):
: How does one obtain the permissions granted to the calling code
: assembly?  The docs indicate that the runtime grants permissions based
: on policy and on any declarative security requests (required, optional,
: refused). So, I am assuming there must be a window into the runtime
: (some API) where we can get this info.
: Regards,
: Nick D.
: _______________________________________________
: Mono-list maillist  -  Mono-list@ximian.com
: http://lists.ximian.com/mailman/listinfo/mono-list

Content-Type: application/octet-stream;
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

 * Class:   SecurityManagerTest
 * Author:  Gaurav Vaish
 * Maintainer: gvaish@iitk.ac.in
 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
 * Implementation: yes
 * Status:  100%
 * (C) Gaurav Vaish (2001)

using System;
using System.Net;
using System.Security;
using System.Security.Permissions;

public class SecurityManagerTest
	public static void Main()
		WebPermission wp = new WebPermission();
		bool isGranted = SecurityManager.IsGranted(wp);
		System.Console.WriteLine("Granted: {0}", (isGranted ? "yes" : "no"));

		isGranted = SecurityManager.IsGranted(null);
		System.Console.WriteLine("Granted: {0}", (isGranted ? "yes" : "no"));
		wp = new WebPermission(PermissionState.None);
		isGranted = SecurityManager.IsGranted(wp);
		System.Console.WriteLine("Granted: {0}", (isGranted ? "yes" : "no"));