Пример #1
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgWorker.ReportProgress(1, "Requesting Authenticator Token...");

                AuthAPI.Authenticator newAuthenticator = Settings.SettingsDatabase.SelectedAuthenticator.Clone() as AuthAPI.Authenticator;

                newAuthenticator.Name = authenticatorName;

                if (encryptionType != AuthAPI.Security.EncryptionProvider.EncryptionType.None)
                {
                    bgWorker.ReportProgress(1, "Encrypting Authenticator...");
                }

                newAuthenticator.Encrypt(encryptionType, userPassword);

                bgWorker.ReportProgress(2, "Saving Authenticator to File...");

                newAuthenticator.ToFile(savePath);

                bgWorker.ReportProgress(3, "Authenticator Exported!");

                System.Threading.Thread.Sleep(1000);

                e.Result = true;
            }
            catch (Exception)
            {
                e.Result = false;
            }
        }
Пример #2
0
        private void bgVerifier_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgVerifier.ReportProgress(0, "Verifying Restore Code...");

                newAuthenticator = AuthAPI.BlizzardAPI.RestoreAuthenticator(checkSerial, checkRestoreCode);

                if (newAuthenticator == null)
                {
                    e.Result = false;
                    return;
                }

                bgVerifier.ReportProgress(2, "Restore Code Verified!");

                System.Threading.Thread.Sleep(1000);

                e.Result = true;
            }
            catch (Exception)
            {
                e.Result = false;
            }
        }
Пример #3
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgWorker.ReportProgress(0, "Requesting Authenticator Token...");

                newAuthenticator = AuthAPI.BlizzardAPI.RequestAuthenticator();

                if (newAuthenticator == null)
                {
                    e.Result = false;
                    return;
                }

                newAuthenticator.Name = authenticatorName;

                if (encryptionType != AuthAPI.Security.EncryptionProvider.EncryptionType.None)
                {
                    bgWorker.ReportProgress(1, "Encrypting Authenticator...");

                    newAuthenticator.Encrypt(encryptionType, userPassword);
                }

                bgWorker.ReportProgress(2, "Adding Authenticator to Database...");

                Settings.SettingsDatabase.Authenticators.Add(newAuthenticator);
                Settings.SettingsDatabase.Save();

                bgWorker.ReportProgress(3, "Authenticator Created!");

                System.Threading.Thread.Sleep(1000);

                e.Result = true;
            }
            catch (Exception)
            {
                e.Result = false;
            }
        }
Пример #4
0
        public HelpAddingWindow(AuthAPI.Authenticator auth)
        {
            InitializeComponent();

            PROGRESS_AuthCode.Maximum = AuthAPI.BlizzardAPI.HOTP_PERIOD_LENGTH - 1;

            LINK_BattleNet.Click += new RoutedEventHandler(LINK_BattleNet_Click);

            this.auth = auth;

            authTimer          = new DispatcherTimer();
            authTimer.Interval = TimeSpan.FromMilliseconds(100);
            authTimer.Tick    += new EventHandler(authTimer_Tick);

            TEXT_Serial.Text = auth.Serial;

            this.RefreshAuthenticatorData();

            TEXT_AuthCode.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(TEXT_PreviewMouseLeftButtonDown);
            TEXT_Serial.PreviewMouseLeftButtonDown   += new MouseButtonEventHandler(TEXT_PreviewMouseLeftButtonDown);

            this.Closing += new System.ComponentModel.CancelEventHandler(HelpAddingWindow_Closing);
        }
Пример #5
0
        public HelpAddingWindow(AuthAPI.Authenticator auth)
        {
            InitializeComponent();

            PROGRESS_AuthCode.Maximum = AuthAPI.BlizzardAPI.HOTP_PERIOD_LENGTH - 1;

            LINK_BattleNet.Click += new RoutedEventHandler(LINK_BattleNet_Click);

            this.auth = auth;

            authTimer = new DispatcherTimer();
            authTimer.Interval = TimeSpan.FromMilliseconds(100);
            authTimer.Tick += new EventHandler(authTimer_Tick);

            TEXT_Serial.Text = auth.Serial;

            this.RefreshAuthenticatorData();

            TEXT_AuthCode.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(TEXT_PreviewMouseLeftButtonDown);
            TEXT_Serial.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(TEXT_PreviewMouseLeftButtonDown);

            this.Closing += new System.ComponentModel.CancelEventHandler(HelpAddingWindow_Closing);
        }
