Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IList <PasswordSafe> Get()
        {
            IList <PasswordSafe> records = null;

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = new SqlCommand(Query.GET_PASSWORD_SAFE_RECORDS, sqlConnection))
                    {
                        SqlDataReader reader = sqlCommand.ExecuteReader();

                        if (reader != null)
                        {
                            records = new List <PasswordSafe>();
                            while (reader.Read())
                            {
                                PasswordSafe record = new PasswordSafe();
                                record.PasswordSafeId    = GetInt(reader["PasswordSafeId"]);
                                record.ServiceName       = GetString(reader["ServiceName"]);
                                record.Username          = GetString(reader["Username"]);
                                record.Password          = GetString(reader["Password"]);
                                record.ServiceType       = GetString(reader["ServiceType"]);
                                record.SecurityQuestion1 = GetString(reader["SQ1"]);
                                record.SecurityAnswer1   = GetString(reader["SA1"]);
                                record.SecurityQuestion2 = GetString(reader["SQ2"]);
                                record.SecurityAnswer2   = GetString(reader["SA2"]);
                                record.SecurityQuestion3 = GetString(reader["SQ3"]);
                                record.SecurityAnswer3   = GetString(reader["SA3"]);

                                records.Add(record);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(records);
        }
        private void passwordTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (passwordTextBox.Text == "")
            {
                passwordCorrectCheckLabel.Content = "";
            }
            PasswordSafe safe = new PasswordSafe(passwordTextBox.Text);

            if (PasswordFormatCheck(passwordTextBox.Text))
            {
                switch (safe.CheckAll())
                {
                case PasswordSafe.SafePower.Bad:
                    passwordCorrectCheckLabel.Foreground = new SolidColorBrush(Colors.Red);
                    passwordCorrectCheckLabel.Content    = "Не безопасный пароль";
                    break;

                case PasswordSafe.SafePower.Normal:
                    passwordCorrectCheckLabel.Foreground = new SolidColorBrush(Colors.Orange);
                    passwordCorrectCheckLabel.Content    = "Умеренный пароль";
                    break;

                case PasswordSafe.SafePower.Good:
                    passwordCorrectCheckLabel.Foreground = new SolidColorBrush(Colors.YellowGreen);
                    passwordCorrectCheckLabel.Content    = "Безопасный пароль";
                    break;

                case PasswordSafe.SafePower.Excelent:
                    passwordCorrectCheckLabel.Foreground = new SolidColorBrush(Colors.Green);
                    passwordCorrectCheckLabel.Content    = "Очень безопасный пароль";
                    break;
                }
            }
            else
            {
                passwordCorrectCheckLabel.Foreground = new SolidColorBrush(Colors.Red);
                passwordCorrectCheckLabel.Content    = "Пароль не может быть меньше 4 или больше 100 символов";
            }
        }