Example #1
0
        /// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call
        /// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider
        /// after the provider has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize values from web.config
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (name == null || name.Length == 0)
            {
                name = "UmbracoMemberRoleProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Umbraco Member Role provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            this._applicationName = config["applicationName"];
            if (string.IsNullOrEmpty(this._applicationName))
            {
                this._applicationName = SecUtility.GetDefaultAppName();
            }
        }
 public override void Initialize(string name, NameValueCollection config)
 {
     if (string.IsNullOrEmpty(name))
     {
         name = "WindowsTokenProvider";
     }
     if (string.IsNullOrEmpty(config["description"]))
     {
         config.Remove("description");
         config.Add("description", System.Web.SR.GetString("RoleWindowsTokenProvider_description"));
     }
     base.Initialize(name, config);
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     this._AppName = config["applicationName"];
     if (string.IsNullOrEmpty(this._AppName))
     {
         this._AppName = SecUtility.GetDefaultAppName();
     }
     if (this._AppName.Length > 0x100)
     {
         throw new ProviderException(System.Web.SR.GetString("Provider_application_name_too_long"));
     }
     config.Remove("applicationName");
     if (config.Count > 0)
     {
         string key = config.GetKey(0);
         if (!string.IsNullOrEmpty(key))
         {
             throw new ProviderException(System.Web.SR.GetString("Provider_unrecognized_attribute", new object[] { key }));
         }
     }
 }
Example #3
0
        public override void Initialize(string name, NameValueCollection config)
        {
            HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level);
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "SqlRoleProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", SR.GetString(SR.RoleSqlProvider_description));
            }
            base.Initialize(name, config);

            _SchemaVersionCheck = 0;

            _CommandTimeout = SecUtility.GetIntValue(config, "commandTimeout", 30, true, 0);

            _sqlConnectionString = SecUtility.GetConnectionString(config);

            _AppName = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
            {
                _AppName = SecUtility.GetDefaultAppName();
            }

            if (_AppName.Length > 256)
            {
                throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
            }

            config.Remove("connectionString");
            config.Remove("connectionStringName");
            config.Remove("applicationName");
            config.Remove("commandTimeout");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
                }
            }
        }
Example #4
0
 public override void Initialize(string name, NameValueCollection config)
 {
     HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level");
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     if ((name == null) || (name.Length < 1))
     {
         name = "SqlProfileProvider";
     }
     if (string.IsNullOrEmpty(config["description"]))
     {
         config.Remove("description");
         config.Add("description", System.Web.SR.GetString("ProfileSqlProvider_description"));
     }
     base.Initialize(name, config);
     this._SchemaVersionCheck  = 0;
     this._sqlConnectionString = SecUtility.GetConnectionString(config);
     this._AppName             = config["applicationName"];
     if (string.IsNullOrEmpty(this._AppName))
     {
         this._AppName = SecUtility.GetDefaultAppName();
     }
     if (this._AppName.Length > 0x100)
     {
         throw new ProviderException(System.Web.SR.GetString("Provider_application_name_too_long"));
     }
     this._CommandTimeout = SecUtility.GetIntValue(config, "commandTimeout", 30, true, 0);
     config.Remove("commandTimeout");
     config.Remove("connectionStringName");
     config.Remove("connectionString");
     config.Remove("applicationName");
     if (config.Count > 0)
     {
         string key = config.GetKey(0);
         if (!string.IsNullOrEmpty(key))
         {
             throw new ProviderException(System.Web.SR.GetString("Provider_unrecognized_attribute", new object[] { key }));
         }
     }
 }
Example #5
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (String.IsNullOrEmpty(name))
            {
                name = "WindowsTokenProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", SR.GetString(SR.RoleWindowsTokenProvider_description));
            }
            base.Initialize(name, config);

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            _AppName = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
            {
                _AppName = SecUtility.GetDefaultAppName();
            }

            if (_AppName.Length > 256)
            {
                throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
            }

            config.Remove("applicationName");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
                }
            }
        }
