2008-05-30 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / System.Security / SecurityManager.cs
index a0193de0e20e70a41c8c83dd8086610abc7c1b72..100fe29efff746ee1fcbf715cc02cd706d14d88e 100644 (file)
@@ -102,7 +102,8 @@ namespace System.Security {
                // NOTE: This method doesn't show in the class library status page because
                // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
                // But it's there!
-               [MonoTODO ("works for fulltrust (empty), documentation doesn't really make sense, type wise")]
+               // FIXME works for fulltrust (empty), documentation doesn't really make sense, type wise
+               [MonoTODO ("CAS support is experimental (and unsupported). This method only works in FullTrust.")]
                [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000")]
                public static void GetZoneAndOrigin (out ArrayList zone, out ArrayList origin) 
                {
@@ -668,8 +669,12 @@ namespace System.Security {
                }
 
                // we try to provide as much details as possible to help debugging
-               private static void LinkDemandSecurityException (int securityViolation, Assembly a, MethodInfo method)
+               private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle)
                {
+                       RuntimeMethodHandle runtimeHandle = new RuntimeMethodHandle (methodHandle);
+                       MethodInfo method = (MethodInfo)(MethodBase.GetMethodFromHandle (runtimeHandle));
+                       Assembly a = method.DeclaringType.Assembly;
+
                        string message = null;
                        AssemblyName an = null;
                        PermissionSet granted = null;
@@ -735,6 +740,18 @@ namespace System.Security {
                        throw new SecurityException (message, an, granted, refused, method, SecurityAction.InheritanceDemand, null, null, null);
                }
 
+#if NET_2_1
+               private static void MethodAccessException (IntPtr caller, IntPtr callee)
+               {
+                       throw new MethodAccessException (Locale.GetText ("Method call not allowed."));
+               }
+
+               private static void VerificationException ()
+               {
+                       throw new VerificationException (Locale.GetText ("Unsafe code encountered."));
+               }
+#endif
+
                // internal - get called by the class loader
 
                // Called when