public Form_WeakPasswordDetection(bool allowEdit, WeakPasswordSetting passwordSettings) { InitializeComponent(); _bf_MainPanel.Enabled = allowEdit; this.passwordSettings = passwordSettings; enableCheck.Checked = passwordSettings.PasswordCheckingEnabled; additionalListTextbox.Text = WeakPasswordSetting.ConvertListToString(passwordSettings.AdditionalPasswordList); if (passwordSettings.AdditionalListUpdated == DateTime.MinValue) { additionalUpdatedLabel.Text = "Last Updated: Never"; } else { additionalUpdatedLabel.Text = String.Format("{0}", passwordSettings.AdditionalListUpdated.ToLocalTime().ToString()); } if (passwordSettings.CustomListUpdated == DateTime.MinValue) { customUpdatedLabel.Text = "Last Updated: Never"; } else { customUpdatedLabel.Text = String.Format("Last Updated: {0}", passwordSettings.CustomListUpdated.ToLocalTime().ToString()); } }
private void okButton_Click(object sender, EventArgs e) { //only update the list if it has changed. if (!String.Equals(additionalListTextbox.Text, WeakPasswordSetting.ConvertListToString(passwordSettings.AdditionalPasswordList))) { passwordSettings.AdditionalPasswordList.Clear(); passwordSettings.AdditionalPasswordList.AddRange(additionalListTextbox.Text.Split(new char[] { ';' })); passwordSettings.AdditionalListUpdated = DateTime.Now.ToUniversalTime(); } string filename = customListTextbox.Text; if (!String.IsNullOrEmpty(filename)) { try { DialogResult result = DialogResult.Yes; if (passwordSettings.CustomPasswordList.Count > 0) { result = Utility.MsgBox.ShowConfirm("Override Custom Password List", String.Format("Uploading a new custom password list will override {0} existing custom passwords. Do you wish to continue?", passwordSettings.CustomPasswordList.Count)); } if (result == DialogResult.Yes) { StreamReader fileStream; //copy the file to the same directory as the console and collector using (fileStream = File.OpenText(filename)) { //empty out the old custom list passwordSettings.CustomPasswordList.Clear(); string password; while ((password = fileStream.ReadLine()) != null) { passwordSettings.CustomPasswordList.Add(password); } } Utility.MsgBox.ShowInfo("Upload Successful", "Uploading of the custom password list was successful."); passwordSettings.CustomListUpdated = DateTime.Now.ToUniversalTime(); } else { this.DialogResult = DialogResult.None; return; } } catch (Exception exception) { Utility.MsgBox.ShowError("Unable to load", "Unable to load the custom password list.", exception); logX.loggerX.Error(String.Format("Unable to load the custom password list. Error:{0}", exception.ToString())); this.DialogResult = DialogResult.None; return; } } this.DialogResult = DialogResult.OK; this.Close(); }
static public void Process(bool allowEdit) { List <WeakPasswordSetting> passwordSettings = WeakPasswordSetting.GetWeakPasswordSettings(Program.gController.Repository.ConnectionString); //right now there will only be one custom password list but that might change if we allow for each server to have a custom list. Form_WeakPasswordDetection dlg = new Form_WeakPasswordDetection(allowEdit, passwordSettings[0]); if (dlg.ShowDialog() == DialogResult.OK) { WeakPasswordSetting.UpdateWeakPasswordSettings(dlg.PasswordSettings, Program.gController.Repository.ConnectionString); } }