Beispiel #1
0
        public static ValidationHandlerNode GetValidationHandlerChain(IPasswordValidationSettings settings)
        {
            var locator = new ValidationServiceLocator(settings);
            var result  = locator.GetValidationHandlerChain();

            return(result);
        }
Beispiel #2
0
        public void InterfaceStandardWordLists_Constructed_AnEmptyCollection()
        {
            PasswordValidationSettings  settings  = new PasswordValidationSettings();
            IPasswordValidationSettings iSettings = settings;

            Assert.AreEqual(0, iSettings.StandardWordLists.Count);
        }
 private ValidationHandler CreateCustomHandler(IPasswordValidationSettings settings)
 {
   object customData = GetCustomData(settings);
   var result = (ValidationHandler) Activator.CreateInstance(HandlerType);
   result.SetData(customData);
   return result;
 }
    /// <summary>
    /// Add the specified settings to the cache with the given key.
    /// </summary>
    /// <param name="key">The key with which to reference the settings</param>
    /// <param name="settings">The rules that govern how the password is to be validated.</param>
    /// <exception cref="ArgumentNullException">If key is null</exception>
    /// <exception cref="ArgumentNullException">If settings is null</exception>
    public static void Add(string key, IPasswordValidationSettings settings)
    {
      if (key == null) throw new ArgumentNullException("key");
      if (settings == null) throw new ArgumentNullException("settings");

      _cache[key] = settings;
    }
 /// <summary>
 /// Constructs an instance of the `Validator` class using the settings passed
 /// into the constructor.
 /// </summary>
 /// <param name="settings">The settings that define the rules by which
 /// to validate a password.</param>
 public Validator(IPasswordValidationSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     _validationChain = ValidationServiceLocator.GetValidationHandlerChain(settings);
 }
Beispiel #6
0
        private ValidationHandler CreateCustomHandler(IPasswordValidationSettings settings)
        {
            object customData = GetCustomData(settings);
            var    result     = (ValidationHandler)Activator.CreateInstance(HandlerType);

            result.SetData(customData);
            return(result);
        }
 private object GetCustomData(IPasswordValidationSettings settings)
 {
   var allCustomData = settings.CustomData;
   object result;
   if (allCustomData.TryGetValue(HandlerType, out result))
     return result;
   return null;
 }
 public ValidationHandler ConstructHandler(IPasswordValidationSettings settings)
 {
   if (NeedsSettings)
     return CreateSettingsBasedHandler(settings);
   if (IsCustomHandler)
     return CreateCustomHandler(settings);
   return CreateBasicHandler();
 }
Beispiel #9
0
        public void InterfaceCustomLists_RoundtripValue()
        {
            var section = new PasswordValidationSection();
            IPasswordValidationSettings iSection = section;
            var collection = new CustomWordListCollection();

            Assert.AreNotSame(collection, iSection.CustomWordLists);
            section.CustomWordLists = collection;
            Assert.AreSame(collection, iSection.CustomWordLists);
        }
Beispiel #10
0
        private object GetCustomData(IPasswordValidationSettings settings)
        {
            var    allCustomData = settings.CustomData;
            object result;

            if (allCustomData.TryGetValue(HandlerType, out result))
            {
                return(result);
            }
            return(null);
        }
Beispiel #11
0
 public ValidationHandler ConstructHandler(IPasswordValidationSettings settings)
 {
     if (NeedsSettings)
     {
         return(CreateSettingsBasedHandler(settings));
     }
     if (IsCustomHandler)
     {
         return(CreateCustomHandler(settings));
     }
     return(CreateBasicHandler());
 }
Beispiel #12
0
        /// <summary>
        /// Add the specified settings to the cache with the given key.
        /// </summary>
        /// <param name="key">The key with which to reference the settings</param>
        /// <param name="settings">The rules that govern how the password is to be validated.</param>
        /// <exception cref="ArgumentNullException">If key is null</exception>
        /// <exception cref="ArgumentNullException">If settings is null</exception>
        public static void Add(string key, IPasswordValidationSettings settings)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _cache[key] = settings;
        }
 public PasswordValidator(IPasswordValidationSettings settings)
 {
     Settings = settings;
 }
 public MinimumLengthValidationHandler(IPasswordValidationSettings settings)
     : base(settings)
 {
 }
 public ConcreteSettingsBasedValdiationHandler(IPasswordValidationSettings settings)
     : base(settings)
 {
 }
Beispiel #16
0
 private ValidationHandler CreateSettingsBasedHandler(IPasswordValidationSettings settings)
 {
     return((ValidationHandler)Activator.CreateInstance(HandlerType, settings));
 }
 public StandardWordListValidationHandler(IPasswordValidationSettings settings) 
   : base(settings)
 {
 }
 public MinimumLengthValidationHandler(IPasswordValidationSettings settings) 
   : base(settings)
 {
 }
 /// <summary>
 /// Constructs an instance of the `Validator` class using the settings passed 
 /// into the constructor.
 /// </summary>
 /// <param name="settings">The settings that define the rules by which
 /// to validate a password.</param>
 public Validator(IPasswordValidationSettings settings)
 {
   if (settings == null) throw new ArgumentNullException("settings");
   _validationChain = ValidationServiceLocator.GetValidationHandlerChain(settings);
 }
 public CustomWordListValidationHandler(IPasswordValidationSettings settings) 
   : base(settings)
 {
 }
Beispiel #21
0
 public CustomWordListValidationHandler(IPasswordValidationSettings settings)
     : base(settings)
 {
 }
Beispiel #22
0
 public ValidationServiceLocator(IPasswordValidationSettings settings)
 {
     _settings = settings;
 }
 internal SettingsBasedValidationHandler(IPasswordValidationSettings settings)
 {
   Settings = settings;
 }
 public static ValidationHandlerNode GetValidationHandlerChain(IPasswordValidationSettings settings)
 {
   var locator = new ValidationServiceLocator(settings);
   var result = locator.GetValidationHandlerChain();
   return result;
 }
 public ValidationServiceLocator(IPasswordValidationSettings settings)
 {
   _settings = settings;
 }
 private ValidationHandler CreateSettingsBasedHandler(IPasswordValidationSettings settings)
 {
   return (ValidationHandler)Activator.CreateInstance(HandlerType, settings);
 }
 internal SettingsBasedValidationHandler(IPasswordValidationSettings settings)
 {
     Settings = settings;
 }
 protected WordListValidationHandler(IPasswordValidationSettings settings)
     : base(settings)
 {
 }
 public ConcreteSettingsBasedValdiationHandler(IPasswordValidationSettings settings) 
   : base(settings)
 {
 }
Beispiel #30
0
 public StandardWordListValidationHandler(IPasswordValidationSettings settings)
     : base(settings)
 {
 }
    protected WordListValidationHandler(IPasswordValidationSettings settings) 
      : base(settings)
    {

    }