示例#1
0
		/// <summary>
		/// Checks that a candidate password meets the enterprise-wide password policy.
		/// </summary>
		/// <param name="passwordCandidate"></param>
		/// <param name="settings"></param>
		public static void CheckPasswordCandidate(string passwordCandidate, AuthenticationSettings settings)
		{
			// password cannot be empty
			if (string.IsNullOrEmpty(passwordCandidate))
				throw new RequestValidationException(settings.ValidPasswordMessage);

			// if no regex specified, then any non-empty password is valid
			if (string.IsNullOrEmpty(settings.ValidPasswordRegex))
				return;

			// otherwise match the regex
			if (!Regex.Match(passwordCandidate, settings.ValidPasswordRegex).Success)
				throw new RequestValidationException(settings.ValidPasswordMessage);
		}
示例#2
0
        /// <summary>
        /// Checks that a candidate password meets the enterprise-wide password policy.
        /// </summary>
        /// <param name="passwordCandidate"></param>
        /// <param name="settings"></param>
        public static void CheckPasswordCandidate(string passwordCandidate, AuthenticationSettings settings)
        {
            // password cannot be empty
            if (string.IsNullOrEmpty(passwordCandidate))
            {
                throw new RequestValidationException(settings.ValidPasswordMessage);
            }

            // if no regex specified, then any non-empty password is valid
            if (string.IsNullOrEmpty(settings.ValidPasswordRegex))
            {
                return;
            }

            // otherwise match the regex
            if (!Regex.Match(passwordCandidate, settings.ValidPasswordRegex).Success)
            {
                throw new RequestValidationException(settings.ValidPasswordMessage);
            }
        }
示例#3
0
		/// <summary>
		/// Checks that a candidate password meets the enterprise-wide password policy.
		/// </summary>
		/// <param name="accountType"></param>
		/// <param name="passwordCandidate"></param>
		/// <param name="settings"></param>
		public static void CheckPasswordCandidate(UserAccountType accountType, string passwordCandidate, AuthenticationSettings settings)
		{
			if (accountType == UserAccountType.S)
			{
				if (string.IsNullOrEmpty(passwordCandidate) || passwordCandidate.Length < 8)
					throw new RequestValidationException(SR.SystemAccountValidPasswordMessage);

				return;
			}

			// password cannot be empty
			if (string.IsNullOrEmpty(passwordCandidate))
				throw new RequestValidationException(settings.ValidPasswordMessage);

			// if no regex specified, then any non-empty password is valid
			if (string.IsNullOrEmpty(settings.ValidPasswordRegex))
				return;

			// otherwise match the regex
			if (!Regex.Match(passwordCandidate, settings.ValidPasswordRegex).Success)
				throw new RequestValidationException(settings.ValidPasswordMessage);
		}
示例#4
0
        /// <summary>
        /// Checks that a candidate password meets the enterprise-wide password policy.
        /// </summary>
        /// <param name="accountType"></param>
        /// <param name="passwordCandidate"></param>
        /// <param name="settings"></param>
        public static void CheckPasswordCandidate(UserAccountType accountType, string passwordCandidate, AuthenticationSettings settings)
        {
            if (accountType == UserAccountType.S)
            {
                if (string.IsNullOrEmpty(passwordCandidate) || passwordCandidate.Length < 8)
                {
                    throw new RequestValidationException(SR.SystemAccountValidPasswordMessage);
                }

                return;
            }

            // password cannot be empty
            if (string.IsNullOrEmpty(passwordCandidate))
            {
                throw new RequestValidationException(settings.ValidPasswordMessage);
            }

            // if no regex specified, then any non-empty password is valid
            if (string.IsNullOrEmpty(settings.ValidPasswordRegex))
            {
                return;
            }

            // otherwise match the regex
            if (!Regex.Match(passwordCandidate, settings.ValidPasswordRegex).Success)
            {
                throw new RequestValidationException(settings.ValidPasswordMessage);
            }
        }