Skip to content

Commit d086099

Browse files
authored
Show additional info about PIN in PinPAD progress window (#1374)
IB-8748 Signed-off-by: Raul Metsma <[email protected]>
1 parent 3ef4484 commit d086099

File tree

8 files changed

+65
-77
lines changed

8 files changed

+65
-77
lines changed

client/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ qt_add_translations(${PROJECT_NAME} TS_FILES
102102
../common/translations/qtbase_et.ts
103103
../common/translations/qtbase_ru.ts
104104
RESOURCE_PREFIX /translations
105+
LUPDATE_OPTIONS -locations none
105106
)
106107
qt_add_resources(${PROJECT_NAME} tsl BASE ${TSL_DIR} PREFIX /TSL FILES ${TSL_LIST})
107108

client/QPKCS11.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ QPKCS11::PinStatus QPKCS11::login(const TokenData &t)
220220
if(token.flags & CKF_USER_PIN_FINAL_TRY) f = PinPopup::PinFinalTry;
221221
if(token.flags & CKF_PROTECTED_AUTHENTICATION_PATH)
222222
{
223-
PinPopup p(isSign ? PinPopup::Pin2PinpadType : PinPopup::Pin1PinpadType, cert, f, Application::mainWindow());
223+
f |= PinPopup::PinpadFlag;
224+
PinPopup p(isSign ? QSmartCardData::Pin2Type : QSmartCardData::Pin1Type, f, cert, Application::mainWindow());
224225
std::thread([&err, &p, this] {
225226
emit p.startTimer();
226227
err = d->f->C_Login(d->session, CKU_USER, nullptr, 0);
@@ -230,7 +231,7 @@ QPKCS11::PinStatus QPKCS11::login(const TokenData &t)
230231
}
231232
else
232233
{
233-
PinPopup p(isSign ? PinPopup::Pin2Type : PinPopup::Pin1Type, cert, f, Application::mainWindow());
234+
PinPopup p(isSign ? QSmartCardData::Pin2Type : QSmartCardData::Pin1Type, f, cert, Application::mainWindow());
234235
p.setPinLen(token.ulMinPinLen, token.ulMaxPinLen < 12 ? 12 : token.ulMaxPinLen);
235236
if( !p.exec() )
236237
return PinCanceled;

client/QSmartCard.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -543,17 +543,15 @@ QSmartCard::ErrorType QSmartCard::pinChange(QSmartCardData::PinType type, QSmart
543543
}
544544
else
545545
{
546-
SslCertificate cert = d->t.authCert();
547-
QString title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
548-
PinPopup::PinFlags flags = {};
549-
switch(type)
546+
PinPopup::TokenFlags flags = PinPopup::PinpadChangeFlag;
547+
switch(d->t.retryCount(type))
550548
{
551-
case QSmartCardData::Pin1Type: flags = PinPopup::Pin1Type; break;
552-
case QSmartCardData::Pin2Type: flags = PinPopup::Pin2Type; break;
553-
case QSmartCardData::PukType: flags = PinPopup::PukType; break;
554-
default: return UnknownError;
549+
case 2: flags |= PinPopup::PinCountLow; break;
550+
case 1: flags |= PinPopup::PinFinalTry; break;
551+
case 0: flags |= PinPopup::PinLocked; break;
552+
default: break;
555553
}
556-
popup.reset(new PinPopup(PinPopup::PinFlags(flags|PinPopup::PinpadChangeFlag), title, {}, parent,
554+
popup.reset(new PinPopup(type, flags, d->t.authCert(), parent,
557555
tr("To change %1 on a PinPad reader the old %1 code has to be entered first and then the new %1 code twice.").arg(QSmartCardData::typeString(type))));
558556
popup->open();
559557
}
@@ -579,8 +577,6 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, QSmar
579577
}
580578
else
581579
{
582-
SslCertificate cert = d->t.authCert();
583-
QString title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
584580
QString bodyText;
585581
switch(action)
586582
{
@@ -594,14 +590,17 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, QSmar
594590
default:
595591
break;
596592
}
597-
PinPopup::PinFlags flags = {};
598-
switch(type)
593+
if(type == QSmartCardData::PukType)
594+
return UnknownError;
595+
PinPopup::TokenFlags flags = PinPopup::PinpadChangeFlag;
596+
switch(d->t.retryCount(QSmartCardData::PukType))
599597
{
600-
case QSmartCardData::Pin1Type: flags = PinPopup::Pin1Type; break;
601-
case QSmartCardData::Pin2Type: flags = PinPopup::Pin2Type; break;
602-
default: return UnknownError;
598+
case 2: flags |= PinPopup::PinCountLow; break;
599+
case 1: flags |= PinPopup::PinFinalTry; break;
600+
case 0: flags |= PinPopup::PinLocked; break;
601+
default: break;
603602
}
604-
popup.reset(new PinPopup(PinPopup::PinFlags(flags|PinPopup::PinpadChangeFlag), title, {}, parent, bodyText));
603+
popup.reset(new PinPopup(QSmartCardData::PukType, flags, d->t.authCert(), parent, bodyText));
605604
popup->open();
606605
}
607606

client/dialogs/PinPopup.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@
2929
#include <QtWidgets/QPushButton>
3030
#include <QSvgWidget>
3131

32-
PinPopup::PinPopup(PinFlags flags, const SslCertificate &c, TokenFlags count, QWidget *parent)
33-
: PinPopup(flags, c.toString(c.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")), count, parent)
34-
{
35-
if(c.type() & SslCertificate::TempelType)
36-
{
37-
regexp->setRegularExpression(QRegularExpression(QStringLiteral("^.{4,}$")));
38-
ui->pin->setMaxLength(32767);
39-
}
40-
}
41-
42-
PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidget *parent, QString text)
32+
PinPopup::PinPopup(QSmartCardData::PinType type, TokenFlags flags, const SslCertificate &c, QWidget *parent, QString text)
4333
: QDialog(parent)
4434
, ui(new Ui::PinPopup)
4535
{
@@ -60,7 +50,7 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
6050

6151
if(!text.isEmpty())
6252
ui->labelPin->hide();
63-
else if( flags & Pin2Type )
53+
else if(type == QSmartCardData::Pin2Type)
6454
{
6555
text = tr("Selected action requires sign certificate.");
6656
ui->labelPin->setText(flags & PinpadFlag ?
@@ -76,12 +66,12 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
7666
tr("For using authentication certificate enter PIN1"));
7767
setPinLen(4);
7868
}
79-
ui->label->setText(title);
69+
ui->label->setText(c.toString(c.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")));
8070
ui->text->setText(text);
81-
if(count & PinFinalTry)
82-
ui->errorPin->setText(tr("PIN will be locked next failed attempt"));
83-
else if(count & PinCountLow)
84-
ui->errorPin->setText(tr("PIN has been entered incorrectly at least once"));
71+
if(flags & PinFinalTry)
72+
ui->errorPin->setText(tr("%1 will be locked next failed attempt").arg(QSmartCardData::typeString(type)));
73+
else if(flags & PinCountLow)
74+
ui->errorPin->setText(tr("%1 has been entered incorrectly at least once").arg(QSmartCardData::typeString(type)));
8575
else
8676
ui->errorPin->hide();
8777

@@ -90,12 +80,13 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
9080
ui->pin->hide();
9181
ui->ok->hide();
9282
ui->cancel->hide();
83+
ui->errorPin->setAlignment(Qt::AlignCenter);
9384
auto *movie = new QSvgWidget(QStringLiteral(":/images/wait.svg"), this);
9485
movie->setFixedSize(ui->pin->size().height(), ui->pin->size().height());
9586
movie->show();
9687
ui->layoutContent->addWidget(movie, 0, Qt::AlignCenter);
9788
}
98-
if( flags & PinpadFlag )
89+
else if(flags & PinpadFlag)
9990
{
10091
ui->pin->hide();
10192
ui->ok->hide();
@@ -123,6 +114,11 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
123114
ui->text->setBuddy( ui->pin );
124115
ui->ok->setDisabled(true);
125116
}
117+
if(c.type() & SslCertificate::TempelType)
118+
{
119+
regexp->setRegularExpression(QRegularExpression(QStringLiteral("^.{4,}$")));
120+
ui->pin->setMaxLength(32767);
121+
}
126122
}
127123

128124
PinPopup::~PinPopup()

client/dialogs/PinPopup.h

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <QDialog>
2323

24+
#include "QSmartCard.h"
2425
#include "WaitDialog.h"
2526

2627
namespace Ui {
@@ -35,27 +36,17 @@ class PinPopup final : public QDialog
3536
Q_OBJECT
3637

3738
public:
38-
enum PinFlags
39-
{
40-
Pin1Type = 0,
41-
Pin2Type = 1 << 0,
42-
PukType = 1 << 1,
43-
PinpadFlag = 1 << 2,
44-
PinpadChangeFlag = 1 << 4,
45-
Pin1PinpadType = Pin1Type|PinpadFlag,
46-
Pin2PinpadType = Pin2Type|PinpadFlag,
47-
PukPinpadType = PukType|PinpadFlag
48-
};
4939
enum TokenFlag
5040
{
51-
PinCountLow = (1<<1),
52-
PinFinalTry = (1<<2),
53-
PinLocked = (1<<3)
41+
PinCountLow = 1<<1,
42+
PinFinalTry = 1<<2,
43+
PinLocked = 1<<3,
44+
PinpadFlag = 1 << 4,
45+
PinpadChangeFlag = 1 << 5,
5446
};
5547
Q_DECLARE_FLAGS(TokenFlags, TokenFlag)
5648

57-
PinPopup(PinFlags flags, const SslCertificate &cert, TokenFlags count, QWidget *parent = {});
58-
PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidget *parent = {}, QString text = {});
49+
PinPopup(QSmartCardData::PinType type, TokenFlags flags, const SslCertificate &cert, QWidget *parent = {}, QString text = {});
5950
~PinPopup() final;
6051

6152
void setPinLen(unsigned long minLen, unsigned long maxLen = 12);

client/translations/en.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,14 +1755,6 @@ ID-Card</translation>
17551755
</context>
17561756
<context>
17571757
<name>PinPopup</name>
1758-
<message>
1759-
<source>PIN will be locked next failed attempt</source>
1760-
<translation>PIN will be locked next failed attempt</translation>
1761-
</message>
1762-
<message>
1763-
<source>PIN has been entered incorrectly at least once</source>
1764-
<translation>PIN has been entered incorrectly at least once</translation>
1765-
</message>
17661758
<message>
17671759
<source>For using sign certificate enter PIN2 at the reader</source>
17681760
<translation>For using sign certificate enter PIN2 at the reader</translation>
@@ -1783,6 +1775,14 @@ ID-Card</translation>
17831775
<source>For using authentication certificate enter PIN1</source>
17841776
<translation>For using authentication certificate enter PIN1</translation>
17851777
</message>
1778+
<message>
1779+
<source>%1 will be locked next failed attempt</source>
1780+
<translation>%1 will be locked next failed attempt</translation>
1781+
</message>
1782+
<message>
1783+
<source>%1 has been entered incorrectly at least once</source>
1784+
<translation>%1 has been entered incorrectly at least once</translation>
1785+
</message>
17861786
<message>
17871787
<source>Selected action requires authentication certificate.</source>
17881788
<translation>Selected action requires authentication certificate.</translation>

client/translations/et.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,14 +1755,6 @@ ID-kaardiga</translation>
17551755
</context>
17561756
<context>
17571757
<name>PinPopup</name>
1758-
<message>
1759-
<source>PIN will be locked next failed attempt</source>
1760-
<translation>Vale koodi sisestamisel PIN lukustub</translation>
1761-
</message>
1762-
<message>
1763-
<source>PIN has been entered incorrectly at least once</source>
1764-
<translation>PIN on vähemalt ühe korra valesti sisestatud</translation>
1765-
</message>
17661758
<message>
17671759
<source>For using sign certificate enter PIN2 at the reader</source>
17681760
<translation>Sertifikaadi kasutamiseks sisesta PIN2 kaardilugeja sõrmistikult</translation>
@@ -1783,6 +1775,14 @@ ID-kaardiga</translation>
17831775
<source>For using authentication certificate enter PIN1</source>
17841776
<translation>Sertifikaadi kasutamiseks sisesta PIN1</translation>
17851777
</message>
1778+
<message>
1779+
<source>%1 will be locked next failed attempt</source>
1780+
<translation>Vale koodi sisestamisel %1 lukustub</translation>
1781+
</message>
1782+
<message>
1783+
<source>%1 has been entered incorrectly at least once</source>
1784+
<translation>%1 on vähemalt ühe korra valesti sisestatud</translation>
1785+
</message>
17861786
<message>
17871787
<source>Selected action requires authentication certificate.</source>
17881788
<translation>Valitud tegevuse jaoks on vaja kasutada isikutuvastuse sertifikaati.</translation>

client/translations/ru.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,14 +1756,6 @@ ID-картой</translation>
17561756
</context>
17571757
<context>
17581758
<name>PinPopup</name>
1759-
<message>
1760-
<source>PIN will be locked next failed attempt</source>
1761-
<translation>PIN будет заблокирован при следующей неудачной попытке</translation>
1762-
</message>
1763-
<message>
1764-
<source>PIN has been entered incorrectly at least once</source>
1765-
<translation>По меньшей мере один раз был введен неправильный PIN</translation>
1766-
</message>
17671759
<message>
17681760
<source>For using sign certificate enter PIN2 at the reader</source>
17691761
<translation>Для использования сертификата цифровой подписи введите PIN2&lt;br/&gt;с клавиатуры считывателя</translation>
@@ -1784,6 +1776,14 @@ ID-картой</translation>
17841776
<source>For using authentication certificate enter PIN1</source>
17851777
<translation>Для использования сертификата идентификации введите PIN1</translation>
17861778
</message>
1779+
<message>
1780+
<source>%1 will be locked next failed attempt</source>
1781+
<translation>%1 будет заблокирован при следующей неудачной попытке</translation>
1782+
</message>
1783+
<message>
1784+
<source>%1 has been entered incorrectly at least once</source>
1785+
<translation>По меньшей мере один раз был введен неправильный %1</translation>
1786+
</message>
17871787
<message>
17881788
<source>Selected action requires authentication certificate.</source>
17891789
<translation>Данная операция требует сертификат идентификации.</translation>

0 commit comments

Comments
 (0)