2 * Namespace: System.Web
\r
5 * Author: Gaurav Vaish
\r
6 * Contact: <gvaish@iitk.ac.in>
\r
9 * (C) Gaurav Vaish (2001)
\r
13 using System.Security;
\r
14 using System.Security.Permissions;
\r
15 using System.Web.Caching;
\r
16 using System.Web.UI;
\r
17 using System.Web.Utils;
\r
19 namespace System.Web
\r
21 public sealed class HttpRuntime
\r
23 internal static byte[] autogenKeys;
\r
25 private static bool initialized;
\r
26 private static string installDir;
\r
27 private static HttpRuntime runtime;
\r
30 /// Loading of ISAPI
\r
32 private static bool isapiLoaded;
\r
34 private Cache cache;
\r
36 // Security permission helper objects
\r
37 private static IStackWalk appPathDiscoveryStackWalk;
\r
38 private static IStackWalk ctrlPrincipalStackWalk;
\r
39 private static IStackWalk sensitiveInfoStackWalk;
\r
40 private static IStackWalk unmgdCodeStackWalk;
\r
41 private static IStackWalk unrestrictedStackWalk;
\r
42 private static IStackWalk reflectionStackWalk;
\r
44 private string appDomainAppPath;
\r
45 private string appDomainAppVirtualPath;
\r
47 private FileChangesMonitor fcm;
\r
49 private Exception initErrorException;
\r
51 static HttpRuntime()
\r
53 autogenKeys = new byte[88];
\r
54 initialized = false;
\r
55 isapiLoaded = false;
\r
57 appPathDiscoveryStackWalk = null;
\r
58 ctrlPrincipalStackWalk = null;
\r
59 sensitiveInfoStackWalk = null;
\r
60 unmgdCodeStackWalk = null;
\r
61 unrestrictedStackWalk = null;
\r
63 if(!DesignTimeParseData.InDesigner)
\r
65 runtime = new HttpRuntime();
\r
66 if(!DesignTimeParseData.InDesigner)
\r
70 //FIXME: IIS specific code. Need information on what to do for Apache?
\r
71 internal static void Initialize()
\r
75 bool moduleObtained = false;
\r
76 string file = IISVersionInfo.GetLoadedModuleFilename("aspnet_isapi.dll");
\r
78 string version = null;
\r
81 dir = file.Substring(0, file.LastIndexOf('\\'));
\r
82 moduleObtained = true;
\r
84 if(dir!=null && dir.Length > 0)
\r
88 version = IISVersionInfo.SystemWebVersion;
\r
89 /* TODO: I need the code to read registry
\r
90 * I need LOCAL_MACHINE\Software\Micorosoft\ASP.NET\<version>
\r
97 if(dir==null || dir.Length == 0)
\r
99 string modulefile = (typeof(HttpRuntime)).Module.FullyQualifiedName;
\r
100 dir = modulefile.Substring(0, modulefile.LastIndexOf('\\'));
\r
102 if(!moduleObtained)
\r
104 //TODO: Now what? Module still not obtained
\r
105 // Try loading using native calls. something like LoadLibrary(...) in *java*
\r
106 // LoadLibrary(dir+"\\aspnet_asp.dll)
\r
110 //TODO: Initialize the library
\r
111 // InitIsapiLibrary();
\r
114 isapiLoaded = moduleObtained;
\r
115 initialized = true;
\r
120 private void Init()
\r
122 initErrorException = null;
\r
123 cache = new Cache();
\r
124 appDomainAppPath = "";
\r
130 // throw new PlatformNotSupportedException();
\r
131 //I am here <gvaish>
\r
132 throw new NotImplementedException();
\r
133 } catch(Exception e)
\r
135 initErrorException = e;
\r
139 [MonoTODO("FormatResourceString(string, string, string)")]
\r
140 internal static string FormatResourceString(string key, string arg0, string type)
\r
142 throw new NotImplementedException();
\r
145 internal static string FormatResourceString(string key, string arg0)
\r
147 string format = GetResourceString(key);
\r
150 return String.Format(format, arg0);
\r
153 internal static string FormatResourceString(string key)
\r
155 return GetResourceString(key);
\r
158 private static string GetResourceString(string key)
\r
160 return runtime.GetResourceStringFromResourceManager(key);
\r
163 [MonoTODO("GetResourceStringFromResourceManager(string)")]
\r
164 private string GetResourceStringFromResourceManager(string key)
\r
166 throw new NotImplementedException();
\r
169 public static Cache Cache
\r
173 return runtime.cache;
\r
178 public static string AppDomainAppId
\r
182 throw new NotImplementedException();
\r
187 public static string AppDomainAppPath
\r
191 throw new NotImplementedException();
\r
196 public static string AppDomainAppVirtualPath
\r
200 throw new NotImplementedException();
\r
205 public static string AppDomainId
\r
209 throw new NotImplementedException();
\r
214 public static string AspInstallDirectory
\r
218 throw new NotImplementedException();
\r
223 public static string BinDirectory
\r
227 throw new NotImplementedException();
\r
232 public static string ClrInstallDirectory
\r
236 throw new NotImplementedException();
\r
241 public static string CodegenDir
\r
245 throw new NotImplementedException();
\r
250 public static bool IsOnUNCShare
\r
254 throw new NotImplementedException();
\r
259 public static string MachineConfigurationDirectory
\r
263 throw new NotImplementedException();
\r
268 public static void Close()
\r
270 throw new NotImplementedException();
\r
273 internal static IStackWalk AppPathDiscovery
\r
277 if(appPathDiscoveryStackWalk == null)
\r
279 appPathDiscoveryStackWalk = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, runtime.appDomainAppPath);
\r
281 return appPathDiscoveryStackWalk;
\r
285 internal static IStackWalk ControlPrincipal
\r
289 if(ctrlPrincipalStackWalk == null)
\r
291 ctrlPrincipalStackWalk = new SecurityPermission(SecurityPermissionFlag.ControlPrincipal);
\r
293 return ctrlPrincipalStackWalk;
\r
297 internal static IStackWalk Reflection
\r
301 if(reflectionStackWalk == null)
\r
303 reflectionStackWalk = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation | ReflectionPermissionFlag.MemberAccess);
\r
305 return reflectionStackWalk;
\r
309 internal static IStackWalk SensitiveInformation
\r
313 if(sensitiveInfoStackWalk == null)
\r
315 sensitiveInfoStackWalk = new EnvironmentPermission(PermissionState.Unrestricted);
\r
317 return sensitiveInfoStackWalk;
\r
321 internal static IStackWalk UnmanagedCode
\r
325 if(unmgdCodeStackWalk == null)
\r
327 unmgdCodeStackWalk = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
\r
329 return unmgdCodeStackWalk;
\r
333 internal static IStackWalk Unrestricted
\r
337 if(unrestrictedStackWalk == null)
\r
339 unrestrictedStackWalk = new PermissionSet(PermissionState.Unrestricted);
\r
341 return unrestrictedStackWalk;
\r
345 internal static IStackWalk FileReadAccess(string file)
\r
347 return new FileIOPermission(FileIOPermissionAccess.Read, file);
\r
350 internal static IStackWalk PathDiscoveryAccess(string path)
\r
352 return new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path);
\r