2010-03-12 Jb Evain <jbevain@novell.com>
[mono.git] / mcs / class / corlib / System.Security / SecurityManager_2_1.cs
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 Novell, Inc (http://www.novell.com)
11 //
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.
30 //
31
32 #if NET_2_1 && !MONOTOUCH
33
34 using System.Reflection;
35 using System.Runtime.CompilerServices;
36 using System.Runtime.InteropServices;
37 using System.Security.Policy;
38
39 namespace System.Security {
40
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;
46         }
47
48         internal static class SecurityManager {
49
50                 // note: this let us differentiate between running in the browser (w/CoreCLR) and \r
51                 // running on the desktop (e.g. smcs compiling stuff)\r
52                 extern public static bool SecurityEnabled {
53                         [MethodImplAttribute (MethodImplOptions.InternalCall)]
54                         get;
55                 }
56
57                 internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
58                 {
59                         return null;
60                 }
61
62                 internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
63                 {
64                         return null;
65                 }
66
67                 internal static PermissionSet Decode (byte[] encodedPermissions)
68                 {
69                         return null;
70                 }
71
72                 internal static PermissionSet Decode (IntPtr permissions, int length)
73                 {
74                         return null;
75                 }
76
77                 public static bool IsGranted (IPermission perm)
78                 {
79                         return false;
80                 }
81
82                 public static PermissionSet ResolvePolicy (Evidence evidence)
83                 {
84                         return null;
85                 }
86
87                 public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
88                 {
89                         denied = null;
90                         return null;
91                 }
92
93                 internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
94                 {
95                         return false;;
96                 }
97
98                 internal static PolicyLevel ResolvingPolicyLevel {
99                         get { return null; }
100                 }
101
102                 internal static void ReflectedLinkDemandInvoke (MethodBase mb)
103                 {
104                 }
105
106                 // called by the runtime when CoreCLR is enabled
107
108                 private static void ThrowException (Exception ex)
109                 {
110                         throw ex;
111                 }
112
113                 // internal - get called by the class loader
114
115                 // Called when
116                 // - class inheritance
117                 // - method overrides
118                 private unsafe static bool InheritanceDemand (AppDomain ad, Assembly a, RuntimeDeclSecurityActions *actions)
119                 {
120                         return false;
121                 }
122
123                 private static void InheritanceDemandSecurityException (int securityViolation, Assembly a, Type t, MethodInfo method)
124                 {
125                 }
126
127                 // internal - get called at JIT time
128
129                 private static void DemandUnmanaged ()
130                 {
131                 }
132
133                 // internal - get called by JIT generated code
134
135                 private static void InternalDemand (IntPtr permissions, int length)
136                 {
137                 }
138
139                 private static void InternalDemandChoice (IntPtr permissions, int length)
140                 {
141                 }
142
143                 private unsafe static bool LinkDemand (Assembly a, RuntimeDeclSecurityActions *klass, RuntimeDeclSecurityActions *method)
144                 {
145                         return false;
146                 }
147
148                 private static bool LinkDemandUnmanaged (Assembly a)
149                 {
150                         return false;
151                 }
152
153                 private static bool LinkDemandFullTrust (Assembly a)
154                 {
155                         return false;
156                 }
157
158                 private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle)
159                 {
160                 }
161         }
162 }
163
164 #endif
165