Esempio n. 1
0
        public void Init(HttpApplication context)
        {
            _formsAuthenticationModule = new FormsAuthenticationModule();

            // используется блок try-catch, так как при инициализации _formsAuthenticationModule могут возникнуть всякие exception'ы (например, при попытке его подцепиться ко всяким событиям application'а, context'а или request'а).
            try
            {
                using (HttpApplication fakeApplication = new HttpApplication())
                {
                    _formsAuthenticationModule.Init(fakeApplication);
                }
            }
            catch (Exception)
            {
            }

            // using reflection - need FULL TRUST
            Type t = _formsAuthenticationModule.GetType();

            _formsAuthenticationModuleOnEnter = t.GetMethod("OnEnter", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Object), typeof(EventArgs) }, null);
            _formsAuthenticationModuleOnLeave = t.GetMethod("OnLeave", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Object), typeof(EventArgs) }, null);

            if (_formsAuthenticationModuleOnEnter == null || _formsAuthenticationModuleOnLeave == null)
            {
                throw new Exception("Unable to get all required FormsAuthenticationModule entrypoints using reflection.");
            }

            context.AuthenticateRequest     += new EventHandler(OnAuthenticateRequest);
            context.PostAuthenticateRequest += new EventHandler(OnPostAuthenticateRequest);
            context.EndRequest += new EventHandler(OnEndRequest);
        }
Esempio n. 2
0
        private static void CallInternalOnEnter(object sender, EventArgs e)
        {
            FormsAuthenticationModule formsAuthenticationModule   = new FormsAuthenticationModule();
            MethodInfo formsAuthenticationModuleOnEnterMethodInfo = formsAuthenticationModule.GetType().GetMethod("OnEnter", BindingFlags.Instance | BindingFlags.NonPublic);

            formsAuthenticationModuleOnEnterMethodInfo.Invoke(
                formsAuthenticationModule,
                new object[] { sender, e });
        }
Esempio n. 3
0
 protected override void Dispose(bool disposing)
 {
     if (HttpContext.Current != null && HttpContext.Current.Session != null)
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), HttpContext.Current.Session.SessionID);
     }
     FormsAuthenticationModule.SignOut();
     base.Dispose(disposing);
 }
Esempio n. 4
0
        public SharpZipHelper()
        {
            FormsAuthenticationModule module = new FormsAuthenticationModule();

            module.Authenticate += new FormsAuthenticationEventHandler(module_Authenticate);
            FormsAuthenticationTicket ticket   = new FormsAuthenticationTicket("acheng", true, 20);
            FormsIdentity             identity = new FormsIdentity(ticket);

            System.Security.Principal.GenericIdentity gIdentity = new System.Security.Principal.GenericIdentity("acheng", "generic");
            GenericPrincipal pricipal = new GenericPrincipal(gIdentity, new string[] { "admin", "superadmin" });
        }
Esempio n. 5
0
        private void OnEndRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            string          authType    = application.Context.Items["AuthType"] as string;

            if (authType == "Forms")
            {
                FormsAuthenticationModule formsAuthenticationModule   = new FormsAuthenticationModule();
                MethodInfo formsAuthenticationModuleOnEnterMethodInfo =
                    formsAuthenticationModule.GetType().GetMethod("OnLeave", BindingFlags.Instance | BindingFlags.NonPublic);
                formsAuthenticationModuleOnEnterMethodInfo.Invoke(
                    formsAuthenticationModule,
                    new object[] { sender, e });
            }

            SnTrace.Web.Write("PortalAuthenticationModule.OnEndRequest. Url:{0}, StatusCode:{1}",
                              HttpContext.Current.Request.Url, HttpContext.Current.Response.StatusCode);
        }
        void OnEndRequest(object sender, EventArgs e)
        {
            //DebugThis("begin:" + HttpContext.Current.Response.StatusCode.ToString());

            HttpApplication application = sender as HttpApplication;
            string          authType    = application.Context.Items["AuthType"] as string;

            if (authType == "Forms")
            {
                FormsAuthenticationModule formsAuthenticationModule   = new FormsAuthenticationModule();
                MethodInfo formsAuthenticationModuleOnEnterMethodInfo =
                    formsAuthenticationModule.GetType().GetMethod("OnLeave", BindingFlags.Instance | BindingFlags.NonPublic);
                formsAuthenticationModuleOnEnterMethodInfo.Invoke(
                    formsAuthenticationModule,
                    new object[] { sender, e });
            }

            Logger.WriteVerbose("PortalAuthenticationModule.OnEndRequest",
                                new Dictionary <string, object> {
                { "Url", HttpContext.Current.Request.Url },
                { "StatusCode", HttpContext.Current.Response.StatusCode }
            });
        }
Esempio n. 7
0
 public void Dispose()
 {
     _formsAuthenticationModule.Dispose();
     _formsAuthenticationModule = null;
     GC.SuppressFinalize(this);
 }
Esempio n. 8
0
 public void FixtureSetUp()
 {
     app    = new HttpApplication();
     module = new FormsAuthenticationModule();
 }