Esempio n. 1
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            Password newPassword = new Password()
            {
                UserID   = user.ID,
                Name     = txtName.Text,
                Email    = txtEmail.Text.Equals("") ? "*****@*****.**" : txtEmail.Text,
                Username = txtUsername.Text,
                Website  = txtWebsite.Text,
                Text     = txtPassword.Text,
                Notes    = rtxtNotes.Text,

                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };

            try
            {
                await PasswordsService.Instance().SaveNewUserPasswordAsync(user, newPassword);
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
            }
        }
        private async void btnImportPasswords_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog
            {
                Title            = "Import Passwords",
                DefaultExt       = "kvf",
                Filter           = "KeysVault files (*.kvf)|*.kvf|All files (*.*)|*.*",
                FilterIndex      = 1,
                CheckPathExists  = true,
                RestoreDirectory = true
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                List <Password> importedPasswords = await KeyVaultService.Instance().ImportPasswordsAsync(ofd.FileName);

                if (importedPasswords != null)
                {
                    if (Messenger.Confirm("The file contains " + importedPasswords.Count + " passwords. Are you sure you want to import these passwords to your account?"))
                    {
                        try
                        {
                            await PasswordsService.Instance().SaveNewPasswordsAsync(localSettings, CryptoService.Instance().DecryptPasswords(localSettings.Master, importedPasswords));
                        }
                        catch
                        {
                            Messenger.Show("Unable to import passwords. Either these passwords were encrypted with a different Master Password than yours or you changed your Master Password.", "Error");
                        }
                        localPasswords = await PasswordsService.Instance().GetAllPasswordsAsync(localSettings);

                        ShowPasswords(localPasswords);
                    }
                }
            }
        }
Esempio n. 3
0
        private async void btnImportPasswords_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title            = "Import Passwords";
            ofd.DefaultExt       = "bpf";
            ofd.Filter           = Globals.Information.AppName + " files (*.bpf)|*.bpf|All files (*.*)|*.*";
            ofd.FilterIndex      = 1;
            ofd.CheckPathExists  = true;
            ofd.RestoreDirectory = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                List <Password> importedPasswords = await BearPassService.Instance().ImportPasswordsAsync(ofd.FileName);

                if (importedPasswords != null)
                {
                    if (Messenger.Confirm("The file contains " + importedPasswords.Count + " passwords. Are you sure you want to import these passwords to your account?"))
                    {
                        try
                        {
                            await PasswordsService.Instance().SaveNewUserPasswordsAsync(user, CryptoService.Instance().DecryptUserPasswords(user, importedPasswords));
                        }
                        catch
                        {
                            Messenger.Show("Unable to import passwords. Either these passwords were encrypted with a different Master Password than yours or you changed your Master Password.", "Error");
                        }
                        ShowPasswords(await PasswordsService.Instance().GetAllUserPasswordsAsync(user));
                    }
                }
            }
        }
Esempio n. 4
0
 public bool IsEnable()
 {
     if (PasswordsService.Instance().IsSame(txtNewMaster.Text, txtConfirmMaster.Text) && Verifier.Text(txtNewMaster.Text) && Verifier.Text(txtConfirmMaster.Text))
     {
         //now check if existing master match too
         if (Verifier.Text(txtMaster.Text) && PasswordsService.Instance().IsSame(settings.Master, txtMaster.Text))
         {
             lblMassege.Text      = "You can try to save now.";
             lblMassege.ForeColor = Color.FromArgb(67, 140, 235);
             return(true);
         }
         else
         {
             lblMassege.Text      = "Your Master Password is incorrect.";
             lblMassege.ForeColor = Color.FromArgb(244, 67, 54);
             return(false);
         }
     }
     else
     {
         lblMassege.Text      = "Your New Master Password and Confirm Master Password doesn't match.";
         lblMassege.ForeColor = Color.FromArgb(244, 67, 54);
         return(false);
     }
 }
