void OnAuthenticateRequest(object sender, EventArgs args) { HttpApplication app = (HttpApplication)sender; BaseWorkerRequest req = J2EEUtils.GetWorkerRequest(app.Context); if (req.GetRemoteUser() != null) { app.Context.User = new ServletPrincipal(req); } }
internal static HttpSession GetSession(HttpContext context, bool create, bool throwOnError) { HttpSession session = J2EEUtils.GetWorkerRequest(context).GetSession(create); if (session == null && throwOnError) { throw new HttpException("Session is not established"); } return(session); }
} // For Java deserialization public ServletSessionStateItemCollection(HttpContext context) : this() { _items = new SessionStateItemCollection(); _staticObjects = new HttpStaticObjectsCollection(); if (context != null) { ServletContext servletContext = J2EEUtils.GetWorkerRequest(context).GetContext(); string sessionPersistance = servletContext.getInitParameter(J2EEConsts.Enable_Session_Persistency); if (sessionPersistance != null) { try { _needSessionPersistence = Boolean.Parse(sessionPersistance); } catch (Exception) { _needSessionPersistence = false; Debug.WriteLine("EnableSessionPersistency init param's value is invalid. the value is " + sessionPersistance); } } } }
public override string MapPath(string virtualPath) { if (virtualPath == null) { throw new ArgumentNullException("virtualPath"); } ServletContext context = GetContext(); string contextPath = GetAppPath(); if ((virtualPath.Length > contextPath.Length && virtualPath [contextPath.Length] != '/') || string.Compare(contextPath, 0, virtualPath, 0, contextPath.Length, StringComparison.OrdinalIgnoreCase) != 0) { for (int appVirtualPathIndex = 0; appVirtualPathIndex > 0 && virtualPath.Length > appVirtualPathIndex;) { appVirtualPathIndex = virtualPath.IndexOf('/', appVirtualPathIndex + 1); string crossContextPath = appVirtualPathIndex > 0 ? virtualPath.Remove(appVirtualPathIndex) : virtualPath; ServletContext other = context.getContext(crossContextPath); if (other != null) { string appVirtualPath = appVirtualPathIndex > 0 ? virtualPath.Substring(appVirtualPathIndex) : String.Empty; return(other.getRealPath(appVirtualPath)); } } throw new HttpException( String.Format("MapPath: Mapping across applications is not allowed. ApplicationPath is '{0}', VirtualPath is '{1}'.", contextPath, virtualPath)); } string thisAppVirtualPath = virtualPath.Length > contextPath.Length ? virtualPath.Substring(contextPath.Length) : String.Empty; return(J2EEUtils.GetApplicationRealPath(context, thisAppVirtualPath)); }
private static AppDomain createServletDomain(ServletConfig config) { string rootPath = J2EEUtils.GetApplicationRealPath(config.getServletContext()); AppDomainSetup domainSetup = new AppDomainSetup(); string name = config.getServletName(); //.getServletContextName(); if (name == null) { name = "GH Application"; } domainSetup.ApplicationName = name; domainSetup.ConfigurationFile = Path.Combine(rootPath, "Web.config"); domainSetup.PrivateBinPath = Path.Combine(rootPath, "WEB-INF/lib"); AppDomain servletDomain = AppDomain.CreateDomain(name, null, domainSetup); //servletDomain.SetData(IAppDomainConfig.APP_PHYS_DIR, J2EEUtils.GetApplicationPhysicalPath(config)); //servletDomain.SetData(IAppDomainConfig.WEB_APP_DIR, rootPath); servletDomain.SetData(IAppDomainConfig.APP_PHYS_DIR, J2EEUtils.GetApplicationPhysicalPath(config.getServletContext())); servletDomain.SetData(IAppDomainConfig.WEB_APP_DIR, rootPath); servletDomain.SetData(IAppDomainConfig.SERVLET_CONFIG, config); //Set DataDirectory substitution string (http://blogs.msdn.com/dataaccess/archive/2005/10/28/486273.aspx) string dataDirectory = config.getServletContext().getInitParameter("DataDirectory"); if (dataDirectory == null) { dataDirectory = "App_Data"; } if (!Path.IsPathRooted(dataDirectory)) { java.io.InputStream inputStream = config.getServletContext().getResourceAsStream("/WEB-INF/classes/appData.properties"); string root; if (inputStream != null) { try { Properties props = new Properties(); props.load(inputStream); root = props.getProperty("root.folder"); } finally { inputStream.close(); } } else { root = config.getServletContext().getRealPath("/"); } if (root == null) { root = String.Empty; } dataDirectory = Path.Combine(root, dataDirectory); } if (dataDirectory [dataDirectory.Length - 1] != Path.DirectorySeparatorChar) { dataDirectory += Path.DirectorySeparatorChar; } servletDomain.SetData("DataDirectory", dataDirectory); if (config.getServletContext().getRealPath("/") == null) { servletDomain.SetData(".appStartTime", DateTime.UtcNow); } // The BaseDir is the full path to the physical dir of the app // and allows the application to modify files in the case of // open deployment. string webApp_baseDir = config.getServletContext().getRealPath(""); if (webApp_baseDir == null || webApp_baseDir == "") { webApp_baseDir = rootPath; } servletDomain.SetData(IAppDomainConfig.APP_BASE_DIR, webApp_baseDir); Debug.WriteLine("Initialization of webapp " + webApp_baseDir); //servletDomain.SetData(".hostingVirtualPath", "/"); //servletDomain.SetData(".hostingInstallDir", "/"); return(servletDomain); }
public override string GetAppPathTranslated() { return(J2EEUtils.GetApplicationRealPath(GetContext())); }
public string GetSessionID(HttpContext context) { BaseWorkerRequest request = J2EEUtils.GetWorkerRequest(context); return(request.IsRequestedSessionIdValid() ? request.GetRequestedSessionId() : null); }