Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/controller/command-handlers/authenticate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class Authenticate : public CertificateReader
QVariantMap onConfirm(WebEidUI* window,
const EidCertificateAndPinInfo& certAndPinInfo) override;

signals:
void verifyPinFailed(const electronic_id::VerifyPinFailed::Status status,
const qint8 retriesLeft);

private:
QString challengeNonce;
};
2 changes: 0 additions & 2 deletions src/controller/command-handlers/sign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class Sign : public CertificateReader

signals:
void signingCertificateMismatch();
void verifyPinFailed(const electronic_id::VerifyPinFailed::Status status,
const qint8 retriesLeft);

private:
void
Expand Down
1 change: 1 addition & 0 deletions src/controller/commandhandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CommandHandler : public QObject
void multipleCertificatesReady(const QUrl& origin,
const std::vector<EidCertificateAndPinInfo>& certAndPinInfos);
void singleCertificateReady(const QUrl& origin, const EidCertificateAndPinInfo& certAndPinInfo);
void verifyPinFailed(electronic_id::VerifyPinFailed::Status status, qint8 retriesLeft);

protected:
CommandHandler(const CommandWithArguments& cmd) : command(cmd) {}
Expand Down
61 changes: 29 additions & 32 deletions src/controller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,22 @@ void Controller::onCardsAvailable(
}
}

void Controller::runCommandHandler(const std::vector<ElectronicID::ptr>& availableEids)
{
try {
auto* commandHandlerRunThread =
new CommandHandlerRunThread(this, *commandHandler, availableEids);
connectRetry(commandHandlerRunThread);

// When the command handler run thread retrieves certificates successfully, call
// onCertificatesLoaded() that starts card event monitoring while user enters the PIN.
connect(commandHandler.get(), &CommandHandler::singleCertificateReady, this,
&Controller::onCertificatesLoaded);
connect(commandHandler.get(), &CommandHandler::multipleCertificatesReady, this,
&Controller::onCertificatesLoaded);

commandHandlerRunThread->start();

} catch (const std::exception& error) {
onCriticalFailure(error.what());
}
void Controller::runCommandHandler(std::vector<ElectronicID::ptr> availableEids) noexcept
try {
auto* commandHandlerRunThread =
new CommandHandlerRunThread(this, *commandHandler, std::move(availableEids));
connectRetry(commandHandlerRunThread);

// When the command handler run thread retrieves certificates successfully, call
// onCertificatesLoaded() that starts card event monitoring while user enters the PIN.
connect(commandHandler.get(), &CommandHandler::singleCertificateReady, this,
&Controller::onCertificatesLoaded);
connect(commandHandler.get(), &CommandHandler::multipleCertificatesReady, this,
&Controller::onCertificatesLoaded);

commandHandlerRunThread->start();
} catch (const std::exception& error) {
onCriticalFailure(error.what());
}

void Controller::onCertificatesLoaded()
Expand All @@ -202,22 +199,22 @@ void Controller::disposeUI()
}
}

void Controller::onConfirmCommandHandler(const EidCertificateAndPinInfo& certAndPinInfo)
{
void Controller::onConfirmCommandHandler(const EidCertificateAndPinInfo& certAndPinInfo) noexcept
try {
emit stopCardEventMonitorThread();

try {
auto* commandHandlerConfirmThread =
new CommandHandlerConfirmThread(this, *commandHandler, window, certAndPinInfo);
connect(commandHandlerConfirmThread, &CommandHandlerConfirmThread::completed, this,
&Controller::onCommandHandlerConfirmCompleted);
connectRetry(commandHandlerConfirmThread);
auto* commandHandlerConfirmThread =
new CommandHandlerConfirmThread(this, *commandHandler, window, certAndPinInfo);
connect(commandHandlerConfirmThread, &CommandHandlerConfirmThread::completed, this,
&Controller::onCommandHandlerConfirmCompleted);
connectRetry(commandHandlerConfirmThread);
connect(commandHandler.get(), &CommandHandler::verifyPinFailed, this,
&Controller::onCertificatesLoaded);

commandHandlerConfirmThread->start();
commandHandlerConfirmThread->start();

} catch (const std::exception& error) {
onCriticalFailure(error.what());
}
} catch (const std::exception& error) {
onCriticalFailure(error.what());
}

void Controller::onCommandHandlerConfirmCompleted(const QVariantMap& res)
Expand Down Expand Up @@ -258,7 +255,7 @@ void Controller::onRetry()
}
}

