Sholo.Web.Security/Authentication/User/UserAuthentication.cs
/// <summary>
/// Initializes configuration-related properties and validates configuration.
/// </summary>        
Initializes configuration-related properties and validates configuration.
Initializes configuration - related properties and validates configuration .
public static void Initialize()
        {
            if (!_initialized)
            {
                lock (LockObject)
                {
                    if (!_initialized)
                    {
                        FormsAuthentication.Initialize();
                        AuthenticationConfig = (AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication");
                        UserAuthenticationConfig = UserAuthenticationConfiguration.GetConfig();
                        if (UserAuthenticationConfig != null)
                        {
                            _enabled = true;
                            _hashAlgorithm = new SHA512Managed();
                            if (AuthenticationConfig == null)
                            {
                                throw new ConfigurationErrorsException("The UserAuthenticationModule requires Forms authentication to be enabled in web.config.");
                            }
                            _formsTimeout = AuthenticationConfig.Forms.Timeout;
                            if (AuthenticationConfig.Mode != AuthenticationMode.Forms)
                            {
                                throw new ConfigurationErrorsException("The UserAuthenticationModule requires Forms authentication to be enabled in web.config.");
                            }
                            if (FormsAuthentication.CookieMode != HttpCookieMode.UseCookies)
                            {
                                throw new ConfigurationErrorsException("The UserAuthenticationModule requires Forms Authentication to use cookies (cookieless='UseCookies').");
                            }
                            if (UserAuthenticationConfig.StateProvider == null)
                            {
                                throw new ConfigurationErrorsException("TODO");
                            }
                            _providers = new UserAuthenticationTicketProviderCollection();                            
                            ProvidersHelper.InstantiateProviders(UserAuthenticationConfig.Providers, _providers, typeof (UserAuthenticationTicketProviderBase));
                            _providers.SetReadOnly();
                            _provider = _providers[UserAuthenticationConfig.StateProvider];
                            _enforceClientHostAddressValidation = UserAuthenticationConfig.EnforceClientHostAddressValidation;
                            _enforceUserAgentValidation = UserAuthenticationConfig.EnforceUserAgentValidation;
                            _hashSalt = UserAuthenticationConfig.HashSalt;
                            if (_hashSalt == "ExampleSalt")
                            {
                                throw new ConfigurationErrorsException("For security purposes, you must change the example salt in web.config's userAuthentication element.`");
                            }
                        }
                        else
                        {
                            _enabled = false;
                            if (AuthenticationConfig != null && AuthenticationConfig.Mode == AuthenticationMode.Forms)
                            {
                                _formsTimeout = AuthenticationConfig.Forms.Timeout;
                            }
                            _enforceClientHostAddressValidation = false;
                            _enforceUserAgentValidation = false;
                        }
                        _initialized = true;
                    }
                }
            }
        }
public static void Initialize ( ) { if ( ! _initialized ) { lock ( LockObject ) { if ( ! _initialized ) { FormsAuthentication . Initialize ( ) ; AuthenticationConfig = ( AuthenticationSection ) WebConfigurationManager . GetSection ( " " ) ; UserAuthenticationConfig = UserAuthenticationConfiguration . GetConfig ( ) ; if ( UserAuthenticationConfig != null ) { _enabled = true ; _hashAlgorithm = new SHA512Managed ( ) ; if ( AuthenticationConfig == null ) { throw new ConfigurationErrorsException ( " " ) ; } _formsTimeout = AuthenticationConfig . Forms . Timeout ; if ( AuthenticationConfig . Mode != AuthenticationMode . Forms ) { throw new ConfigurationErrorsException ( " " ) ; } if ( FormsAuthentication . CookieMode != HttpCookieMode . UseCookies ) { throw new ConfigurationErrorsException ( " " ) ; } if ( UserAuthenticationConfig . StateProvider == null ) { throw new ConfigurationErrorsException ( " " ) ; } _providers = new UserAuthenticationTicketProviderCollection ( ) ; ProvidersHelper . InstantiateProviders ( UserAuthenticationConfig . Providers , _providers , typeof ( UserAuthenticationTicketProviderBase ) ) ; _providers . SetReadOnly ( ) ; _provider = _providers [ UserAuthenticationConfig . StateProvider ] ; _enforceClientHostAddressValidation = UserAuthenticationConfig . EnforceClientHostAddressValidation ; _enforceUserAgentValidation = UserAuthenticationConfig . EnforceUserAgentValidation ; _hashSalt = UserAuthenticationConfig . HashSalt ; if ( _hashSalt == " " ) { throw new ConfigurationErrorsException ( " " ) ; } } else { _enabled = false ; if ( AuthenticationConfig != null && AuthenticationConfig . Mode == AuthenticationMode . Forms ) { _formsTimeout = AuthenticationConfig . Forms . Timeout ; } _enforceClientHostAddressValidation = false ; _enforceUserAgentValidation = false ; } _initialized = true ; } } } }
Initializes configuration-related properties and validates configuration.
Initializes configuration - related properties and validates configuration .
// TODO: Add exception text /* TODO: Implement/fix sliding Provider expiration */