Example #6
0
        /// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call
        /// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider
        /// has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Intialize values from web.config
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "UmbracoMembershipProvider";
            }
            // Initialize base provider class
            base.Initialize(name, config);
            m_providerName = name;

            this.m_EnablePasswordRetrieval              = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false);
            this.m_EnablePasswordReset                  = SecUtility.GetBooleanValue(config, "enablePasswordReset", false);
            this.m_RequiresQuestionAndAnswer            = SecUtility.GetBooleanValue(config, "requiresQuestionAndAnswer", false);
            this.m_RequiresUniqueEmail                  = SecUtility.GetBooleanValue(config, "requiresUniqueEmail", true);
            this.m_MaxInvalidPasswordAttempts           = SecUtility.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
            this.m_PasswordAttemptWindow                = SecUtility.GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
            this.m_MinRequiredPasswordLength            = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, true, 0x80);
            this.m_MinRequiredNonAlphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80);
            this.m_PasswordStrengthRegularExpression    = config["passwordStrengthRegularExpression"];

            this.m_ApplicationName = config["applicationName"];
            if (string.IsNullOrEmpty(this.m_ApplicationName))
            {
                this.m_ApplicationName = SecUtility.GetDefaultAppName();
            }

            // make sure password format is clear by default.
            string str = config["passwordFormat"];

            if (str == null)
            {
                str = "Clear";
            }

            switch (str.ToLower())
            {
            case "clear":
                this.m_PasswordFormat = MembershipPasswordFormat.Clear;
                break;

            case "encrypted":
                this.m_PasswordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "hashed":
                this.m_PasswordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                throw new ProviderException("Provider bad password format");
            }

            if ((this.PasswordFormat == MembershipPasswordFormat.Hashed) && this.EnablePasswordRetrieval)
            {
                throw new ProviderException("Provider can not retrieve hashed password");
            }

            // test for membertype (if not specified, choose the first member type available)
            if (config["defaultMemberTypeAlias"] != null)
            {
                m_DefaultMemberTypeAlias = config["defaultMemberTypeAlias"];
            }
            else if (MemberType.GetAll.Length == 1)
            {
                m_DefaultMemberTypeAlias = MemberType.GetAll[0].Alias;
            }
            else
            {
                throw new ProviderException("No default MemberType alias is specified in the web.config string. Please add a 'defaultMemberTypeAlias' to the add element in the provider declaration in web.config");
            }

            // test for approve status
            if (config["umbracoApprovePropertyTypeAlias"] != null)
            {
                m_ApprovedPropertyTypeAlias = config["umbracoApprovePropertyTypeAlias"];
            }
            // test for lock attempts
            if (config["umbracoLockPropertyTypeAlias"] != null)
            {
                m_LockPropertyTypeAlias = config["umbracoLockPropertyTypeAlias"];
            }
            if (config["umbracoFailedPasswordAttemptsPropertyTypeAlias"] != null)
            {
                m_FailedPasswordAttemptsPropertyTypeAlias = config["umbracoFailedPasswordAttemptsPropertyTypeAlias"];
            }
            // comment property
            if (config["umbracoCommentPropertyTypeAlias"] != null)
            {
                m_CommentPropertyTypeAlias = config["umbracoCommentPropertyTypeAlias"];
            }
            // last login date
            if (config["umbracoLastLoginPropertyTypeAlias"] != null)
            {
                m_LastLoginPropertyTypeAlias = config["umbracoLastLoginPropertyTypeAlias"];
            }
            // password retrieval
            if (config["umbracoPasswordRetrievalQuestionPropertyTypeAlias"] != null)
            {
                m_PasswordRetrievalQuestionPropertyTypeAlias = config["umbracoPasswordRetrievalQuestionPropertyTypeAlias"];
            }
            if (config["umbracoPasswordRetrievalAnswerPropertyTypeAlias"] != null)
            {
                m_PasswordRetrievalAnswerPropertyTypeAlias = config["umbracoPasswordRetrievalAnswerPropertyTypeAlias"];
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level");
            if (string.IsNullOrEmpty(name))
            {
                name = "AuthorizationStoreRoleProvider";
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", System.Web.SR.GetString("RoleAuthStoreProvider_description"));
            }
            base.Initialize(name, config);
            this._CacheRefreshInterval = SecUtility.GetIntValue(config, "cacheRefreshInterval", 60, false, 0);
            this._ScopeName            = config["scopeName"];
            if ((this._ScopeName != null) && (this._ScopeName.Length == 0))
            {
                this._ScopeName = null;
            }
            this._ConnectionString = config["connectionStringName"];
            if ((this._ConnectionString == null) || (this._ConnectionString.Length < 1))
            {
                throw new ProviderException(System.Web.SR.GetString("Connection_name_not_specified"));
            }
            ConnectionStringSettings settings = RuntimeConfig.GetAppConfig().ConnectionStrings.ConnectionStrings[this._ConnectionString];

            if (settings == null)
            {
                throw new ProviderException(System.Web.SR.GetString("Connection_string_not_found", new object[] { this._ConnectionString }));
            }
            if (string.IsNullOrEmpty(settings.ConnectionString))
            {
                throw new ProviderException(System.Web.SR.GetString("Connection_string_not_found", new object[] { this._ConnectionString }));
            }
            this._ConnectionString = settings.ConnectionString;
            this._AppName          = config["applicationName"];
            if (string.IsNullOrEmpty(this._AppName))
            {
                this._AppName = SecUtility.GetDefaultAppName();
            }
            if (this._AppName.Length > 0x100)
            {
                throw new ProviderException(System.Web.SR.GetString("Provider_application_name_too_long"));
            }
            config.Remove("connectionStringName");
            config.Remove("cacheRefreshInterval");
            config.Remove("applicationName");
            config.Remove("scopeName");
            if (config.Count > 0)
            {
                string key = config.GetKey(0);
                if (!string.IsNullOrEmpty(key))
                {
                    throw new ProviderException(System.Web.SR.GetString("Provider_unrecognized_attribute", new object[] { key }));
                }
            }
        }
