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 {
59 public static bool CheckExecutionRights {
64 [Obsolete ("The security manager cannot be turned off on MS runtime")]
65 public static bool SecurityEnabled {
70 internal static bool HasElevatedPermissions {
74 internal static bool CheckElevatedPermissions ()
79 internal static void EnsureElevatedPermissions ()
85 [StrongNameIdentityPermission (SecurityAction.LinkDemand, PublicKey = "0x00000000000000000400000000000000")]
86 public static void GetZoneAndOrigin (out ArrayList zone, out ArrayList origin)
88 zone = new ArrayList ();
89 origin = new ArrayList ();
93 public static bool IsGranted (IPermission perm)
99 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
100 public static PolicyLevel LoadPolicyLevelFromFile (string path, PolicyLevelType type)
102 throw new NotSupportedException ();
106 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
107 public static PolicyLevel LoadPolicyLevelFromString (string str, PolicyLevelType type)
109 throw new NotSupportedException ();
113 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
114 public static IEnumerator PolicyHierarchy ()
116 throw new NotSupportedException ();
120 public static PermissionSet ResolvePolicy (Evidence evidence)
122 throw new NotSupportedException ();
126 public static PermissionSet ResolvePolicy (Evidence[] evidences)
128 throw new NotSupportedException ();
132 public static PermissionSet ResolveSystemPolicy (Evidence evidence)
134 throw new NotSupportedException ();
138 public static PermissionSet ResolvePolicy (Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
140 throw new NotSupportedException ();
144 public static IEnumerator ResolvePolicyGroups (Evidence evidence)
146 throw new NotSupportedException ();
150 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
151 public static void SavePolicy ()
153 throw new NotSupportedException ();
157 [SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
158 public static void SavePolicyLevel (PolicyLevel level)
160 throw new NotSupportedException ();
163 // private/internal stuff
165 internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
167 throw new NotSupportedException ();
170 internal static void ResolveIdentityPermissions (PermissionSet ps, Evidence evidence)
172 throw new NotSupportedException ();
175 internal static PolicyLevel ResolvingPolicyLevel {
180 internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
185 internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
190 internal static PermissionSet Decode (IntPtr permissions, int length)
192 throw new NotSupportedException ();
195 internal static PermissionSet Decode (byte[] encodedPermissions)
197 throw new NotSupportedException ();
200 public static PermissionSet GetStandardSandbox (Evidence evidence)
202 if (evidence == null)
203 throw new ArgumentNullException ("evidence");
205 throw new NotImplementedException ();
208 public static bool CurrentThreadRequiresSecurityContextCapture ()
210 throw new NotImplementedException ();