Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartID support #521

Merged
merged 1 commit into from
Dec 9, 2019
Merged
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ include_directories( ${LIBDIGIDOCPP_INCLUDE_DIR} )

set_env( TSL_URL "https://ec.europa.eu/tools/lotl/eu-lotl.xml" CACHE STRING "TSL trust list primary URL" )
set_env( TSL_INCLUDE "EE" CACHE STRING "TSL list include in binary" )
set_env( MOBILEID_URL "https://tsp.demo.sk.ee/mid-api" CACHE STRING "URL for Mobile-ID" )
set_env( MOBILEID_URL "https://dd-mid.ria.ee/mid-api" CACHE STRING "URL for Mobile-ID" )
set_env( SMARTID_URL "https://dd-sid.ria.ee/v1" CACHE STRING "URL for Smart-ID" )

if(APPLE)
set(BUNDLE_NAME qdigidoc4)
Expand Down
6 changes: 6 additions & 0 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ void Application::diagnostics(QTextStream &s)
<< "<br />SIVA_URL: " << confValue(SiVaUrl).toString()
#ifdef MOBILEID_URL
<< "<br />MOBILEID_URL: " << MOBILEID_URL
#endif
#ifdef SMARTID_URL
<< "<br />SMARTID_URL: " << SMARTID_URL
#endif
<< "<br /><br /><b>" << tr("TSL signing certs") << ":</b>";
for(const QSslCertificate &cert: confValue(TSLCerts).value<QList<QSslCertificate>>())
Expand Down Expand Up @@ -1029,6 +1032,9 @@ void DdCliApplication::diagnostics(QTextStream &s) const

#ifdef MOBILEID_URL
s << "<br />MOBILEID_URL: " << MOBILEID_URL;
#endif
#ifdef SMARTID_URL
s << "<br />SMARTID_URL: " << SMARTID_URL;
#endif
s << "<br />TSL_URL: " << Application::confValue(Application::TSLUrl).toString();
s << "<br /><br /><b>" << "TSL signing certs:</b>";
Expand Down
5 changes: 4 additions & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ qt5_wrap_ui( SOURCES
dialogs/RoleAddressDialog.ui
dialogs/SettingsDialog.ui
dialogs/SignatureDialog.ui
dialogs/SmartIDDialog.ui
dialogs/WaitDialog.ui
dialogs/WarningDialog.ui
widgets/Accordion.ui
Expand Down Expand Up @@ -86,6 +87,8 @@ add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE
dialogs/PinUnblock.cpp
dialogs/RoleAddressDialog.cpp
dialogs/SettingsDialog.cpp
dialogs/SmartIDDialog.cpp
dialogs/SmartIDProgress.cpp
dialogs/SignatureDialog.cpp
dialogs/WaitDialog.cpp
dialogs/WarningDialog.cpp
Expand Down Expand Up @@ -125,7 +128,7 @@ target_link_libraries( ${PROGNAME}
${LDAP_LIBRARIES}
)

target_compile_definitions(${PROGNAME} PRIVATE MOBILEID_URL="${MOBILEID_URL}")
target_compile_definitions(${PROGNAME} PRIVATE MOBILEID_URL="${MOBILEID_URL}" SMARTID_URL="${SMARTID_URL}" )

if( APPLE )
target_sources( ${PROGNAME} PRIVATE Application_mac.mm dialogs/CertificateDetails_mac.mm Diagnostics_unix.cpp)
Expand Down
9 changes: 9 additions & 0 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "dialogs/MobileProgress.h"
#include "dialogs/RoleAddressDialog.h"
#include "dialogs/SettingsDialog.h"
#include "dialogs/SmartIDProgress.h"
#include "dialogs/WaitDialog.h"
#include "dialogs/WarningDialog.h"
#include "widgets/WarningList.h"
Expand Down Expand Up @@ -498,6 +499,14 @@ void MainWindow::onSignAction(int action, const QString &info1, const QString &i
return digiDoc->sign(city, state, zip, country, role, &m);
});
break;
case SignatureSmartID:
sign([this, info1, info2](const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role) {
SmartIDProgress s(this);
if(!s.init(info1, info2))
return false;
return digiDoc->sign(city, state, zip, country, role, &s);
});
break;
case ClearSignatureWarning:
ui->signature->warningIcon(false);
warnings->closeWarnings(SignDetails);
Expand Down
1 change: 1 addition & 0 deletions client/common_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum Actions {

SignatureAdd,
SignatureMobile,
SignatureSmartID,
SignatureToken,
SignatureRemove,
SignatureWarning,
Expand Down
2 changes: 1 addition & 1 deletion client/dialogs/MobileProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ MobileProgress::MobileProgress(QWidget *parent)
returnError(tr("Connecting to SK server failed! Please check your internet connection."));
return;
case QNetworkReply::ConnectionRefusedError:
returnError(tr("Mobile-ID service has encountered technical errors. Please try again later."));
returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(tr("Mobile-ID")));
return;
case QNetworkReply::SslHandshakeFailedError:
returnError(tr("SSL handshake failed. Check the proxy settings of your computer or software upgrades."));
Expand Down
3 changes: 0 additions & 3 deletions client/dialogs/MobileProgress.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<height>185</height>
</size>
</property>
<property name="windowTitle">
<string>Signing with Mobile-ID</string>
</property>
<property name="styleSheet">
<string notr="true">border-radius: 2px;
background-color: #FFFFFF;</string>
Expand Down
80 changes: 80 additions & 0 deletions client/dialogs/SmartIDDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include "SmartIDDialog.h"
#include "ui_SmartIDDialog.h"

#include "Settings.h"
#include "Styles.h"
#include "effects/Overlay.h"

#include <common/IKValidator.h>

SmartIDDialog::SmartIDDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::SmartIDDialog)
{
Overlay *overlay = new Overlay(parent->topLevelWidget());
overlay->show();
connect(this, &SmartIDDialog::destroyed, overlay, &Overlay::deleteLater);

ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
setWindowModality( Qt::ApplicationModal);
setFixedSize(size());
QFont condensed12 = Styles::font(Styles::Condensed, 12);
QFont condensed14 = Styles::font(Styles::Condensed, 14);
QFont header = Styles::font(Styles::Regular, 14);
QFont regularFont = Styles::font(Styles::Regular, 14);
header.setWeight(QFont::DemiBold);
ui->cbRemember->setFont(Styles::font(Styles::Regular, 14));
ui->labelNameId->setFont(header);
ui->labelCode->setFont(condensed12);
ui->labelCountry->setFont(condensed12);
ui->idCode->setFont(regularFont);
ui->idCountry->setFont(regularFont);
ui->sign->setFont(condensed14);
ui->cancel->setFont(condensed14);

Settings s(qApp->applicationName());
QValidator *ik = new IKValidator(ui->idCode);
ui->idCode->setValidator(ik);
ui->idCode->setText(s.value(QStringLiteral("SmartID")).toString());
ui->idCountry->setItemData(0, "EE");
ui->idCountry->setItemData(1, "LT");
ui->idCountry->setItemData(2, "LV");
ui->idCountry->setCurrentIndex(ui->idCountry->findData(s.value(QStringLiteral("SmartIDCountry"), QStringLiteral("EE")).toString()));
ui->cbRemember->setChecked(s.value(QStringLiteral("SmartIDSettings"), true).toBool());
connect(ui->sign, &QPushButton::clicked, this, &QDialog::accept);
connect(ui->cancel, &QPushButton::clicked, this, &QDialog::reject);

auto enableSign = [=] {
const QString EE = QStringLiteral("EE");
ui->idCode->setValidator(country() == EE ? ik : nullptr);
bool checked = ui->cbRemember->isChecked();
Settings s(qApp->applicationName());
s.setValueEx(QStringLiteral("SmartIDSettings"), checked, true);
s.setValueEx(QStringLiteral("SmartID"), checked ? idCode() : QString(), QString());
s.setValueEx(QStringLiteral("SmartIDCountry"), checked ? country() : EE, EE);
ui->sign->setToolTip(QString());
if(!idCode().isEmpty() && country() == EE && !IKValidator::isValid(idCode()))
ui->sign->setToolTip(tr("Personal code is not valid"));
ui->sign->setEnabled(!idCode().isEmpty() && ui->sign->toolTip().isEmpty());
};
connect(ui->idCode, &QLineEdit::textEdited, this, enableSign);
connect(ui->idCountry, &QComboBox::currentTextChanged, this, enableSign);
connect(ui->cbRemember, &QCheckBox::clicked, this, enableSign);
enableSign();
}

SmartIDDialog::~SmartIDDialog()
{
delete ui;
}

QString SmartIDDialog::country() const
{
return ui->idCountry->currentData().toString();
}

QString SmartIDDialog::idCode() const
{
return ui->idCode->text();
}
20 changes: 20 additions & 0 deletions client/dialogs/SmartIDDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <QDialog>

namespace Ui { class SmartIDDialog; }

class SmartIDDialog : public QDialog
{
Q_OBJECT

public:
explicit SmartIDDialog(QWidget *parent = nullptr);
~SmartIDDialog() final;

QString country() const;
QString idCode() const;

private:
Ui::SmartIDDialog *ui;
};
Loading