2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / corlib / System.Security / SecurityManager_2_1.cs
blob216f03da15fe55de36542cc4989f8fd01491f714
1 //
2 // System.Security.SecurityManager.cs
3 //
4 // Authors:
5 // Nick Drochak(ndrochak@gol.com)
6 // Sebastien Pouliot <sebastien@ximian.com>
7 //
8 // (C) Nick Drochak
9 // Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
10 // Copyright (C) 2004-2005, 2009-2010 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #if MOONLIGHT
34 using System.Reflection;
35 using System.Runtime.CompilerServices;
36 using System.Runtime.InteropServices;
37 using System.Security.Policy;
39 namespace System.Security {
41 // Must match MonoDeclSecurityActions in /mono/metadata/reflection.h
42 internal struct RuntimeDeclSecurityActions {
43 public RuntimeDeclSecurityEntry cas;
44 public RuntimeDeclSecurityEntry noncas;
45 public RuntimeDeclSecurityEntry choice;
48 internal static class SecurityManager {
50 // note: this let us differentiate between running in the browser (w/CoreCLR) and
51 // running on the desktop (e.g. smcs compiling stuff)
52 extern public static bool SecurityEnabled {
53 [MethodImplAttribute (MethodImplOptions.InternalCall)]
54 get;
57 public static bool HasElevatedPermissions {
58 get; set;
61 internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
63 return null;
66 internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
68 return null;
71 internal static PermissionSet Decode (byte[] encodedPermissions)
73 return null;
76 internal static PermissionSet Decode (IntPtr permissions, int length)
78 return null;
81 public static bool IsGranted (IPermission perm)
83 return false;
86 public static PermissionSet ResolvePolicy (Evidence evidence)
88 return null;
91 public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
93 denied = null;
94 return null;
97 internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
99 return false;;
102 internal static PolicyLevel ResolvingPolicyLevel {
103 get { return null; }
106 internal static void ReflectedLinkDemandInvoke (MethodBase mb)
110 // called by the runtime when CoreCLR is enabled
112 private static void ThrowException (Exception ex)
114 throw ex;
117 // internal - get called by the class loader
119 // Called when
120 // - class inheritance
121 // - method overrides
122 private unsafe static bool InheritanceDemand (AppDomain ad, Assembly a, RuntimeDeclSecurityActions *actions)
124 return false;
127 private static void InheritanceDemandSecurityException (int securityViolation, Assembly a, Type t, MethodInfo method)
131 // internal - get called at JIT time
133 private static void DemandUnmanaged ()
137 // internal - get called by JIT generated code
139 private static void InternalDemand (IntPtr permissions, int length)
143 private static void InternalDemandChoice (IntPtr permissions, int length)
147 private unsafe static bool LinkDemand (Assembly a, RuntimeDeclSecurityActions *klass, RuntimeDeclSecurityActions *method)
149 return false;
152 private static bool LinkDemandUnmanaged (Assembly a)
154 return false;
157 private static bool LinkDemandFullTrust (Assembly a)
159 return false;
162 private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle)
168 #endif