Example #1
0
        public override void Initialize(string name,
                                        System.Collections.Specialized.NameValueCollection config)
        {
            // Initialize values from Web.config.
            if (null == config)
            {
                throw (new ArgumentNullException("config"));
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "MemcachedProviders.CacheProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Memcached Cache Provider");
            }
            // Call the base class implementation.
            base.Initialize(name, config);

            // Load configuration data.
            _lDefaultExpireTime =
                Convert.ToInt64(ConfigurationUtil.GetConfigValue(config["defaultExpireTime"], "2000"));

            _strKeySuffix =
                ConfigurationUtil.GetConfigValue(config["keySuffix"], string.Empty);

            this._client = MemcachedProviders.Common.MemcachedClientService.Instance.Client;
        }
Example #2
0
 public override void Initialize(string name, NameValueCollection config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     if (string.IsNullOrEmpty(name))
     {
         name = "NHibernateRoleProvider";
     }
     if (string.IsNullOrEmpty(config["description"]))
     {
         config.Remove("description");
         config.Add("description", "NHibernate Role Provider");
     }
     base.Initialize(name, config);
     application =
         SystemApplicationWrapper.CreateOrLoadApplication(
             ConfigurationUtil.GetConfigValue(config["applicationName"],
                                              HostingEnvironment.ApplicationVirtualPath));
 }
Example #3
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "NHibernateMembershipProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "NHibernate Membership Provider");
            }
            base.Initialize(name, config);
            application =
                SystemApplicationWrapper.CreateOrLoadApplication(
                    ConfigurationUtil.GetConfigValue(config["applicationName"],
                                                     HostingEnvironment.ApplicationVirtualPath));
            requiresQuestionAndAnswer =
                Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["requiresQuestionAndAnswer"], "False"));
            requiresUniqueEmail =
                Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["requiresUniqueEmail"], "True"));
            enablePasswordRetrieval =
                Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["enablePasswordRetrieval"], "True"));
            enablePasswordReset =
                Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["enablePasswordReset"], "True"));
            maxInvalidPasswordAttempts =
                Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            passwordAttemptWindow =
                Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["passwordAttemptWindow"], "10"));
            minRequiredPasswordLength =
                Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["minRequiredPasswordLength"], "7"));
            minRequiredNonAlphanumericCharacters =
                Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["minRequiredAlphaNumericCharacters"], "1"));
            passwordStrengthRegularExpression =
                Convert.ToString(ConfigurationUtil.GetConfigValue(config["passwordStrengthRegularExpression"],
                                                                  string.Empty));
            string configValue = ConfigurationUtil.GetConfigValue(config["passwordFormat"], "Hashed");

            if (configValue != null)
            {
                if (!(configValue == "Hashed"))
                {
                    if (configValue == "Encrypted")
                    {
                        passwordFormat = MembershipPasswordFormat.Encrypted;
                        goto Label_01FB;
                    }
                    if (configValue == "Clear")
                    {
                        passwordFormat = MembershipPasswordFormat.Clear;
                        goto Label_01FB;
                    }
                }
                else
                {
                    passwordFormat = MembershipPasswordFormat.Hashed;
                    goto Label_01FB;
                }
            }
            throw NhibernateMembershipProviderExceptionUtil.NewProviderException(this, "password format not supported");
Label_01FB:
            Configuration configuration =
                WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);

            machineKey = (MachineKeySection)configuration.GetSection("system.web/machineKey");
            if ("Auto".Equals(machineKey.Decryption))
            {
                machineKey.DecryptionKey = CryptographyUtil.CreateKey(0x18);
                machineKey.ValidationKey = CryptographyUtil.CreateKey(0x40);
            }
        }