Пример #6
0
        private void WIZARD_PageChanged(object sender, RoutedEventArgs e)
        {
            if (WIZARD.CurrentPage == WIZARDPAGE_SettingsSummary)
            {
                string strEncryptionType = null;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    strEncryptionType = "Password";
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    if (strEncryptionType != null)
                        strEncryptionType += "\n";
                    else
                        strEncryptionType = "";

                    strEncryptionType += (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? "Locked to local machine (" + TEXTBLOCK_LocalMachine.Text + ")" : "Locked to current user (" + TEXTBLOCK_CurrentUser.Text + ")";
                }

                if (strEncryptionType == null)
                {
                    LABEL_EncryptionType.IsEnabled = false;
                    LABEL_EncryptionType.Content = "(None)";
                }
                else
                {
                    LABEL_EncryptionType.IsEnabled = true;
                    LABEL_EncryptionType.Content = strEncryptionType;
                }

                if (String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    LABEL_FriendlyName.IsEnabled = false;
                    LABEL_FriendlyName.Content = "(Serial will be used)";
                }
                else
                {
                    LABEL_FriendlyName.IsEnabled = true;
                    LABEL_FriendlyName.Content = TEXT_FriendlyName.Text.Trim();
                }
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_Progress)
            {
                encryptionType = AuthAPI.Security.EncryptionProvider.EncryptionType.None;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    userPassword = TEXT_Password.Text;
                    encryptionType |= AuthAPI.Security.EncryptionProvider.EncryptionType.Password;
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    encryptionType |= (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? AuthAPI.Security.EncryptionProvider.EncryptionType.LocalMachine : AuthAPI.Security.EncryptionProvider.EncryptionType.LocalUser;
                }

                if (!String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    authenticatorName = TEXT_FriendlyName.Text.Trim();
                }

                bgWorker.RunWorkerAsync();
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_SelectFile)
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.CheckFileExists = true;

                dlg.Title = "Select Authenticator";
                dlg.DefaultExt = ".bma"; // Default file extension
                dlg.Filter = "WinBMA Exported Authenticator (.bma)|*.bma"; // Filter files by extension

                // Show open file dialog box
                Nullable<bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    string filename = dlg.FileName;

                    newAuthenticator = AuthAPI.Authenticator.FromFile(filename);

                    if (newAuthenticator == null)
                    {
                        this.Close();
                        return;
                    }

                    if (!this.DecryptAuthenticator())
                    {
                        this.Close();
                        return;
                    }

                    TEXT_FriendlyName.Text = newAuthenticator.Name;
                    WIZARD.CurrentPage = WIZARDPAGE_Protect;
                }
                else
                {
                    this.Close();
                }
            }
        }
