예제 #1
0
        private void btnConfig_Click(object sender, RoutedEventArgs e)
        {
            int       Id         = (dgDevicesList.SelectedItem as Device).id;
            var       ConfigItem = modelCodeFirst.Devices.Where(m => m.id == Id).Single();
            ConfigWin newConfig  = new ConfigWin(ConfigItem.id);

            newConfig.ShowDialog();
            Load();
        }
예제 #2
0
        // Open KeyServer Configuration Form
        private void OpenConfigForm(object sender, EventArgs e)
        {
            ConfigWin ConfigForm = new ConfigWin(m_host);

            ConfigForm.ShowDialog();
        }
예제 #3
0
        public override byte[] GetKey(KeyProviderQueryContext ctx)
        {
            //Apply Policy restrictions.
            PolicyApply();

            SecureString secPassword = new SecureString();

            // Reads config values for Keepass.config.xml
            string ksURL      = m_host.CustomConfig.GetString(urlField);
            string ksLogin    = m_host.CustomConfig.GetString(loginField);
            string ksPassword = m_host.CustomConfig.GetString(passwordField);

            // Open config window if a parameter is missing
            if ((ksURL == null) || (ksLogin == null) || (ksPassword == null))
            {
                ConfigWin ConfigForm = new ConfigWin(m_host);
                ConfigForm.ShowDialog();

                ksURL      = m_host.CustomConfig.GetString(urlField);
                ksLogin    = m_host.CustomConfig.GetString(loginField);
                ksPassword = m_host.CustomConfig.GetString(passwordField);
            }

            // Open Debug Window
            StatusWin StatusForm = new StatusWin();

            StatusForm.Show();

            // Create Webservice object
            StatusForm.StatusLog.Text = "Invoking Web Service...";
            KeyServerWS.Soap ksws = new KeyServerWS.Soap();
            // Use URL from Keepass.config.xml
            ksws.Url = ksURL;
            StatusForm.StatusLog.AppendText("Done\r\n");

            // Retrieve database filename
            string dbFilename = Path.GetFileName(ctx.DatabasePath);

            StatusForm.StatusLog.AppendText("Querying key with parameters :\r\n");
            StatusForm.StatusLog.AppendText(String.Format(" - FileName : {0}\r\n", dbFilename));
            StatusForm.StatusLog.AppendText(String.Format(" - UserName : {0}\r\n", ksLogin));
            StatusForm.StatusLog.AppendText(String.Format(" - HadwareId : {0}\r\n", HardwareId));

            string dbKey = null;

            try {
                secPassword.Encrypted = ksPassword;
                NetworkCredential ksCreds = new NetworkCredential();
                ksCreds.UserName = ksLogin;
                ksCreds.Password = secPassword.Decrypted;
                ksws.Credentials = ksCreds;
                dbKey            = ksws.GetKey(dbFilename, ksLogin, HardwareId);
                StatusForm.StatusLog.AppendText("Done\r\n");
                StatusForm.StatusLog.AppendText(String.Format("Key Found : {0}\r\n", dbKey));
            } catch (Exception) {
                MessageBox.Show("Connection Error...\r\nCheck configuration.\r\n(Tools / Configure KeyServer)");
                StatusForm.Close();
                return(null);
            }

            if (dbKey == String.Empty)
            {
                MessageBox.Show("Error : Access denied or database not found");
                StatusForm.Close();
                return(null);
            }

            return(Encoding.ASCII.GetBytes(dbKey));
        }