mscorlib(4.0.0.0) API with additions
SecurityManager.cs
1 using System.Collections;
3 using System.IO;
8 using System.Security.Util;
9 using System.Threading;
10 
11 namespace System.Security
12 {
14  [ComVisible(true)]
15  public static class SecurityManager
16  {
17  private static volatile SecurityPermission executionSecurityPermission = null;
18 
19  private static PolicyManager polmgr = new PolicyManager();
20 
21  private static int[][] s_BuiltInPermissionIndexMap = new int[6][]
22  {
23  new int[2]
24  {
25  0,
26  10
27  },
28  new int[2]
29  {
30  1,
31  11
32  },
33  new int[2]
34  {
35  2,
36  12
37  },
38  new int[2]
39  {
40  4,
41  13
42  },
43  new int[2]
44  {
45  6,
46  14
47  },
48  new int[2]
49  {
50  7,
51  9
52  }
53  };
54 
55  private static CodeAccessPermission[] s_UnrestrictedSpecialPermissionMap = new CodeAccessPermission[6]
56  {
57  new EnvironmentPermission(PermissionState.Unrestricted),
58  new FileDialogPermission(PermissionState.Unrestricted),
59  new FileIOPermission(PermissionState.Unrestricted),
60  new ReflectionPermission(PermissionState.Unrestricted),
61  new SecurityPermission(PermissionState.Unrestricted),
62  new UIPermission(PermissionState.Unrestricted)
63  };
64 
65  internal static PolicyManager PolicyManager => polmgr;
66 
71  [Obsolete("Because execution permission checks can no longer be turned off, the CheckExecutionRights property no longer has any effect.")]
72  public static bool CheckExecutionRights
73  {
74  get
75  {
76  return true;
77  }
78  set
79  {
80  }
81  }
82 
87  [Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")]
88  public static bool SecurityEnabled
89  {
90  get
91  {
92  return true;
93  }
94  set
95  {
96  }
97  }
98 
103  [MethodImpl(MethodImplOptions.NoInlining)]
104  [SecuritySafeCritical]
105  [Obsolete("IsGranted is obsolete and will be removed in a future release of the .NET Framework. Please use the PermissionSet property of either AppDomain or Assembly instead.")]
106  public static bool IsGranted(IPermission perm)
107  {
108  if (perm == null)
109  {
110  return true;
111  }
112  PermissionSet o = null;
113  PermissionSet o2 = null;
114  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
115  GetGrantedPermissions(JitHelpers.GetObjectHandleOnStack(ref o), JitHelpers.GetObjectHandleOnStack(ref o2), JitHelpers.GetStackCrawlMarkHandle(ref stackMark));
116  if (o.Contains(perm))
117  {
118  if (o2 != null)
119  {
120  return !o2.Contains(perm);
121  }
122  return true;
123  }
124  return false;
125  }
126 
132  public static PermissionSet GetStandardSandbox(Evidence evidence)
133  {
134  if (evidence == null)
135  {
136  throw new ArgumentNullException("evidence");
137  }
138  Zone hostEvidence = evidence.GetHostEvidence<Zone>();
139  if (hostEvidence == null)
140  {
141  return new PermissionSet(PermissionState.None);
142  }
143  if (hostEvidence.SecurityZone == SecurityZone.MyComputer)
144  {
145  return new PermissionSet(PermissionState.Unrestricted);
146  }
147  if (hostEvidence.SecurityZone == SecurityZone.Intranet)
148  {
149  PermissionSet localIntranet = BuiltInPermissionSets.LocalIntranet;
150  PolicyStatement policyStatement = new NetCodeGroup(new AllMembershipCondition()).Resolve(evidence);
151  PolicyStatement policyStatement2 = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery).Resolve(evidence);
152  if (policyStatement != null)
153  {
154  localIntranet.InplaceUnion(policyStatement.PermissionSet);
155  }
156  if (policyStatement2 != null)
157  {
158  localIntranet.InplaceUnion(policyStatement2.PermissionSet);
159  }
160  return localIntranet;
161  }
162  if (hostEvidence.SecurityZone == SecurityZone.Internet || hostEvidence.SecurityZone == SecurityZone.Trusted)
163  {
164  PermissionSet internet = BuiltInPermissionSets.Internet;
165  PolicyStatement policyStatement3 = new NetCodeGroup(new AllMembershipCondition()).Resolve(evidence);
166  if (policyStatement3 != null)
167  {
168  internet.InplaceUnion(policyStatement3.PermissionSet);
169  }
170  return internet;
171  }
172  return new PermissionSet(PermissionState.None);
173  }
174 
179  [MethodImpl(MethodImplOptions.NoInlining)]
180  [SecurityCritical]
181  public static void GetZoneAndOrigin(out ArrayList zone, out ArrayList origin)
182  {
183  StackCrawlMark mark = StackCrawlMark.LookForMyCaller;
184  CodeAccessSecurityEngine.GetZoneAndOrigin(ref mark, out zone, out origin);
185  }
186 
195  [SecuritySafeCritical]
196  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
197  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPolicy)]
198  public static PolicyLevel LoadPolicyLevelFromFile(string path, PolicyLevelType type)
199  {
200  if (path == null)
201  {
202  throw new ArgumentNullException("path");
203  }
204  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
205  {
206  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
207  }
208  if (!File.InternalExists(path))
209  {
210  throw new ArgumentException(Environment.GetResourceString("Argument_PolicyFileDoesNotExist"));
211  }
212  string fullPath = Path.GetFullPath(path);
213  FileIOPermission fileIOPermission = new FileIOPermission(PermissionState.None);
214  fileIOPermission.AddPathList(FileIOPermissionAccess.Read, fullPath);
215  fileIOPermission.AddPathList(FileIOPermissionAccess.Write, fullPath);
216  fileIOPermission.Demand();
217  using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
218  {
219  using (StreamReader streamReader = new StreamReader(stream))
220  {
221  return LoadPolicyLevelFromStringHelper(streamReader.ReadToEnd(), path, type);
222  }
223  }
224  }
225 
233  [SecuritySafeCritical]
234  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
235  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPolicy)]
236  public static PolicyLevel LoadPolicyLevelFromString(string str, PolicyLevelType type)
237  {
238  return LoadPolicyLevelFromStringHelper(str, null, type);
239  }
240 
241  private static PolicyLevel LoadPolicyLevelFromStringHelper(string str, string path, PolicyLevelType type)
242  {
243  if (str == null)
244  {
245  throw new ArgumentNullException("str");
246  }
247  PolicyLevel policyLevel = new PolicyLevel(type, path);
248  Parser parser = new Parser(str);
249  SecurityElement topElement = parser.GetTopElement();
250  if (topElement == null)
251  {
252  throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), "configuration"));
253  }
254  SecurityElement securityElement = topElement.SearchForChildByTag("mscorlib");
255  if (securityElement == null)
256  {
257  throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), "mscorlib"));
258  }
259  SecurityElement securityElement2 = securityElement.SearchForChildByTag("security");
260  if (securityElement2 == null)
261  {
262  throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), "security"));
263  }
264  SecurityElement securityElement3 = securityElement2.SearchForChildByTag("policy");
265  if (securityElement3 == null)
266  {
267  throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), "policy"));
268  }
269  SecurityElement securityElement4 = securityElement3.SearchForChildByTag("PolicyLevel");
270  if (securityElement4 != null)
271  {
272  policyLevel.FromXml(securityElement4);
273  return policyLevel;
274  }
275  throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), "PolicyLevel"));
276  }
277 
282  [SecuritySafeCritical]
283  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
284  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPolicy)]
285  public static void SavePolicyLevel(PolicyLevel level)
286  {
287  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
288  {
289  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
290  }
291  PolicyManager.EncodeLevel(level);
292  }
293 
303  [SecuritySafeCritical]
304  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
305  public static PermissionSet ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
306  {
307  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
308  {
309  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
310  }
311  return ResolvePolicy(evidence, reqdPset, optPset, denyPset, out denied, checkExecutionPermission: true);
312  }
313 
318  [SecuritySafeCritical]
319  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
320  public static PermissionSet ResolvePolicy(Evidence evidence)
321  {
322  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
323  {
324  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
325  }
326  if (evidence == null)
327  {
328  evidence = new Evidence();
329  }
330  return polmgr.Resolve(evidence);
331  }
332 
337  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
338  public static PermissionSet ResolvePolicy(Evidence[] evidences)
339  {
340  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
341  {
342  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
343  }
344  if (evidences == null || evidences.Length == 0)
345  {
346  evidences = new Evidence[1];
347  }
348  PermissionSet permissionSet = ResolvePolicy(evidences[0]);
349  if (permissionSet == null)
350  {
351  return null;
352  }
353  for (int i = 1; i < evidences.Length; i++)
354  {
355  permissionSet = permissionSet.Intersect(ResolvePolicy(evidences[i]));
356  if (permissionSet == null || permissionSet.IsEmpty())
357  {
358  return permissionSet;
359  }
360  }
361  return permissionSet;
362  }
363 
367  [SecurityCritical]
369  {
370  return !CodeAccessSecurityEngine.QuickCheckForAllDemands();
371  }
372 
377  [SecuritySafeCritical]
378  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
380  {
381  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
382  {
383  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
384  }
385  if (PolicyManager.IsGacAssembly(evidence))
386  {
387  return new PermissionSet(PermissionState.Unrestricted);
388  }
389  return polmgr.CodeGroupResolve(evidence, systemPolicy: true);
390  }
391 
396  [SecuritySafeCritical]
397  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
398  public static IEnumerator ResolvePolicyGroups(Evidence evidence)
399  {
400  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
401  {
402  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
403  }
404  return polmgr.ResolveCodeGroups(evidence);
405  }
406 
411  [SecuritySafeCritical]
412  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
413  public static IEnumerator PolicyHierarchy()
414  {
415  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
416  {
417  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
418  }
419  return polmgr.PolicyHierarchy();
420  }
421 
425  [SecuritySafeCritical]
426  [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
427  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPolicy)]
428  public static void SavePolicy()
429  {
430  if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
431  {
432  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit"));
433  }
434  polmgr.Save();
435  }
436 
437  [SecurityCritical]
438  private static PermissionSet ResolveCasPolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied, out int securitySpecialFlags, bool checkExecutionPermission)
439  {
440  CodeAccessPermission.Assert(allPossible: true);
441  PermissionSet permissionSet = ResolvePolicy(evidence, reqdPset, optPset, denyPset, out denied, checkExecutionPermission);
442  securitySpecialFlags = GetSpecialFlags(permissionSet, denied);
443  return permissionSet;
444  }
445 
446  [SecurityCritical]
447  private static PermissionSet ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied, bool checkExecutionPermission)
448  {
449  if (executionSecurityPermission == null)
450  {
451  executionSecurityPermission = new SecurityPermission(SecurityPermissionFlag.Execution);
452  }
453  PermissionSet permissionSet = null;
454  Exception exception = null;
455  permissionSet = ((reqdPset != null) ? ((optPset == null) ? null : reqdPset.Union(optPset)) : optPset);
456  if (permissionSet != null && !permissionSet.IsUnrestricted())
457  {
458  permissionSet.AddPermission(executionSecurityPermission);
459  }
460  if (evidence == null)
461  {
462  evidence = new Evidence();
463  }
464  PermissionSet permissionSet2 = polmgr.Resolve(evidence);
465  if (permissionSet != null)
466  {
467  permissionSet2.InplaceIntersect(permissionSet);
468  }
469  if (checkExecutionPermission && (!permissionSet2.Contains(executionSecurityPermission) || (denyPset != null && denyPset.Contains(executionSecurityPermission))))
470  {
471  throw new PolicyException(Environment.GetResourceString("Policy_NoExecutionPermission"), -2146233320, exception);
472  }
473  if (reqdPset != null && !reqdPset.IsSubsetOf(permissionSet2))
474  {
475  throw new PolicyException(Environment.GetResourceString("Policy_NoRequiredPermission"), -2146233321, exception);
476  }
477  if (denyPset != null)
478  {
479  denied = denyPset.Copy();
480  permissionSet2.MergeDeniedSet(denied);
481  if (denied.IsEmpty())
482  {
483  denied = null;
484  }
485  }
486  else
487  {
488  denied = null;
489  }
490  permissionSet2.IgnoreTypeLoadFailures = true;
491  return permissionSet2;
492  }
493 
494  internal static int GetSpecialFlags(PermissionSet grantSet, PermissionSet deniedSet)
495  {
496  if (grantSet != null && grantSet.IsUnrestricted() && (deniedSet == null || deniedSet.IsEmpty()))
497  {
498  return -1;
499  }
500  SecurityPermission securityPermission = null;
501  SecurityPermissionFlag securityPermissionFlag = SecurityPermissionFlag.NoFlags;
502  ReflectionPermission reflectionPermission = null;
503  ReflectionPermissionFlag reflectionPermissionFlag = ReflectionPermissionFlag.NoFlags;
504  CodeAccessPermission[] array = new CodeAccessPermission[6];
505  if (grantSet != null)
506  {
507  if (grantSet.IsUnrestricted())
508  {
509  securityPermissionFlag = SecurityPermissionFlag.AllFlags;
510  reflectionPermissionFlag = (ReflectionPermissionFlag.TypeInformation | ReflectionPermissionFlag.MemberAccess | ReflectionPermissionFlag.ReflectionEmit | ReflectionPermissionFlag.RestrictedMemberAccess);
511  for (int i = 0; i < array.Length; i++)
512  {
513  array[i] = s_UnrestrictedSpecialPermissionMap[i];
514  }
515  }
516  else
517  {
518  securityPermission = (grantSet.GetPermission(6) as SecurityPermission);
519  if (securityPermission != null)
520  {
521  securityPermissionFlag = securityPermission.Flags;
522  }
523  reflectionPermission = (grantSet.GetPermission(4) as ReflectionPermission);
524  if (reflectionPermission != null)
525  {
526  reflectionPermissionFlag = reflectionPermission.Flags;
527  }
528  for (int j = 0; j < array.Length; j++)
529  {
530  array[j] = (grantSet.GetPermission(s_BuiltInPermissionIndexMap[j][0]) as CodeAccessPermission);
531  }
532  }
533  }
534  if (deniedSet != null)
535  {
536  if (deniedSet.IsUnrestricted())
537  {
538  securityPermissionFlag = SecurityPermissionFlag.NoFlags;
539  reflectionPermissionFlag = ReflectionPermissionFlag.NoFlags;
540  for (int k = 0; k < s_BuiltInPermissionIndexMap.Length; k++)
541  {
542  array[k] = null;
543  }
544  }
545  else
546  {
547  securityPermission = (deniedSet.GetPermission(6) as SecurityPermission);
548  if (securityPermission != null)
549  {
550  securityPermissionFlag &= ~securityPermission.Flags;
551  }
552  reflectionPermission = (deniedSet.GetPermission(4) as ReflectionPermission);
553  if (reflectionPermission != null)
554  {
555  reflectionPermissionFlag &= ~reflectionPermission.Flags;
556  }
557  for (int l = 0; l < s_BuiltInPermissionIndexMap.Length; l++)
558  {
559  CodeAccessPermission codeAccessPermission = deniedSet.GetPermission(s_BuiltInPermissionIndexMap[l][0]) as CodeAccessPermission;
560  if (codeAccessPermission != null && !codeAccessPermission.IsSubsetOf(null))
561  {
562  array[l] = null;
563  }
564  }
565  }
566  }
567  int num = MapToSpecialFlags(securityPermissionFlag, reflectionPermissionFlag);
568  if (num != -1)
569  {
570  for (int m = 0; m < array.Length; m++)
571  {
572  if (array[m] != null && ((IUnrestrictedPermission)array[m]).IsUnrestricted())
573  {
574  num |= 1 << s_BuiltInPermissionIndexMap[m][1];
575  }
576  }
577  }
578  return num;
579  }
580 
581  private static int MapToSpecialFlags(SecurityPermissionFlag securityPermissionFlags, ReflectionPermissionFlag reflectionPermissionFlags)
582  {
583  int num = 0;
584  if ((securityPermissionFlags & SecurityPermissionFlag.UnmanagedCode) == SecurityPermissionFlag.UnmanagedCode)
585  {
586  num |= 1;
587  }
588  if ((securityPermissionFlags & SecurityPermissionFlag.SkipVerification) == SecurityPermissionFlag.SkipVerification)
589  {
590  num |= 2;
591  }
592  if ((securityPermissionFlags & SecurityPermissionFlag.Assertion) == SecurityPermissionFlag.Assertion)
593  {
594  num |= 8;
595  }
596  if ((securityPermissionFlags & SecurityPermissionFlag.SerializationFormatter) == SecurityPermissionFlag.SerializationFormatter)
597  {
598  num |= 0x20;
599  }
600  if ((securityPermissionFlags & SecurityPermissionFlag.BindingRedirects) == SecurityPermissionFlag.BindingRedirects)
601  {
602  num |= 0x100;
603  }
604  if ((securityPermissionFlags & SecurityPermissionFlag.ControlEvidence) == SecurityPermissionFlag.ControlEvidence)
605  {
606  num |= 0x10000;
607  }
608  if ((securityPermissionFlags & SecurityPermissionFlag.ControlPrincipal) == SecurityPermissionFlag.ControlPrincipal)
609  {
610  num |= 0x20000;
611  }
612  if ((reflectionPermissionFlags & ReflectionPermissionFlag.RestrictedMemberAccess) == ReflectionPermissionFlag.RestrictedMemberAccess)
613  {
614  num |= 0x40;
615  }
616  if ((reflectionPermissionFlags & ReflectionPermissionFlag.MemberAccess) == ReflectionPermissionFlag.MemberAccess)
617  {
618  num |= 0x10;
619  }
620  return num;
621  }
622 
623  [DllImport("QCall", CharSet = CharSet.Unicode)]
624  [SecurityCritical]
625  [SuppressUnmanagedCodeSecurity]
626  internal static extern bool IsSameType(string strLeft, string strRight);
627 
628  [MethodImpl(MethodImplOptions.InternalCall)]
629  [SecurityCritical]
630  internal static extern bool _SetThreadSecurity(bool bThreadSecurity);
631 
632  [DllImport("QCall", CharSet = CharSet.Unicode)]
633  [SecurityCritical]
634  [SuppressUnmanagedCodeSecurity]
635  internal static extern void GetGrantedPermissions(ObjectHandleOnStack retGranted, ObjectHandleOnStack retDenied, StackCrawlMarkHandle stackMark);
636  }
637 }
SecurityPermissionFlag Flags
Gets or sets the security permission flags.
Allows a permission to expose an unrestricted state.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
FileIOPermissionAccess
Specifies the type of file access requested.
ReflectionPermissionFlag
Specifies the permitted use of the N:System.Reflection and N:System.Reflection.Emit namespaces.
SecurityZone
Defines the integer values corresponding to security zones used by security policy.
Definition: SecurityZone.cs:8
void FromXml(SecurityElement e)
Reconstructs a security object with a given state from an XML encoding.
Definition: PolicyLevel.cs:661
Provides the security zone of a code assembly as evidence for policy evaluation. This class cannot be...
Definition: Zone.cs:10
PolicyLevelType
Specifies the type of a managed code policy level.
static void GetZoneAndOrigin(out ArrayList zone, out ArrayList origin)
Gets the granted zone identity and URL identity permission sets for the current assembly.
PermissionSet PermissionSet
Gets or sets the T:System.Security.PermissionSet of the policy statement.
FileMode
Specifies how the operating system should open a file.
Definition: FileMode.cs:8
Represents the security policy levels for the common language runtime. This class cannot be inherited...
Definition: PolicyLevel.cs:15
Definition: __Canon.cs:3
static void SavePolicyLevel(PolicyLevel level)
Saves a modified security policy level loaded with M:System.Security.SecurityManager....
override string ReadToEnd()
Reads all characters from the current position to the end of the stream.
Implements a T:System.IO.TextReader that reads characters from a byte stream in a particular encoding...
Definition: StreamReader.cs:13
static IEnumerator ResolvePolicyGroups(Evidence evidence)
Gets a collection of code groups matching the specified evidence.
static bool CheckExecutionRights
Gets or sets a value indicating whether code must have F:System.Security.Permissions....
Grants Web permission to the site from which the assembly was downloaded. This class cannot be inheri...
Definition: NetCodeGroup.cs:13
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
Definition: AppDomain.cs:274
Represents the statement of a T:System.Security.Policy.CodeGroup describing the permissions and other...
Represents an application domain, which is an isolated environment where applications execute....
Definition: AppDomain.cs:33
ReflectionPermissionFlag Flags
Gets or sets the type of reflection allowed for the current permission.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
void AddPathList(FileIOPermissionAccess access, string path)
Adds access for the specified file or directory to the existing state of the permission.
static PermissionSet GetStandardSandbox(Evidence evidence)
Gets a permission set that is safe to grant to an application that has the provided evidence.
Grants permission to manipulate files located in the code assemblies to code assemblies that match th...
Represents a collection that can contain many different types of permissions.
static PolicyLevel LoadPolicyLevelFromFile(string path, PolicyLevelType type)
Loads a T:System.Security.Policy.PolicyLevel from the specified file.
bool IsEmpty()
Gets a value indicating whether the T:System.Security.PermissionSet is empty.
static bool SecurityEnabled
Gets or sets a value indicating whether security is enabled.
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
Definition: FileStream.cs:15
Controls the permissions related to user interfaces and the Clipboard. This class cannot be inherited...
Definition: UIPermission.cs:9
static bool IsGranted(IPermission perm)
Determines whether a permission is granted to the caller.
Defines the underlying structure of all code access permissions.
static PermissionSet ResolveSystemPolicy(Evidence evidence)
Determines which permissions to grant to code based on the specified evidence, excluding the policy f...
override PolicyStatement Resolve(Evidence evidence)
Resolves policy for the code group and its descendants for a set of evidence.
static string GetFullPath(string path)
Returns the absolute path for the specified path string.
Definition: Path.cs:446
MethodImplOptions
Defines the details of how a method is implemented.
CharSet
Dictates which character set marshaled strings should use.
Definition: CharSet.cs:7
Represents a membership condition that matches all code. This class cannot be inherited.
override PolicyStatement Resolve(Evidence evidence)
Resolves policy for the code group and its descendants for a set of evidence.
Defines methods implemented by permission types.
Definition: IPermission.cs:7
static PolicyLevel LoadPolicyLevelFromString(string str, PolicyLevelType type)
Loads a T:System.Security.Policy.PolicyLevel from the specified string.
PermissionSet Intersect(PermissionSet other)
Creates and returns a permission set that is the intersection of the current T:System....
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
static void SavePolicy()
Saves the modified security policy state.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
FileAccess
Defines constants for read, write, or read/write access to a file.
Definition: FileAccess.cs:9
Defines the set of information that constitutes input to security policy decisions....
Definition: Evidence.cs:17
static IEnumerator PolicyHierarchy()
Provides an enumerator to access the security policy hierarchy by levels, such as computer policy and...
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
Definition: File.cs:14
Controls access to system and user environment variables. This class cannot be inherited.
Provides the main access point for classes interacting with the security system. This class cannot be...
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Controls the ability to access files and folders. This class cannot be inherited.
static PermissionSet ResolvePolicy(Evidence evidence)
Determines what permissions to grant to code based on the specified evidence.
SecurityZone SecurityZone
Gets the zone from which the code assembly originates.
Definition: Zone.cs:30
static PermissionSet ResolvePolicy(Evidence[] evidences)
Determines what permissions to grant to code based on the specified evidence.
SecurityPermissionFlag
Specifies access flags for the security permission object.
Controls access to non-public types and members through the N:System.Reflection APIs....
static PermissionSet ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, out PermissionSet denied)
Determines what permissions to grant to code based on the specified evidence and requests.
The exception that is thrown when policy forbids code to run.
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9
Performs operations on T:System.String instances that contain file or directory path information....
Definition: Path.cs:13
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14
static bool CurrentThreadRequiresSecurityContextCapture()
Determines whether the current thread requires a security context capture if its security state has t...
Controls the ability to access files or folders through a File dialog box. This class cannot be inher...