Initialize() public static method

public static Initialize ( ) : void
return void
        ////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////
        /// <include file='doc\FormsAuthenticationModule.uex' path='docs/doc[@for="FormsAuthenticationModule.OnEnter"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        private void OnEnter(Object source, EventArgs eventArgs)
        {
            if (_fAuthChecked && !_fAuthRequired)
            {
                return;
            }

            HttpApplication app;
            HttpContext     context;

            app     = (HttpApplication)source;
            context = app.Context;

            AuthenticationConfig settings = (AuthenticationConfig)context.GetConfig("system.web/authentication");

            if (!_fAuthChecked)
            {
                _fAuthRequired = (settings.Mode == AuthenticationMode.Forms);
                _fAuthChecked  = true;
            }

            if (!_fAuthRequired)
            {
                return;
            }


            if (!_fFormsInit)
            {
                Trace("Initializing Forms Auth Manager");
                FormsAuthentication.Initialize();
                _FormsName = settings.CookieName;

                if (_FormsName == null)
                {
                    _FormsName = CONFIG_DEFAULT_COOKIE;
                }
                Trace("Forms name is: " + _FormsName);


                _LoginUrl = settings.LoginUrl;
                if (_LoginUrl == null)
                {
                    _LoginUrl = CONFIG_DEFAULT_LOGINURL;
                }
                _fFormsInit = true;
            }

            ////////////////////////////////////////////////////////
            // Step 2: Call OnAuthenticate virtual method to create
            //    an IPrincipal for this request
            OnAuthenticate(new FormsAuthenticationEventArgs(context));

            ////////////////////////////////////////////////////////
            // Skip AuthZ if accessing the login page
            context.SkipAuthorization = AuthenticationConfig.AccessingLoginPage(context, _LoginUrl);
        }
Beispiel #2
0
 public void Init(HttpApplication app)
 {
     if (!_fAuthChecked)
     {
         _fAuthRequired = AuthenticationConfig.Mode == AuthenticationMode.Forms;
         _fAuthChecked  = true;
     }
     if (_fAuthRequired)
     {
         FormsAuthentication.Initialize();
         app.AuthenticateRequest += new EventHandler(this.OnEnter);
         app.EndRequest          += new EventHandler(this.OnLeave);
     }
 }
Beispiel #3
0
        public void Init(HttpApplication app)
        {
            // authentication is an app level setting only
            // so we can read app config early on in an attempt to try and
            // skip wiring up event delegates
            if (!_fAuthChecked)
            {
                _fAuthRequired = (AuthenticationConfig.Mode == AuthenticationMode.Forms);
                _fAuthChecked  = true;
            }

            if (_fAuthRequired)
            {
                // initialize if mode is forms auth
                FormsAuthentication.Initialize();

                app.AuthenticateRequest += new EventHandler(this.OnEnter);
                app.EndRequest          += new EventHandler(this.OnLeave);
            }
        }