using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
public class Starter {
public static void Main() {
GenericIdentity g = new GenericIdentity("Person1");
GenericPrincipal p = new GenericPrincipal(g,new string[] { "Manager" });
Thread.CurrentPrincipal = p;
MyClass.MethodA();
YClass.MethodA();
}
}
[PrincipalPermission(SecurityAction.Demand, Role = "Manager")]
public class MyClass {
static public void MethodA() {
Console.WriteLine("MyClass.MethodA");
}
}
[PrincipalPermission(SecurityAction.Demand,Role = "Accountant")]
public class YClass : MyClass {
static public void MethodB() {
Console.WriteLine("MyClass.MethodB");
}
}