Example #8
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "MongoDbRoleProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "EazyRole Provider for MongoDb");
            }
            base.Initialize(name, config);


            bool.TryParse(config["useAppHarbor"], out _useAppHarbor);
            if (_useAppHarbor)
            {
                _connectionString =
                    ConfigurationManager.AppSettings.Get("MONGOHQ_URL") ??
                    ConfigurationManager.AppSettings.Get("MONGOLAB_URI");
            }

            if (string.IsNullOrEmpty(_connectionString))
            {
                string temp = config["connectionStringName"];
                if (string.IsNullOrEmpty(temp))
                {
                    throw new ProviderException(StringResources.GetString(StringResources.Connection_name_not_specified));
                }
                _connectionString = SecUtility.GetConnectionString(temp, true, true);

                if (string.IsNullOrEmpty(_connectionString))
                {
                    throw new ProviderException(StringResources.GetString(StringResources.Connection_string_not_found, temp));
                }
            }

            _AppName = config["applicationName"];

            if (string.IsNullOrEmpty(_AppName))
            {
                _AppName = SecUtility.GetDefaultAppName();
            }

            if (_AppName.Length > 256)
            {
                throw new ProviderException(StringResources.GetString(StringResources.Provider_application_name_too_long));
            }

            config.Remove("useAppHarbor");
            config.Remove("connectionStringName");
            config.Remove("applicationName");
            config.Remove("commandTimeout");

            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException(StringResources.GetString(StringResources.Provider_unrecognized_attribute, attribUnrecognized));
                }
            }
        }
Example #9
0
        ////////////////////////////////////////////////////////////
        // Public Methods

        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////

        public override void Initialize(string name, NameValueCollection config)
        {
            HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level);
            if (String.IsNullOrEmpty(name))
            {
                name = "AuthorizationStoreRoleProvider";
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", SR.GetString(SR.RoleAuthStoreProvider_description));
            }
            base.Initialize(name, config);

            _CacheRefreshInterval = SecUtility.GetIntValue(config, "cacheRefreshInterval", 60, false, 0);

            _ScopeName = config["scopeName"];
            if (_ScopeName != null && _ScopeName.Length == 0)
            {
                _ScopeName = null;
            }

            _ConnectionString = config["connectionStringName"];
            if (_ConnectionString == null || _ConnectionString.Length < 1)
            {
                throw new ProviderException(SR.GetString(SR.Connection_name_not_specified));
            }
            ConnectionStringsSection sec1 = null;

            sec1 = RuntimeConfig.GetAppConfig().ConnectionStrings;
            ConnectionStringSettings connObj = sec1.ConnectionStrings[_ConnectionString];

            if (connObj == null)
            {
                throw new ProviderException(SR.GetString(SR.Connection_string_not_found, _ConnectionString));
            }

            if (string.IsNullOrEmpty(connObj.ConnectionString))
            {
                throw new ProviderException(SR.GetString(SR.Connection_string_not_found, _ConnectionString));
            }

            _ConnectionString = connObj.ConnectionString;
            _AppName          = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
            {
                _AppName = SecUtility.GetDefaultAppName();
            }

            if (_AppName.Length > 256)
            {
                throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
            }

            config.Remove("connectionStringName");
            config.Remove("cacheRefreshInterval");
            config.Remove("applicationName");
            config.Remove("scopeName");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
                }
            }
        }