Ejemplo n.º 1
0
        public ServiceInformation(
            string serviceName,
            PasswordRestriction restriction)
        {
            Contract.Assert(!string.IsNullOrWhiteSpace(serviceName));
            Contract.Assert(restriction != null);

            Restriction = restriction;
            ServiceName = serviceName;
            UniqueToken = Guid.NewGuid().ToString();
        }
Ejemplo n.º 2
0
        public ServiceInformation(
            string serviceName,
            PasswordRestriction restriction)
        {
            Contract.Assert(!string.IsNullOrWhiteSpace(serviceName));
            Contract.Assert(restriction != null);

            Restriction = restriction;
            ServiceName = serviceName;
            UniqueToken = Guid.NewGuid().ToString();
        }
        private static long CalculatePasswordLength(
            PasswordRestriction restriction,
            int randomNumber)
        {
            var lowBounder   = Math.Max(restriction.PasswordMinLength, restriction.AcceptedTypes.Count());
            var upperBounder = restriction.PasswordMaxLength;

            if (lowBounder == upperBounder)
            {
                return(lowBounder);
            }

            var middleBounder = (upperBounder - lowBounder) / 2;

            return(upperBounder - randomNumber % (upperBounder - middleBounder));
        }
        private static long CalculatePasswordLength(
            PasswordRestriction restriction,
            int randomNumber)
        {
            var lowBounder = Math.Max(restriction.PasswordMinLength, restriction.AcceptedTypes.Count());
            var upperBounder = restriction.PasswordMaxLength;
            if (lowBounder == upperBounder)
            {
                return lowBounder;
            }

            var middleBounder = (upperBounder - lowBounder) / 2;

            return upperBounder - randomNumber % (upperBounder - middleBounder);
        }