Пример #7
0
        private void WIZARD_PageChanged(object sender, RoutedEventArgs e)
        {
            if (WIZARD.CurrentPage == WIZARDPAGE_SettingsSummary)
            {
                string strEncryptionType = null;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    strEncryptionType = "Password";
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    if (strEncryptionType != null)
                    {
                        strEncryptionType += "\n";
                    }
                    else
                    {
                        strEncryptionType = "";
                    }

                    strEncryptionType += (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? "Locked to local machine (" + TEXTBLOCK_LocalMachine.Text + ")" : "Locked to current user (" + TEXTBLOCK_CurrentUser.Text + ")";
                }

                if (strEncryptionType == null)
                {
                    LABEL_EncryptionType.IsEnabled = false;
                    LABEL_EncryptionType.Content   = "(None)";
                }
                else
                {
                    LABEL_EncryptionType.IsEnabled = true;
                    LABEL_EncryptionType.Content   = strEncryptionType;
                }

                if (String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    LABEL_FriendlyName.IsEnabled = false;
                    LABEL_FriendlyName.Content   = "(Serial will be used)";
                }
                else
                {
                    LABEL_FriendlyName.IsEnabled = true;
                    LABEL_FriendlyName.Content   = TEXT_FriendlyName.Text.Trim();
                }
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_Progress)
            {
                encryptionType = AuthAPI.Security.EncryptionProvider.EncryptionType.None;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    userPassword    = TEXT_Password.Text;
                    encryptionType |= AuthAPI.Security.EncryptionProvider.EncryptionType.Password;
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    encryptionType |= (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? AuthAPI.Security.EncryptionProvider.EncryptionType.LocalMachine : AuthAPI.Security.EncryptionProvider.EncryptionType.LocalUser;
                }

                if (!String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    authenticatorName = TEXT_FriendlyName.Text.Trim();
                }

                bgWorker.RunWorkerAsync();
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_VerifyCode)
            {
                newAuthenticator           = null;
                PROGRESS_VerifyTasks.Value = 0;

                checkSerial      = TEXT_RestoreSerial.Text;
                checkRestoreCode = TEXT_RestoreCodeInput.Text;

                bgVerifier.RunWorkerAsync();
            }
        }
Пример #8
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgWorker.ReportProgress(0, "Requesting Authenticator Token...");

                newAuthenticator = AuthAPI.BlizzardAPI.RequestAuthenticator();

                if (newAuthenticator == null)
                {
                    e.Result = false;
                    return;
                }

                newAuthenticator.Name = authenticatorName;

                if (encryptionType != AuthAPI.Security.EncryptionProvider.EncryptionType.None)
                {
                    bgWorker.ReportProgress(1, "Encrypting Authenticator...");

                    newAuthenticator.Encrypt(encryptionType, userPassword);
                }

                bgWorker.ReportProgress(2, "Adding Authenticator to Database...");

                Settings.SettingsDatabase.Authenticators.Add(newAuthenticator);
                Settings.SettingsDatabase.Save();

                bgWorker.ReportProgress(3, "Authenticator Created!");

                System.Threading.Thread.Sleep(1000);

                e.Result = true;
            }
            catch (Exception)
            {
                e.Result = false;
            }
        }
Пример #9
0
        private void WIZARD_PageChanged(object sender, RoutedEventArgs e)
        {
            if (WIZARD.CurrentPage == WIZARDPAGE_SettingsSummary)
            {
                string strEncryptionType = null;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    strEncryptionType = "Password";
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    if (strEncryptionType != null)
                        strEncryptionType += "\n";
                    else
                        strEncryptionType = "";

                    strEncryptionType += (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? "Locked to local machine (" + TEXTBLOCK_LocalMachine.Text + ")" : "Locked to current user (" + TEXTBLOCK_CurrentUser.Text + ")";
                }

                if (strEncryptionType == null)
                {
                    LABEL_EncryptionType.IsEnabled = false;
                    LABEL_EncryptionType.Content = "(None)";
                }
                else
                {
                    LABEL_EncryptionType.IsEnabled = true;
                    LABEL_EncryptionType.Content = strEncryptionType;
                }

                if (String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    LABEL_FriendlyName.IsEnabled = false;
                    LABEL_FriendlyName.Content = "(Serial will be used)";
                }
                else
                {
                    LABEL_FriendlyName.IsEnabled = true;
                    LABEL_FriendlyName.Content = TEXT_FriendlyName.Text.Trim();
                }
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_Progress)
            {
                encryptionType = AuthAPI.Security.EncryptionProvider.EncryptionType.None;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    userPassword = TEXT_Password.Text;
                    encryptionType |= AuthAPI.Security.EncryptionProvider.EncryptionType.Password;
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    encryptionType |= (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? AuthAPI.Security.EncryptionProvider.EncryptionType.LocalMachine : AuthAPI.Security.EncryptionProvider.EncryptionType.LocalUser;
                }

                if (!String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    authenticatorName = TEXT_FriendlyName.Text.Trim();
                }

                bgWorker.RunWorkerAsync();
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_VerifyCode)
            {
                newAuthenticator = null;
                PROGRESS_VerifyTasks.Value = 0;

                checkSerial = TEXT_RestoreSerial.Text;
                checkRestoreCode = TEXT_RestoreCodeInput.Text;

                bgVerifier.RunWorkerAsync();
            }
        }
