Ejemplo n.º 1
0
        /// <summary>
        /// Called everytime a database is opened.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void FileOpenedHandler(object sender, FileOpenedEventArgs e)
        {
            var ioInfo = e.Database.IOConnectionInfo;

            if (e.Database.CustomData.Get(ProductName) == null) // If there is no CustomData in this database
            {
                // Create CustomData to save global setting to enable or disable the plugin
                e.Database.CustomData.Set(ProductName, "true");
                e.Database.Modified = true;

                // Try to save the database
                try { e.Database.Save(null); }
                catch { }
            }

            // Global settings to be used in the Options Panel
            dbName        = Library.CharChange(ioInfo.Path);
            database      = e.Database;
            UWPLibrary.ck = database.MasterKey;
            if (e.Database.CustomData.Get(ProductName + "AT") == "true")
            {
                LockAfterAutoType = true;
            }
            else
            {
                LockAfterAutoType = false;
            }

            if (e.Database.CustomData.Get(ProductName) == "true")
            {
                enablePlugin = true;
            }
            if (e.Database.CustomData.Get(ProductName) == "false") // if plugin is disabled for the database
            {
                enablePlugin = false;
                return; // Don't do anything else
            }

            if (await UWPLibrary.FirstTime(dbName)) // If the database has no credentials saved
            {
                bool isHelloAvailable = await UWPLibrary.IsHelloAvailable();

                if (isHelloAvailable)
                {
                    // Ask the user if he/she wants to configure the plugin
                    bool yesOrNo = MessageService.AskYesNo("Do You want to set " +
                                                           WinHelloUnlockExt.ProductName + " for " + dbName + " now?", WinHelloUnlockExt.ShortProductName, true);

                    // In case he/she wants, create the credentials
                    if (yesOrNo)
                    {
                        await UWPLibrary.CreateHelloData(dbName);
                    }
                }
            }

            // Set global settings back to default
            tries  = 0;
            opened = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// When the plugin detects a change in the MasterKey, it uses this method to prompt the user to update or delete the data
 /// </summary>
 /// <param name="ioInfo">IOConnectionInfo that represents the database.</param>
 /// <param name="dbPath">Name of the credential to update or delete.</param>
 /// <param name="opening">If the masterkey change was detected during database unlock use true.</param>
 internal static async Task HandleMasterKeyChange(IOConnectionInfo ioInfo, string dbPath, bool opening)
 {
     if (opening)
     {
         string str = WinHelloUnlockExt.ProductName + " could not unlock this database." +
                      " MasterKey must have changed. Delete " + WinHelloUnlockExt.ProductName + " data?";
         if (MessageService.AskYesNo(str, WinHelloUnlockExt.ProductName))
         {
             UWPLibrary.DeleteHelloData(dbPath);
         }
         WinHelloUnlockExt.opened = true;
         WinHelloUnlockExt.Host.MainWindow.OpenDatabase(ioInfo, null, false);
     }
     else
     {
         string str = "A change in MasterKey has been detected. Do you want to update " +
                      WinHelloUnlockExt.ProductName + " data?";
         if (MessageService.AskYesNo(str, WinHelloUnlockExt.ProductName))
         {
             UWPLibrary.DeleteHelloData(dbPath);
             await UWPLibrary.CreateHelloData(dbPath);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>Creates WinHelloUnock data when the Create Button is clicked.</summary>
        private async void CreateButton_Click(object sender, EventArgs e)
        {
            await UWPLibrary.CreateHelloData(WinHelloUnlockExt.dbName);

            RefreshOptions();
        }