Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2009-11-07 00:25:38 +0300
committerMiguel de Icaza <miguel@gnome.org>2009-11-07 00:25:38 +0300
commit4baa1d2bc2c7d8bb4c7181b83eac3146c0681666 (patch)
tree9927ff110ec25da72b4afd2f1cdc313871ae2c43 /mcs/class/corlib/System.Security/SecurityManager.cs
parent22429fdd7886171c629cf66d1490e32697dc8fd0 (diff)
More removal of old defines
svn path=/trunk/mcs/; revision=145609
Diffstat (limited to 'mcs/class/corlib/System.Security/SecurityManager.cs')
-rw-r--r--mcs/class/corlib/System.Security/SecurityManager.cs74
1 files changed, 8 insertions, 66 deletions
diff --git a/mcs/class/corlib/System.Security/SecurityManager.cs b/mcs/class/corlib/System.Security/SecurityManager.cs
index d08b1f32e74..7040a08128f 100644
--- a/mcs/class/corlib/System.Security/SecurityManager.cs
+++ b/mcs/class/corlib/System.Security/SecurityManager.cs
@@ -52,16 +52,8 @@ namespace System.Security {
public RuntimeDeclSecurityEntry choice;
}
-#if NET_2_0
[ComVisible (true)]
public static class SecurityManager {
-#else
- public sealed class SecurityManager {
-
- private SecurityManager ()
- {
- }
-#endif
private static object _lockObject;
private static ArrayList _hierarchy;
private static IPermission _unmanagedCode;
@@ -86,9 +78,7 @@ namespace System.Security {
set;
}
-#if NET_2_0
[Obsolete ("The security manager cannot be turned off on MS runtime")]
-#endif
extern public static bool SecurityEnabled {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
get;
@@ -100,7 +90,6 @@ namespace System.Security {
// methods
-#if NET_1_1
// NOTE: This method doesn't show in the class library status page because
// it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
// But it's there!
@@ -112,7 +101,6 @@ namespace System.Security {
zone = new ArrayList ();
origin = new ArrayList ();
}
-#endif
public static bool IsGranted (IPermission perm)
{
@@ -126,23 +114,15 @@ namespace System.Security {
// - Not affected by overrides (like Assert, Deny and PermitOnly)
// - calls IsSubsetOf even for non CAS permissions
// (i.e. it does call Demand so any code there won't be executed)
-#if NET_2_0
// with 2.0 identity permission are unrestrictable
return IsGranted (Assembly.GetCallingAssembly (), perm);
-#else
- if (perm is IUnrestrictedPermission)
- return IsGranted (Assembly.GetCallingAssembly (), perm);
- else
- return IsGrantedRestricted (Assembly.GetCallingAssembly (), perm);
-#endif
}
-#if !NET_2_0
- // only for permissions that do not implement IUnrestrictedPermission
- internal static bool IsGrantedRestricted (Assembly a, IPermission perm)
+ // note: in 2.0 *all* permissions (including identity permissions) support unrestricted
+ internal static bool IsGranted (Assembly a, IPermission perm)
{
- PermissionSet granted = a.GrantedPermissionSet;
- if (granted != null) {
+ PermissionSet granted = a.GrantedPermissionSet;
+ if ((granted != null) && !granted.IsUnrestricted ()) {
CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());
if (!perm.IsSubsetOf (grant)) {
return false;
@@ -150,35 +130,15 @@ namespace System.Security {
}
PermissionSet denied = a.DeniedPermissionSet;
- if (denied != null) {
+ if ((denied != null) && !denied.IsEmpty ()) {
+ if (denied.IsUnrestricted ())
+ return false;
CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());
if ((refuse != null) && perm.IsSubsetOf (refuse))
return false;
}
return true;
}
-#endif
- // note: in 2.0 *all* permissions (including identity permissions) support unrestricted
- internal static bool IsGranted (Assembly a, IPermission perm)
- {
- PermissionSet granted = a.GrantedPermissionSet;
- if ((granted != null) && !granted.IsUnrestricted ()) {
- CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());
- if (!perm.IsSubsetOf (grant)) {
- return false;
- }
- }
-
- PermissionSet denied = a.DeniedPermissionSet;
- if ((denied != null) && !denied.IsEmpty ()) {
- if (denied.IsUnrestricted ())
- return false;
- CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());
- if ((refuse != null) && perm.IsSubsetOf (refuse))
- return false;
- }
- return true;
- }
internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
{
@@ -188,18 +148,8 @@ namespace System.Security {
foreach (IPermission p in ps) {
// note: this may contains non CAS permissions
if ((!noncas) && (p is CodeAccessPermission)) {
-#if NET_2_0
if (!IsGranted (a, p))
return p;
-#else
- if (p is IUnrestrictedPermission) {
- if (!IsGranted (a, p))
- return p;
- } else {
- if (!IsGrantedRestricted (a, p))
- return p;
- }
-#endif
} else {
// but non-CAS will throw on failure...
try {
@@ -222,13 +172,8 @@ namespace System.Security {
PermissionSet granted = ad.GrantedPermissionSet;
if (granted == null)
return null;
-#if NET_2_0
if (granted.IsUnrestricted ())
return null;
-#else
- if ((granted.Count == 0) && granted.IsUnrestricted ())
- return null;
-#endif
if (ps.IsUnrestricted ())
return new SecurityPermission (SecurityPermissionFlag.NoFlags);
@@ -318,7 +263,6 @@ namespace System.Security {
return ps;
}
-#if NET_2_0
[MonoTODO ("(2.0) more tests are needed")]
public static PermissionSet ResolvePolicy (Evidence[] evidences)
{
@@ -355,7 +299,6 @@ namespace System.Security {
ResolveIdentityPermissions (ps, evidence);
return ps;
}
-#endif
static private SecurityPermission _execution = new SecurityPermission (SecurityPermissionFlag.Execution);
@@ -488,11 +431,10 @@ namespace System.Security {
internal static void ResolveIdentityPermissions (PermissionSet ps, Evidence evidence)
{
-#if NET_2_0
// in 2.0 identity permissions can now be unrestricted
if (ps.IsUnrestricted ())
return;
-#endif
+
// Only host evidence are used for policy resolution
IEnumerator ee = evidence.GetHostEnumerator ();
while (ee.MoveNext ()) {