Пример #10
0
        private void bgVerifier_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bgVerifier.ReportProgress(0, "Verifying Restore Code...");

                newAuthenticator = AuthAPI.BlizzardAPI.RestoreAuthenticator(checkSerial, checkRestoreCode);

                if (newAuthenticator == null)
                {
                    e.Result = false;
                    return;
                }

                bgVerifier.ReportProgress(2, "Restore Code Verified!");

                System.Threading.Thread.Sleep(1000);

                e.Result = true;
            }
            catch (Exception)
            {
                e.Result = false;
            }
        }
Пример #11
0
        private void WIZARD_PageChanged(object sender, RoutedEventArgs e)
        {
            if (WIZARD.CurrentPage == WIZARDPAGE_SettingsSummary)
            {
                string strEncryptionType = null;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    strEncryptionType = "Password";
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    if (strEncryptionType != null)
                    {
                        strEncryptionType += "\n";
                    }
                    else
                    {
                        strEncryptionType = "";
                    }

                    strEncryptionType += (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? "Locked to local machine (" + TEXTBLOCK_LocalMachine.Text + ")" : "Locked to current user (" + TEXTBLOCK_CurrentUser.Text + ")";
                }

                if (strEncryptionType == null)
                {
                    LABEL_EncryptionType.IsEnabled = false;
                    LABEL_EncryptionType.Content   = "(None)";
                }
                else
                {
                    LABEL_EncryptionType.IsEnabled = true;
                    LABEL_EncryptionType.Content   = strEncryptionType;
                }

                if (String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    LABEL_FriendlyName.IsEnabled = false;
                    LABEL_FriendlyName.Content   = "(Serial will be used)";
                }
                else
                {
                    LABEL_FriendlyName.IsEnabled = true;
                    LABEL_FriendlyName.Content   = TEXT_FriendlyName.Text.Trim();
                }
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_Progress)
            {
                encryptionType = AuthAPI.Security.EncryptionProvider.EncryptionType.None;

                if (CHECK_ProtectPassword.IsChecked == true)
                {
                    userPassword    = TEXT_Password.Text;
                    encryptionType |= AuthAPI.Security.EncryptionProvider.EncryptionType.Password;
                }

                if (CHECK_ProtectWindows.IsChecked == true)
                {
                    encryptionType |= (RADIO_ProtectLocalMachine.IsChecked == true)
                        ? AuthAPI.Security.EncryptionProvider.EncryptionType.LocalMachine : AuthAPI.Security.EncryptionProvider.EncryptionType.LocalUser;
                }

                if (!String.IsNullOrWhiteSpace(TEXT_FriendlyName.Text))
                {
                    authenticatorName = TEXT_FriendlyName.Text.Trim();
                }

                bgWorker.RunWorkerAsync();
            }
            else if (WIZARD.CurrentPage == WIZARDPAGE_SelectFile)
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.CheckFileExists = true;

                dlg.Title      = "Select Authenticator";
                dlg.DefaultExt = ".bma";                                       // Default file extension
                dlg.Filter     = "WinBMA Exported Authenticator (.bma)|*.bma"; // Filter files by extension

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    string filename = dlg.FileName;

                    newAuthenticator = AuthAPI.Authenticator.FromFile(filename);

                    if (newAuthenticator == null)
                    {
                        this.Close();
                        return;
                    }

                    if (!this.DecryptAuthenticator())
                    {
                        this.Close();
                        return;
                    }

                    TEXT_FriendlyName.Text = newAuthenticator.Name;
                    WIZARD.CurrentPage     = WIZARDPAGE_Protect;
                }
                else
                {
                    this.Close();
                }
            }
        }