1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
namespace System.Web {
using System.Web;
using System.Web.Util;
using System.Security;
using System.Security.Permissions;
internal static class InternalSecurityPermissions {
private static IStackWalk _unrestricted;
private static IStackWalk _unmanagedCode;
private static IStackWalk _controlPrincipal;
private static IStackWalk _reflection;
private static IStackWalk _appPathDiscovery;
private static IStackWalk _controlThread;
private static IStackWalk _levelLow;
private static IStackWalk _levelMedium;
private static IStackWalk _levelHigh;
//
// Static permissions as properties, created on demand
//
internal static IStackWalk Unrestricted {
get {
if (_unrestricted == null)
_unrestricted = new PermissionSet(PermissionState.Unrestricted);
Debug.Trace("Permissions", "Unrestricted Set");
return _unrestricted;
}
}
internal static IStackWalk UnmanagedCode {
get {
if (_unmanagedCode == null)
_unmanagedCode = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
Debug.Trace("Permissions", "UnmanagedCode");
return _unmanagedCode;
}
}
internal static IStackWalk ControlPrincipal {
get {
if (_controlPrincipal == null)
_controlPrincipal = new SecurityPermission(SecurityPermissionFlag.ControlPrincipal);
Debug.Trace("Permissions", "ControlPrincipal");
return _controlPrincipal;
}
}
internal static IStackWalk Reflection {
get {
if (_reflection == null)
_reflection = new ReflectionPermission(ReflectionPermissionFlag.MemberAccess);
Debug.Trace("Permissions", "Reflection");
return _reflection;
}
}
internal static IStackWalk AppPathDiscovery {
get {
if (_appPathDiscovery == null)
_appPathDiscovery = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, HttpRuntime.AppDomainAppPathInternal);
Debug.Trace("Permissions", "AppPathDiscovery");
return _appPathDiscovery;
}
}
internal static IStackWalk ControlThread {
get {
if (_controlThread == null)
_controlThread = new SecurityPermission(SecurityPermissionFlag.ControlThread);
Debug.Trace("Permissions", "ControlThread");
return _controlThread;
}
}
internal static IStackWalk AspNetHostingPermissionLevelLow {
get {
if (_levelLow == null)
_levelLow = new AspNetHostingPermission(AspNetHostingPermissionLevel.Low);
Debug.Trace("Permissions", "AspNetHostingPermissionLevelLow");
return _levelLow;
}
}
internal static IStackWalk AspNetHostingPermissionLevelMedium {
get {
if (_levelMedium == null)
_levelMedium = new AspNetHostingPermission(AspNetHostingPermissionLevel.Medium);
Debug.Trace("Permissions", "AspNetHostingPermissionLevelMedium");
return _levelMedium;
}
}
internal static IStackWalk AspNetHostingPermissionLevelHigh {
get {
if (_levelHigh == null)
_levelHigh = new AspNetHostingPermission(AspNetHostingPermissionLevel.High);
Debug.Trace("Permissions", "AspNetHostingPermissionLevelHigh");
return _levelHigh;
}
}
// Parameterized permissions
internal static IStackWalk FileReadAccess(String filename) {
Debug.Trace("Permissions", "FileReadAccess(" + filename + ")");
return new FileIOPermission(FileIOPermissionAccess.Read, filename);
}
internal static IStackWalk FileWriteAccess(String filename) {
Debug.Trace("Permissions", "FileWriteAccess(" + filename + ")");
return new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Append, filename);
}
internal static IStackWalk PathDiscovery(String path) {
Debug.Trace("Permissions", "PathDiscovery(" + path + ")");
return new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path);
}
}
}
|