Beispiel #1
0
 public bool Initialize(UserPasswordConfig config)
 {
     lock (this)
     {
         if (config != null && !this.initialized)
         {
             if (config.HistoryProvider != null)
             {
                 this.HistoryProvider = this.HistoryProvider = NameReflectionUtils.CreateInstance <UserPasswordHistoryProviderFactory>(config.HistoryProvider);
                 if (this.HistoryProvider != null)
                 {
                     if (this.HistoryProvider.Initialize())
                     {
                         this.MaxHistory = config.MaxHistory;
                         if (config.MinChar < config.MaxChar)
                         {
                             try
                             {
                                 this.Shaker = new SaltShaker((char)config.MinChar, (char)config.MaxChar, config.HashLength, SaltCreationModel.Repeatable, SaltEmbeddingModel.Randomized, -1);
                                 foreach (PasswordComplexityRule curRule in config.Rules)
                                 {
                                     if (curRule != null)
                                     {
                                         this.ComplexityChecker.Rules.Add(curRule);
                                     }
                                 }
                                 this.initialized = true;
                                 return(true);
                             }
                             catch
                             { }
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
Beispiel #2
0
 protected override bool Initialize()
 {
     lock (this)
     {
         if (!initialized)
         {
             ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
             if (config != null)
             {
                 Type myType = typeof(UserPasswordProviderFactory);
                 ConfigurationParameter parm = config.Get(myType, "historyProvider");
                 if (parm != null)
                 {
                     TypeNameReference fact = TypeNameReference.Parse((string)parm.Value);
                     if (fact != null)
                     {
                         UserPasswordConfig myConfig = new UserPasswordConfig();
                         myConfig.HistoryProvider = fact;
                         parm = config.Get(myType, "maxHistory");
                         if (parm != null)
                         {
                             try
                             {
                                 myConfig.MaxHistory = (ushort)(int)parm.Value;
                                 parm = config.Get(myType, "hashLength");
                                 if (parm != null)
                                 {
                                     try
                                     {
                                         myConfig.HashLength = (int)parm.Value;
                                         if (myConfig.HashLength > 0)
                                         {
                                             parm = config.Get(myType, "hashMinChar");
                                             if (parm != null)
                                             {
                                                 try
                                                 {
                                                     myConfig.MinChar = (char)(int)parm.Value;
                                                     if (myConfig.MinChar > 0)
                                                     {
                                                         parm = config.Get(myType, "hashMaxChar");
                                                         if (parm != null)
                                                         {
                                                             try
                                                             {
                                                                 myConfig.MaxChar = (char)(int)parm.Value;
                                                                 if (myConfig.MaxChar > 0)
                                                                 {
                                                                     //TODO -- add complexity rule config params
                                                                     return(this.Initialize(myConfig));
                                                                 }
                                                             }
                                                             catch
                                                             { }
                                                         }
                                                     }
                                                 }
                                                 catch
                                                 { }
                                             }
                                         }
                                     }
                                     catch
                                     { }
                                 }
                             }
                             catch
                             { }
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }