Skip to content

Commit

Permalink
SmartID support
Browse files Browse the repository at this point in the history
IB-5908

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Oct 22, 2019
1 parent 22b1ac3 commit 60fe2b5
Show file tree
Hide file tree
Showing 16 changed files with 810 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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( SMARTID_URL "https://sid.demo.sk.ee/smart-id-rp/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 @@ -547,6 +547,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 @@ -1020,6 +1023,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 @@ -84,6 +85,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 @@ -123,7 +126,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 )
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 @@ -499,6 +500,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 @@ -161,7 +161,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:
d->l.exit(Private::GeneralError);
Expand Down
47 changes: 47 additions & 0 deletions client/dialogs/SmartIDDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "SmartIDDialog.h"
#include "ui_SmartIDDialog.h"

#include "Settings.h"
#include "Styles.h"
#include "effects/Overlay.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);
ui->labelPhone->setFont(condensed12);
ui->idCode->setFont(condensed12);
ui->sign->setFont(condensed14);
ui->cancel->setFont(condensed14);
ui->idCode->setText(Settings(qApp->applicationName()).value(QStringLiteral("SmartID")).toString());
connect(ui->sign, &QPushButton::clicked, this, &QDialog::accept);
connect(ui->cancel, &QPushButton::clicked, this, &QDialog::reject);
connect(ui->idCode, &QLineEdit::textEdited, this, [](const QString &text){
Settings(qApp->applicationName()).setValueEx(QStringLiteral("SmartID"), text, QString());
});
}

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

QString SmartIDDialog::country() const
{
return QStringLiteral("EE");
}

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;
};
217 changes: 217 additions & 0 deletions client/dialogs/SmartIDDialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SmartIDDialog</class>
<widget class="QDialog" name="SmartIDDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Smart-ID</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog {
border-radius: 2px;
background-color: #FFFFFF;
}
QLineEdit, QComboBox {
padding: 0px 10px;
border: 1px solid #DEE4E9;
border-radius: 2px;
}</string>
</property>
<layout class="QVBoxLayout" name="SmartIDDialogLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>50</number>
</property>
<property name="topMargin">
<number>30</number>
</property>
<property name="rightMargin">
<number>50</number>
</property>
<property name="bottomMargin">
<number>30</number>
</property>
<item>
<spacer name="topSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>67</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelPhone">
<property name="font">
<font>
<family>Roboto Condensed</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #353739;</string>
</property>
<property name="text">
<string>Personal code</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="idCodeLayout" stretch="0,1">
<item>
<widget class="QComboBox" name="idCodeCountry">
<property name="minimumSize">
<size>
<width>0</width>
<height>34</height>
</size>
</property>
<item>
<property name="text">
<string notr="true">EE</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">LT</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">LV</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="idCode">
<property name="minimumSize">
<size>
<width>0</width>
<height>34</height>
</size>
</property>
<property name="placeholderText">
<string notr="true">47101010033</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="bottomSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>66</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<property name="spacing">
<number>40</number>
</property>
<item>
<widget class="QPushButton" name="cancel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border-radius: 2px;
border: none;
color: #ffffff;
background-color: #981E32;
}
QPushButton:pressed {
background-color: #F24A66;
}
QPushButton:hover:!pressed {
background-color: #CD2541;
}</string>
</property>
<property name="text">
<string>CANCEL</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sign">
<property name="minimumSize">
<size>
<width>120</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border-radius: 2px;
border: none;
color: #ffffff;
background-color: #006EB5;
}
QPushButton:pressed {
background-color: #41B6E6;
}
QPushButton:hover:!pressed {
background-color: #008DCF;
}
QPushButton:disabled {
background-color: #BEDBED;
}</string>
</property>
<property name="text">
<string>SIGN</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 60fe2b5

Please sign in to comment.