New test.
[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-2010 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 MOONLIGHT
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                 public static bool HasElevatedPermissions {
58                         get; set;
59                 }
60
61                 internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
62                 {
63                         return null;
64                 }
65
66                 internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
67                 {
68                         return null;
69                 }
70
71                 internal static PermissionSet Decode (byte[] encodedPermissions)
72                 {
73                         return null;
74                 }
75
76                 internal static PermissionSet Decode (IntPtr permissions, int length)
77                 {
78                         return null;
79                 }
80
81                 public static bool IsGranted (IPermission perm)
82                 {
83                         return false;
84                 }
85
86                 public static PermissionSet ResolvePolicy (Evidence evidence)
87                 {
88                         return null;
89                 }
90
91                 public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
92                 {
93                         denied = null;
94                         return null;
95                 }
96
97                 internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
98                 {
99                         return false;;
100                 }
101
102                 internal static PolicyLevel ResolvingPolicyLevel {
103                         get { return null; }
104                 }
105
106                 internal static void ReflectedLinkDemandInvoke (MethodBase mb)
107                 {
108                 }
109
110                 // called by the runtime when CoreCLR is enabled
111
112                 private static void ThrowException (Exception ex)
113                 {
114                         throw ex;
115                 }
116
117                 // internal - get called by the class loader
118
119                 // Called when
120                 // - class inheritance
121                 // - method overrides
122                 private unsafe static bool InheritanceDemand (AppDomain ad, Assembly a, RuntimeDeclSecurityActions *actions)
123                 {
124                         return false;
125                 }
126
127                 private static void InheritanceDemandSecurityException (int securityViolation, Assembly a, Type t, MethodInfo method)
128                 {
129                 }
130
131                 // internal - get called at JIT time
132
133                 private static void DemandUnmanaged ()
134                 {
135                 }
136
137                 // internal - get called by JIT generated code
138
139                 private static void InternalDemand (IntPtr permissions, int length)
140                 {
141                 }
142
143                 private static void InternalDemandChoice (IntPtr permissions, int length)
144                 {
145                 }
146
147                 private unsafe static bool LinkDemand (Assembly a, RuntimeDeclSecurityActions *klass, RuntimeDeclSecurityActions *method)
148                 {
149                         return false;
150                 }
151
152                 private static bool LinkDemandUnmanaged (Assembly a)
153                 {
154                         return false;
155                 }
156
157                 private static bool LinkDemandFullTrust (Assembly a)
158                 {
159                         return false;
160                 }
161
162                 private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle)
163                 {
164                 }
165         }
166 }
167
168 #endif
169