Esempio n. 5
0
        private void PasswordsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColShow")
                {
                    int ID = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());

                    if (!show)
                    {
                        PasswordsGridView.Rows[e.RowIndex].Cells["ColPassword"].Value = PasswordsService.Instance().GetPasswordByID(ID);

                        PasswordsGridView.Rows[e.RowIndex].Cells["ColShow"].Value = Properties.Resources.Hide;
                        show = true;
                    }
                    else
                    {
                        PasswordsGridView.Rows[e.RowIndex].Cells["ColPassword"].Value = "•••••••••••";
                        PasswordsGridView.Rows[e.RowIndex].Cells["ColShow"].Value     = Properties.Resources.Show;
                        show = false;
                    }
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColCopy")
                {
                    int ID = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());
                    Clipboard.Clear();
                    string hash = Database.GetPassHash(ID);
                    Clipboard.SetText(hash);
                    PasswordsGridView.Rows[e.RowIndex].Cells["ColCopy"].Value = Properties.Resources.Check;

                    wait(3000);

                    PasswordsGridView.Rows[e.RowIndex].Cells["ColCopy"].Value = Properties.Resources.page_copy;
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColUpdate")
                {
                    int ID = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());
                    MessageBox.Show(ID.ToString());
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColDelete")
                {
                    int          ID     = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());
                    DialogResult dialog = CustomMessageBox.Show("Confirmation", "Are you sure you want to delete this password? \nYou can't be never restore this?", CustomMessageBox.eDialogButtons.YesNo, CustomMessageBox.eDialogImages.Question);

                    if (dialog == DialogResult.Yes)
                    {
                        switch (PasswordsService.Instance().DeletePassword(ID))
                        {
                        case 0:
                            CustomMessageBox.Show("An Error Occurred", "An error occured while deleting this password!", CustomMessageBox.eDialogButtons.OK, CustomMessageBox.eDialogImages.Error);
                            break;

                        case 1:
                            CustomMessageBox.Show("Successfull Deleted", "Password successful deleted!", CustomMessageBox.eDialogButtons.OK, CustomMessageBox.eDialogImages.Success);
                            break;
                        }
                    }
                }
            }
        }
        private async void PasswordsGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColCopy")
                {
                    Clipboard.Clear();
                    Clipboard.SetText(PasswordsGridView.Rows[e.RowIndex].Cells["ColPassword"].Value.ToString());
                    System.Media.SystemSounds.Exclamation.Play();
                    DisplayMassege(PasswordsGridView.Rows[e.RowIndex].Cells["ColName"].Value.ToString() + " Password Copied.");
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColUsername")
                {
                    Clipboard.Clear();
                    Clipboard.SetText(PasswordsGridView.Rows[e.RowIndex].Cells["ColUsername"].Value.ToString());
                    System.Media.SystemSounds.Exclamation.Play();
                    DisplayMassege(PasswordsGridView.Rows[e.RowIndex].Cells["ColUsername"].Value.ToString() + " Username Copied.");
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColUpdate")
                {
                    int ID = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());

                    UpdatePassword updatePasswordForm = new UpdatePassword(user, user.Passwords.Where(i => i.ID == ID).FirstOrDefault());

                    if (updatePasswordForm.ShowDialog() == DialogResult.OK)
                    {
                        user.Passwords = await PasswordsService.Instance().GetAllUserPasswordsAsync(user);

                        DisplayMassege("Password Updated.", Globals.Defaults.WarningColor);
                        ShowPasswords(user.Passwords);
                    }
                }
                else if (PasswordsGridView.Columns[e.ColumnIndex].Name == "ColDelete")
                {
                    if (Messenger.Confirm("Are you sure you want to delete this Password?\n\nTHIS TASK WILL NOT BE REVERTED."))
                    {
                        int ID = Convert.ToInt32(PasswordsGridView.Rows[e.RowIndex].Cells["ColID"].Value.ToString());

                        //this is necessary to get all passwords before deleting.
                        user.Passwords = await PasswordsService.Instance().GetAllUserPasswordsAsync(user);

                        Password passwordToDelete = user.Passwords.Where(p => p.ID == ID).FirstOrDefault();

                        if (await PasswordsService.Instance().RemoveUserPasswordAsync(user, passwordToDelete))
                        {
                            PasswordsGridView.Rows.RemoveAt(e.RowIndex);
                            DisplayMassege("Password Deleted.", Globals.Defaults.WarningColor);
                            System.Media.SystemSounds.Hand.Play();
                        }
                        else
                        {
                            DisplayMassege("Password NOT Deleted.", Globals.Defaults.ErrorColor);
                            System.Media.SystemSounds.Exclamation.Play();
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        private async void btnOptions_Click(object sender, EventArgs e)
        {
            PasswordGenerateOptions passwordGenerateOptionsForm = new PasswordGenerateOptions(user);

            if (passwordGenerateOptionsForm.ShowDialog() == DialogResult.OK)
            {
                user.Settings.PasswordOptions = passwordGenerateOptionsForm.passwordOptions;
                txtPassword.Text = await PasswordsService.Instance().GeneratePasswordAsync(user);
            }
        }
Esempio n. 8
0
 private async void btnGenerate_Click(object sender, EventArgs e)
 {
     try
     {
         txtPassword.Text = await PasswordsService.Instance().GeneratePasswordAsync(user);
     }
     catch (Exception ex)
     {
         Messenger.Show(ex.Message + " " + ex.HResult, "Error");
     }
 }
Esempio n. 9
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (!Verifier.Text(txtname.Text) || !Verifier.Text(txtUsername.Text) || !Verifier.Text(txtEmail.Text) || !Verifier.Text(txtPass.Text))
            {
                CustomMessageBox.Show("*Mandatory Fields Missing", "Mandatory fields are required!", CustomMessageBox.eDialogButtons.OK, CustomMessageBox.eDialogImages.Exclamation);
            }
            else
            {
                Passwords passwords = new Passwords();

                passwords.Name     = txtname.Text;
                passwords.Username = txtUsername.Text;
                passwords.Email    = txtEmail.Text;
                passwords.Text     = txtPass.Text;

                if (txtWebsite.Text == "")
                {
                    passwords.Website = "null";
                }
                else
                {
                    passwords.Website = txtWebsite.Text;
                }

                if (txtNotes.Text == "")
                {
                    passwords.Notes = "null";
                }
                else
                {
                    passwords.Notes = txtNotes.Text;
                }

                btnReset.Enabled          = false;
                btnSave.Enabled           = false;
                pictureBoxSpinner.Visible = true;

                Passwords check = await PasswordsService.Instance().SaveNewUserPasswordsAsync(passwords);

                if (check != null)
                {
                    CustomMessageBox.Show("*Successfully Saved", "Good! Your new password is succesfully saved and encrypted", CustomMessageBox.eDialogButtons.OK, CustomMessageBox.eDialogImages.Success);
                }
                else
                {
                    CustomMessageBox.Show("*An Error Occured", "Sorry! An error occurred while saving this password", CustomMessageBox.eDialogButtons.OK, CustomMessageBox.eDialogImages.Error);
                }
                btnReset.Enabled          = true;
                btnSave.Enabled           = true;
                pictureBoxSpinner.Visible = false;
                btnReset_Click(sender, e);
            }
        }
        private void buttonReminder_Click(object sender, EventArgs e)
        {
            Entities.Reminder newReminder = new Entities.Reminder();
            newReminder.ReminderText     = reminderLabelText.Text;
            newReminder.ShowReminderDate = Convert.ToDateTime(dateTimePickerReminder.Text);
            newReminder.ReminderPassword = this.password;
            object obj = PasswordsService.Instance().AddNewPasswordReminderAsync(newReminder);

            if (obj != null)
            {
                Messenger.Show($"You will be reminbered to '{newReminder.ReminderText}' on '{newReminder.ShowReminderDate}'", "Success");
            }
        }
Esempio n. 11
0
        private async void btnMasterPassword_Click(object sender, EventArgs e)
        {
            MasterPasswordForm masterPasswordForm = new MasterPasswordForm(localSettings);

            masterPasswordForm.ShowDialog();

            try
            {
                ShowPasswords(await PasswordsService.Instance().GetAllPasswordsAsync(localSettings));
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
            }
        }
Esempio n. 12
0
        private async void ShowPasswords()
        {
            pictureBoxLoading.Visible = true;
            PasswordsGridView.Rows.Clear();
            List <Passwords> passwords = await PasswordsService.Instance().RetrieveUserPasswordsAsync();

            foreach (Passwords password in passwords)
            {
                PasswordsGridView.Rows.Add(password.ID, password.Name, password.Email, password.Username);
            }

            for (int i = 0; i <= passwords.Count - 1; i++)
            {
                PasswordsGridView.Rows[i].Cells["ColPassword"].Value = "•••••••••••";
            }
            pictureBoxLoading.Visible = false;
        }
Esempio n. 13
0
        private async void btnOptions_Click(object sender, EventArgs e)
        {
            try
            {
                PasswordGenerateOptions passwordGenerateOptionsForm = new PasswordGenerateOptions(user);

                if (passwordGenerateOptionsForm.ShowDialog() == DialogResult.OK)
                {
                    user.Settings.PasswordOptions = passwordGenerateOptionsForm.passwordOptions;
                    txtPassword.Text = await PasswordsService.Instance().GeneratePasswordAsync(user);
                }
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
            }
        }
Esempio n. 14
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            password.Name         = txtName.Text;
            password.Email        = txtEmail.Text;
            password.Username     = txtUsername.Text;
            password.Website      = txtWebsite.Text;
            password.Text         = txtPassword.Text;
            password.Notes        = rtxtNotes.Text;
            password.DateModified = DateTime.Now;

            try
            {
                await PasswordsService.Instance().UpdateUserPasswordAsync(user, password);
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //check if the newly supplied passwords are same or not
                if (!PasswordsService.Instance().IsSame(txtNewMaster.Text, txtConfirmMaster.Text) && !Verifier.Text(txtNewMaster.Text) && !Verifier.Text(txtConfirmMaster.Text))
                {
                    lblMassege.Text      = "Your New Master Password and Confirm Master Password doesn't match.";
                    lblMassege.ForeColor = Color.FromArgb(244, 67, 54);
                }
                else //both new passwords are same. Dont match them again
                {
                    //match the current Master Password with the entered Master Password
                    if (Verifier.Text(txtMaster.Text) && PasswordsService.Instance().IsSame(user.Master, txtMaster.Text))
                    {
                        if (MessageBox.Show("Are you sure you want to change your Master Password?\n\nPlease write down your Master Password for safe keeping, if you forgot your Master Password, you will not be able to recover your Passwords.\n\nFor more guidelines goto Dashboard > Guidelines.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                        {
                            picboxLoading.Show();
                            btnSave.Enabled = false;

                            //do some refactoring here like null etc exc -gul:1401171353
                            user = await PasswordsService.Instance().ChangeMasterEncryption(user, txtNewMaster.Text);

                            picboxLoading.Hide();
                            btnSave.Enabled      = true;
                            lblMassege.Text      = "Master Password Changed.";
                            lblMassege.ForeColor = Color.FromArgb(67, 140, 235);
                        }
                    }
                    else //user entered a wrong master password
                    {
                        lblMassege.Text      = "Your Master Password is incorrect.";
                        lblMassege.ForeColor = Color.FromArgb(244, 67, 54);
                    }
                }
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
                picboxLoading.Hide();
                btnSave.Enabled = true;
            }
        }
Esempio n. 16
0
        private async void btnSearchPassword_Click(object sender, EventArgs e)
        {
            Search searchForm = new Search();

            if (searchForm.ShowDialog() == DialogResult.OK)
            {
                string SearchTerm = searchForm.txtSearchPassword.Text;

                string LooksFor = string.Empty;

                if (searchForm.rdbLookEmail.Checked)
                {
                    LooksFor = "Email";
                }
                else if (searchForm.rdbLookUsername.Checked)
                {
                    LooksFor = "Username";
                }
                else
                {
                    LooksFor = "Name";
                }

                string Options = string.Empty;
                if (searchForm.rdbOptionContains.Checked)
                {
                    Options = "Contains";
                }
                else
                {
                    Options = "Equals";
                }

                try
                {
                    ShowPasswords(await PasswordsService.Instance().SearchPasswordsAsync(localSettings, SearchTerm, LooksFor, Options));
                }
                catch (Exception ex)
                {
                    Messenger.Show(ex.Message + " " + ex.HResult, "Error");
                }
            }
        }
Esempio n. 17
0
        private async void btnNewPassword_Click(object sender, EventArgs e)
        {
            NewPassword newPasswordForm = new NewPassword(localSettings);

            if (newPasswordForm.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    localPasswords = await PasswordsService.Instance().GetAllPasswordsAsync(localSettings);

                    ShowPasswords(localPasswords);
                    PasswordsGridView.Focus();
                    PasswordsGridView.CurrentCell = PasswordsGridView.Rows[PasswordsGridView.Rows.Count - 1].Cells[2];
                }
                catch (Exception ex)
                {
                    Messenger.Show(ex.Message + " " + ex.HResult, "Error");
                }
            }
        }
        private void UpdatePassword_Load(object sender, EventArgs e)
        {
            txtName.Text     = password.Name;
            txtEmail.Text    = password.Email;
            txtUsername.Text = password.Username;
            txtWebsite.Text  = password.Website;
            txtPassword.Text = password.Text;
            rtxtNotes.Text   = password.Notes;

            btnSave.Enabled = IsEnable();

            try
            {
                List <PasswordHistory> pass = PasswordsService.Instance().GetAllUserPasswordHistory(user, this.password);
                dataGridHistory.Rows.Clear();
                pass.ForEach(p => dataGridHistory.Rows.Add(p.GetToString()));
            }
            catch (Exception ex)
            {
                Messenger.Show(ex.Message + " " + ex.HResult, "Error");
            }
        }
Esempio n. 19
0
        private async Task LoadPasswords()
        {
            localPasswords = await PasswordsService.Instance().GetAllPasswordsAsync(localSettings);

            ShowPasswords(localPasswords);
        }
Esempio n. 20
0
 public async void ShowPasswords(User user)
 {
     ShowPasswords(await PasswordsService.Instance().GetAllUserPasswordsAsync(user));
 }
Esempio n. 21
0
 private async void btnGenerate_Click(object sender, EventArgs e)
 {
     txtPassword.Text = await PasswordsService.Instance().GeneratePasswordAsync(user);
 }