2 // System.Security.SecurityManager.cs
5 // Nick Drochak(ndrochak@gol.com)
6 // Sebastien Pouliot <sebastien@ximian.com>
9 // Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
10 // Copyright (C) 2004-2005 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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
34 using System.Collections;
35 using System.Diagnostics;
36 using System.Globalization;
38 using System.Reflection;
39 using System.Runtime.CompilerServices;
40 using System.Runtime.InteropServices;
41 using System.Security.Permissions;
42 using System.Security.Policy;
44 namespace System.Security {
46 // Must match MonoDeclSecurityActions in /mono/metadata/reflection.h
47 internal struct RuntimeDeclSecurityActions {
48 public RuntimeDeclSecurityEntry cas;
49 public RuntimeDeclSecurityEntry noncas;
50 public RuntimeDeclSecurityEntry choice;
54 public static class SecurityManager {
61 public static bool CheckExecutionRights {
66 [Obsolete ("The security manager cannot be turned off on MS runtime")]
67 public static bool SecurityEnabled {
72 internal static bool HasElevatedPermissions {
76 internal static bool CheckElevatedPermissions ()
81 internal static void EnsureElevatedPermissions ()
87 [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000")]
88 public static void GetZoneAndOrigin (out ArrayList zone, out ArrayList origin)
90 zone = new ArrayList ();
91 origin = new ArrayList ();
97 public static bool IsGranted (IPermission perm)
105 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
106 public static PolicyLevel LoadPolicyLevelFromFile (string path, PolicyLevelType type)
108 throw new NotSupportedException ();
114 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
115 public static PolicyLevel LoadPolicyLevelFromString (string str, PolicyLevelType type)
117 throw new NotSupportedException ();
123 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
124 public static IEnumerator PolicyHierarchy ()
126 throw new NotSupportedException ();
132 public static PermissionSet ResolvePolicy (Evidence evidence)
134 throw new NotSupportedException ();
140 public static PermissionSet ResolvePolicy (Evidence[] evidences)
142 throw new NotSupportedException ();
148 public static PermissionSet ResolveSystemPolicy (Evidence evidence)
150 throw new NotSupportedException ();
156 public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
158 throw new NotSupportedException ();
164 public static IEnumerator ResolvePolicyGroups (Evidence evidence)
166 throw new NotSupportedException ();
172 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
173 public static void SavePolicy ()
175 throw new NotSupportedException ();
181 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
182 public static void SavePolicyLevel (PolicyLevel level)
184 throw new NotSupportedException ();
187 // private/internal stuff
189 internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
191 throw new NotSupportedException ();
194 internal static void ResolveIdentityPermissions (PermissionSet ps, Evidence evidence)
196 throw new NotSupportedException ();
199 internal static PolicyLevel ResolvingPolicyLevel {
204 internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
209 internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
214 internal static PermissionSet Decode (IntPtr permissions, int length)
216 throw new NotSupportedException ();
219 internal static PermissionSet Decode (byte[] encodedPermissions)
221 throw new NotSupportedException ();
224 internal static void ReflectedLinkDemandInvoke (MethodBase mb)
226 throw new NotSupportedException ();
229 internal static bool ReflectedLinkDemandQuery (MethodBase mb)
231 throw new NotSupportedException ();
235 public static PermissionSet GetStandardSandbox (Evidence evidence)
237 if (evidence == null)
238 throw new ArgumentNullException ("evidence");
240 throw new NotImplementedException ();
243 public static bool CurrentThreadRequiresSecurityContextCapture ()
245 throw new NotImplementedException ();