Show YubiKey message from MainWindow to ensure it's always shown when a challenge is generated

This commit is contained in:
Janek Bevendorff 2017-02-24 17:27:27 +01:00
parent d6c48a5cf1
commit b10cb1c83c
No known key found for this signature in database
GPG Key ID: CFEC2F6850BFFA53
7 changed files with 17 additions and 32 deletions

View File

@ -177,8 +177,6 @@ void ChangeMasterKeyWidget::generateKey()
bool blocking = i & true;
int slot = i >> 1;
auto key = QSharedPointer<YkChallengeResponseKey>(new YkChallengeResponseKey(slot, blocking));
connect(key.data(), SIGNAL(userInteractionRequired()), SLOT(showYubiKeyPopup()));
connect(key.data(), SIGNAL(userConfirmed()), SLOT(hideYubiKeyPopup()));
m_key.addChallengeResponseKey(key);
}
#endif
@ -241,15 +239,3 @@ void ChangeMasterKeyWidget::setCancelEnabled(bool enabled)
{
m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(enabled);
}
void ChangeMasterKeyWidget::showYubiKeyPopup()
{
KEEPASSXC_MAIN_WINDOW->displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information);
KEEPASSXC_MAIN_WINDOW->setEnabled(false);
}
void ChangeMasterKeyWidget::hideYubiKeyPopup()
{
KEEPASSXC_MAIN_WINDOW->hideGlobalMessage();
KEEPASSXC_MAIN_WINDOW->setEnabled(true);
}

View File

@ -55,8 +55,6 @@ private slots:
void noYubikeyFound();
void challengeResponseGroupToggled(bool checked);
void pollYubikey();
void showYubiKeyPopup();
void hideYubiKeyPopup();
private:
const QScopedPointer<Ui::ChangeMasterKeyWidget> m_ui;

View File

@ -214,8 +214,6 @@ CompositeKey DatabaseOpenWidget::databaseKey()
bool blocking = i & true;
int slot = i >> 1;
auto key = QSharedPointer<YkChallengeResponseKey>(new YkChallengeResponseKey(slot, blocking));
connect(key.data(), SIGNAL(userInteractionRequired()), SLOT(showYubiKeyPopup()));
connect(key.data(), SIGNAL(userConfirmed()), SLOT(hideYubiKeyPopup()));
masterKey.addChallengeResponseKey(key);
}
#endif
@ -266,18 +264,6 @@ void DatabaseOpenWidget::pollYubikey()
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
}
void DatabaseOpenWidget::showYubiKeyPopup()
{
m_ui->messageWidget->showMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information);
KEEPASSXC_MAIN_WINDOW->setEnabled(false);
}
void DatabaseOpenWidget::hideYubiKeyPopup()
{
m_ui->messageWidget->hideMessage();
KEEPASSXC_MAIN_WINDOW->setEnabled(true);
}
void DatabaseOpenWidget::yubikeyDetected(int slot, bool blocking)
{
YkChallengeResponseKey yk(slot, blocking);

View File

@ -53,8 +53,6 @@ protected:
protected slots:
virtual void openDatabase();
void showYubiKeyPopup();
void hideYubiKeyPopup();
void reject();
private slots:

View File

@ -871,3 +871,14 @@ void MainWindow::hideTabMessage()
}
}
void MainWindow::showYubiKeyPopup()
{
displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information);
setEnabled(false);
}
void MainWindow::hideYubiKeyPopup()
{
hideGlobalMessage();
setEnabled(true);
}

View File

@ -47,6 +47,8 @@ public Q_SLOTS:
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type);
void displayTabMessage(const QString& text, MessageWidget::MessageType type);
void hideGlobalMessage();
void showYubiKeyPopup();
void hideYubiKeyPopup();
protected:
void closeEvent(QCloseEvent* event) override;

View File

@ -20,6 +20,7 @@
#include "core/Tools.h"
#include "crypto/CryptoHash.h"
#include "crypto/Random.h"
#include "gui/MainWindow.h"
#include <QFile>
#include <QXmlStreamReader>
@ -32,6 +33,9 @@ YkChallengeResponseKey::YkChallengeResponseKey(int slot, bool blocking)
: m_slot(slot),
m_blocking(blocking)
{
connect(this, SIGNAL(userInteractionRequired()), KEEPASSXC_MAIN_WINDOW, SLOT(showYubiKeyPopup()));
connect(this, SIGNAL(userConfirmed()), KEEPASSXC_MAIN_WINDOW, SLOT(hideYubiKeyPopup()));
}
QByteArray YkChallengeResponseKey::rawKey() const