コード例 #1
0
        private void btnClickValidate(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtBxPassword.Password))
            {
                System.Windows.MessageBox.Show("Please enter a password to validate.");
                return;
            }
            if (String.IsNullOrEmpty(MasterConfigManager.getInstance().getPasswordHash()))
            {
                System.Windows.MessageBox.Show("Master Password has not been set, please set master password first.");
                SetMasterPasswordWindow smpw = new SetMasterPasswordWindow();
                smpw.ShowDialog();
                return;
            }
            string inputPassword   = txtBxPassword.Password;
            bool   correctPassword = MasterConfigManager.getInstance().validatePaswword(inputPassword);

            if (!correctPassword)
            {
                System.Windows.MessageBox.Show("Password is not correct!");
            }
            else
            {
                System.Windows.MessageBox.Show("Password is correct!");
            }
        }
コード例 #2
0
        public MainWindow()
        {
            SplashScreen sc = new SplashScreen(SPLASHSCRNIMGPATH);

            sc.Show(false);
            sc.Close(TimeSpan.FromSeconds(3));
            System.Threading.Thread.Sleep(3000);
            sc = null;
            InitializeComponent();
            this.DataContext = this;
            string projectDirectory = String.Empty;

#if (DEBUG)
            //projectDirectory = @"C:\Program Files (x86)\AccountsManager";
            projectDirectory = AppDomain.CurrentDomain.BaseDirectory;
#else
            projectDirectory = AppDomain.CurrentDomain.BaseDirectory;
#endif
            txtFilePath.Text = projectDirectory + ACCTSMGRFILEPATH;
            try
            {
                if (String.IsNullOrEmpty(projectDirectory + ACCTSMGRUSERSCONFIGPATH) || !File.Exists(projectDirectory + ACCTSMGRUSERSCONFIGPATH))
                {
                    throw new FileNotFoundException("Accounts Manager can't find specified config file " + projectDirectory + ACCTSMGRUSERSCONFIGPATH + " Application will now shutdown.");
                }
                if (String.IsNullOrEmpty(projectDirectory + ACCTSMGRFILEPATH) || !File.Exists(projectDirectory + ACCTSMGRFILEPATH))
                {
                    throw new FileNotFoundException("Accounts Manager can't find specified config file " + projectDirectory + ACCTSMGRFILEPATH + " Application will now shutdown.");
                }
                MasterConfigManager.getInstance(projectDirectory + ACCTSMGRUSERSCONFIGPATH);
                if (String.IsNullOrEmpty(MasterConfigManager.getInstance().getPasswordHash()))
                {
                    System.Windows.MessageBox.Show("No master password has been set yet. " + Environment.NewLine + "Please enter a master password to be used to encrypt file.");
                    SetMasterPasswordWindow smpw = new SetMasterPasswordWindow();
                    smpw.ShowDialog();
                }
                if (MasterConfigManager.getInstance().getIsFileEncrypted() == false)
                {
                    lblStatus.Visibility = Visibility.Hidden;
                }
                UserAccountsManager.getInstance(projectDirectory + ACCTSMGRFILEPATH);
                listboxuseraccounts.ItemsSource = UserAccountsManager.getInstance().getUserAccounts();
            }
            catch (FileNotFoundException ex)
            {
                showErrorWindow(ex);
            }
            catch (FileFormatException ex)
            {
                showErrorWindow(ex);
            }
        }
コード例 #3
0
        private void btnClickChangePassword(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(MasterConfigManager.getInstance().getPasswordHash()))
            {
                System.Windows.MessageBox.Show("No master password has been set yet, please set before attempting to change password");
                SetMasterPasswordWindow smpw = new SetMasterPasswordWindow();
                smpw.ShowDialog();
                return;
            }
            ChangePasswordWindow cpw = new ChangePasswordWindow();

            cpw.Show();
        }
コード例 #4
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (!MasterPasswordSet)
     {
         MessageBoxResult mbr = MessageBox.Show("Master password must be set before using application. " +
                                                "Select yes if you wish to set master password, otherwise select no to exit application.", "", MessageBoxButton.YesNo);
         if (mbr == MessageBoxResult.Yes)
         {
             SetMasterPasswordWindow smpw = new SetMasterPasswordWindow();
             smpw.ShowDialog();
         }
         else
         {
             Application.Current.Shutdown();
         }
     }
 }
コード例 #5
0
        private void btnClickEncrypt(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(MasterConfigManager.getInstance().getPasswordHash()))
            {
                System.Windows.MessageBox.Show("Master Password has not been set, please set master password first.");
                SetMasterPasswordWindow smpw = new SetMasterPasswordWindow();
                smpw.ShowDialog();
                return;
            }
            if (MasterConfigManager.getInstance().getIsFileEncrypted() == true)
            {
                System.Windows.MessageBox.Show("File is already encrypted.");
                return;
            }
            if (string.IsNullOrEmpty(txtFilePath.Text))
            {
                System.Windows.MessageBox.Show("Please select a user accounts file first.");
                return;
            }
            string file = txtFilePath.Text;

            if (!File.Exists(file))
            {
                System.Windows.MessageBox.Show("Specified user accounts file does not exist!");
                return;
            }
            var  password        = txtBxPassword.Password;
            bool correctPassword = MasterConfigManager.getInstance().validatePaswword(password);

            if (!correctPassword)
            {
                System.Windows.MessageBox.Show("Password is not correct!");
                return;
            }
            FileEncryptor.Encrypt(file, password, MasterConfigManager.getInstance().getPasswordSalt());
            listboxuseraccounts.ItemsSource = null;
            lblStatus.Visibility            = Visibility.Visible;
        }