Beispiel #1
0
        public static LogicSession GetServiceLogicSession()
        {
            LogicSession logicSession = new LogicSession(AppConfig.Default_Service_UserId, LogicSessionType.S);

            logicSession.DbId = AppConfig.DefaultDbId;
            LogicContext current = LogicContext.Current;

            current.SetLogicSession(logicSession);
            current.UserId = AppConfig.Default_Service_UserId;
            current.SetDatabase(AppConfig.DefaultDbId);
            return(logicSession);
        }
Beispiel #2
0
        public static LogicSession GetLogicSession()
        {
            LogicSession logicSession = null;
            LogicContext current      = LogicContext.Current;
            bool         flag         = current != null;

            if (flag)
            {
                logicSession = current.UserSession;
            }
            return(logicSession);
        }
Beispiel #3
0
        private void application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context           = ((HttpApplication)sender).Context;
            HttpRequest request           = context.Request;
            string      filePath          = request.FilePath;
            string      executionFilePath = request.AppRelativeCurrentExecutionFilePath;

            GlobalCulture.SetContextCulture();
            LogicContext current = LogicContext.Current;

            current.SetDatabase(AppConfig.DefaultDbId);
            current.Source = filePath;
            HttpCookie cookie = request.Cookies[CookieMemory.FormsCookieName];
            bool       flag   = cookie != null;

            if (flag)
            {
                CookieMemory cookie2      = new CookieMemory(cookie);
                LogicSession logicSession = AuthUtils.GetLogicSession(cookie2);
                bool         flag2        = logicSession != null && logicSession.UserId == cookie2.UserId;
                if (!flag2)
                {
                    AppEventLog.Debug("无法恢复");
                    return;
                }
                current.CookieUpdateTime     = cookie2.UpdateTime;
                logicSession.LastRequestTime = AppRuntime.ServerDateTime;
                current.SetLogicSession(logicSession);
                current.UserAuthCookies = cookie;
            }
            bool flag3 = filePath == null;

            if (!flag3)
            {
                string s     = StringHelper.RightSubstring(filePath, 5);
                bool   flag4 = (!StringHelper.EqualsIgnoreCase(s, ".aspx") && !StringHelper.EqualsIgnoreCase(s, ".asmx") && !StringHelper.EqualsIgnoreCase(s, ".ashx")) || context.Request.Url.ToString().IndexOf("ActiveModule.aspx") < 0;
                if (!flag4)
                {
                    string routeUrl = ModuleUtils.GetRouteUrl(request.QueryString["AMID"].ToString().Trim().ToInt());
                    current.AmId = request.QueryString["AMID"].ToString().Trim().ToInt();
                    bool flag5 = routeUrl.IndexOf("?") < 0;
                    if (flag5)
                    {
                        context.Response.Redirect(routeUrl + "?" + context.Request.QueryString, false);
                    }
                    else
                    {
                        context.Response.Redirect(routeUrl + "&" + context.Request.QueryString, false);
                    }
                }
            }
        }
Beispiel #4
0
        internal void SetLogicSession(LogicSession logicSession)
        {
            bool flag = logicSession == null;

            if (!flag)
            {
                this.UserSession    = logicSession;
                this.LogicSessionId = logicSession.SessionId;
                this.UserId         = logicSession.UserId;
                this.UserName       = logicSession.UserName;
                this.DbId           = logicSession.DbId;
                this.TmpID          = logicSession.TmpID;
            }
        }
Beispiel #5
0
        private void HandlerRequest(HttpContext context)
        {
            LogicContext current = LogicContext.Current;
            bool         flag    = current == null || current.HeaderIsSend;

            if (!flag)
            {
                current.HeaderIsSend = true;
                LogicSession userSession = current.UserSession;
                bool         flag2       = userSession == null || string.IsNullOrEmpty(userSession.UserId) || userSession.Ignore;
                if (flag2)
                {
                    FormsAuthentication.SignOut();
                }
                else
                {
                    bool flag3 = userSession.RewriteAuthSession() && current.CookieUpdateTime < userSession.UpdateTime;
                    if (flag3)
                    {
                        NameValueString nameValueString = new NameValueString();
                        nameValueString.Add("U", userSession.UserId);
                        nameValueString.Add("S", userSession.SessionId);
                        nameValueString.Add("T", userSession.UpdateTime.To16String());
                        HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userSession.UserId, false);
                        authCookie.Path = context.Request.ApplicationPath;
                        FormsAuthenticationTicket authenticationTicket = FormsAuthentication.Decrypt(authCookie.Value);
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(authenticationTicket.Version, authenticationTicket.Name, authenticationTicket.IssueDate, authenticationTicket.Expiration, authenticationTicket.IsPersistent, nameValueString.LineText, authenticationTicket.CookiePath);
                        authCookie.Value = FormsAuthentication.Encrypt(ticket);
                        context.Response.Cookies.Set(authCookie);
                    }
                }
                bool flag4 = userSession == null || string.IsNullOrEmpty(userSession.UserId) || !userSession.Ignore;
                if (flag4)
                {
                }
            }
        }