void Controller::connectRetry(const ControllerChildThread* childThread)
void Controller::connectRetry(const ControllerChildThread* childThread) const
{
REQUIRE_NON_NULL(childThread)
connect(childThread, &ControllerChildThread::failure, this, &Controller::onCriticalFailure);
Expand Down
6 changes: 3 additions & 3 deletions src/controller/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Controller : public QObject
void onCertificatesLoaded();

// Called either directly from onDialogOK().
void onConfirmCommandHandler(const EidCertificateAndPinInfo& certAndPinInfo);
void onConfirmCommandHandler(const EidCertificateAndPinInfo& certAndPinInfo) noexcept;

// Called from CommandHandlerConfirm thread.
void onCommandHandlerConfirmCompleted(const QVariantMap& result);
Expand All @@ -69,8 +69,8 @@ class Controller : public QObject

private:
void startCommandExecution();
void runCommandHandler(const std::vector<electronic_id::ElectronicID::ptr>& availableEids);
void connectRetry(const ControllerChildThread* childThread);
void runCommandHandler(std::vector<electronic_id::ElectronicID::ptr> availableEids) noexcept;
void connectRetry(const ControllerChildThread* childThread) const;
void createWindow();
void disposeUI();
void exit();
Expand Down
5 changes: 3 additions & 2 deletions src/controller/threads/commandhandlerrunthread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class CommandHandlerRunThread : public ControllerChildThread

public:
CommandHandlerRunThread(QObject* parent, CommandHandler& handler,
const std::vector<electronic_id::ElectronicID::ptr>& eids) :
ControllerChildThread(handler.commandType(), parent), commandHandler(handler), eids(eids)
std::vector<electronic_id::ElectronicID::ptr> eids) noexcept :
ControllerChildThread(handler.commandType(), parent), commandHandler(handler),
eids(std::move(eids))
{
// Connect retry signal to retry signal to pass it up from the command handler.
connect(&commandHandler, &CommandHandler::retry, this, &ControllerChildThread::retry);
Expand Down
6 changes: 4 additions & 2 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private)
if (auto* button =
qobject_cast<CertificateButton*>(ui->selectionGroup->checkedButton())) {
ui->lockedWarning->setHidden(button->certificateInfo().cardActive);
ui->okButton->setEnabled(currentCommand == CommandType::AUTHENTICATE || button->certificateInfo().cardActive);
ui->okButton->setEnabled(currentCommand == CommandType::AUTHENTICATE
|| button->certificateInfo().cardActive);
}
ui->okButton->setFocus();
});
Expand Down Expand Up @@ -666,7 +667,8 @@ void WebEidDialog::setupPinPadProgressBarAndEmitWait(const EidCertificateAndPinI
void WebEidDialog::setupPinInput(const EidCertificateAndPinInfo& certAndPinInfo)
{
ui->lockedWarning->setHidden(certAndPinInfo.cardActive);
setupPinPrompt(certAndPinInfo.pinInfo, currentCommand == CommandType::AUTHENTICATE || certAndPinInfo.cardActive);
setupPinPrompt(certAndPinInfo.pinInfo,
currentCommand == CommandType::AUTHENTICATE || certAndPinInfo.cardActive);
// The allowed character ranges are from the SafeNet eToken guide:
// 1. English uppercase letters (ASCII 0x41...0x5A).
// 2. English lowercase letters (ASCII 0x61...0x7A).
Expand Down
Loading