private static void Initialize() { if (!_initialized) { lock (LockObject) { if (!_initialized) { FormsAuthentication.Initialize(); DeviceAuthenticationConfig = DeviceAuthenticationConfiguration.GetConfig(); if (DeviceAuthenticationConfig != null) { _enabled = true; _hashAlgorithm = new SHA512Managed(); _enforceClientHostAddressValidation = DeviceAuthenticationConfig.EnforceClientHostAddressValidation; _enforceUserAgentValidation = DeviceAuthenticationConfig.EnforceUserAgentValidation; _hashSalt = DeviceAuthenticationConfig.HashSalt; _path = DeviceAuthenticationConfig.Path; _requireSsl = DeviceAuthenticationConfig.RequireSsl; _slidingExpiration = DeviceAuthenticationConfig.SlidingExpiration; _providers = new DeviceAuthenticationTicketProviderCollection(); ProvidersHelper.InstantiateProviders(DeviceAuthenticationConfig.Providers, _providers, typeof (DeviceAuthenticationTicketProviderBase)); _providers.SetReadOnly(); _provider = _providers[DeviceAuthenticationConfig.StateProvider]; if (_provider == null) { throw new Exception("defaultProvider"); } if (_hashSalt == "ExampleSalt") { throw new ConfigurationErrorsException("For security purposes, you must change the example salt in web.config's userAuthentication element.`"); } } else { _enabled = false; } _initialized = true; } } } }
private static void Initialize() { if (!_initialized) { lock (LockObject) { if (!_initialized) { DeviceAuthenticationConfiguration configuration = (DeviceAuthenticationConfiguration) ConfigurationManager.GetSection("DeviceAuthentication"); if (configuration == null) throw new ConfigurationErrorsException("DeviceAuthentication configuration section is not configured correctly."); _providers = new DeviceAuthenticationTicketProviderCollection(); ProvidersHelper.InstantiateProviders(configuration.Providers, _providers, typeof (DeviceAuthenticationTicketProviderCollection)); _providers.SetReadOnly(); _provider = _providers[configuration.StateProvider]; if (_provider == null) throw new Exception("defaultProvider"); } } } }