Skip to content
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
1 change: 1 addition & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ qt_add_translations(${PROJECT_NAME} TS_FILES
../common/translations/qtbase_et.ts
../common/translations/qtbase_ru.ts
RESOURCE_PREFIX /translations
LUPDATE_OPTIONS -locations none
)
qt_add_resources(${PROJECT_NAME} tsl BASE ${TSL_DIR} PREFIX /TSL FILES ${TSL_LIST})

Expand Down
5 changes: 3 additions & 2 deletions client/QPKCS11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ QPKCS11::PinStatus QPKCS11::login(const TokenData &t)
if(token.flags & CKF_USER_PIN_FINAL_TRY) f = PinPopup::PinFinalTry;
if(token.flags & CKF_PROTECTED_AUTHENTICATION_PATH)
{
PinPopup p(isSign ? PinPopup::Pin2PinpadType : PinPopup::Pin1PinpadType, cert, f, Application::mainWindow());
f |= PinPopup::PinpadFlag;
PinPopup p(isSign ? QSmartCardData::Pin2Type : QSmartCardData::Pin1Type, f, cert, Application::mainWindow());
std::thread([&err, &p, this] {
emit p.startTimer();
err = d->f->C_Login(d->session, CKU_USER, nullptr, 0);
Expand All @@ -230,7 +231,7 @@ QPKCS11::PinStatus QPKCS11::login(const TokenData &t)
}
else
{
PinPopup p(isSign ? PinPopup::Pin2Type : PinPopup::Pin1Type, cert, f, Application::mainWindow());
PinPopup p(isSign ? QSmartCardData::Pin2Type : QSmartCardData::Pin1Type, f, cert, Application::mainWindow());
p.setPinLen(token.ulMinPinLen, token.ulMaxPinLen < 12 ? 12 : token.ulMaxPinLen);
if( !p.exec() )
return PinCanceled;
Expand Down
33 changes: 16 additions & 17 deletions client/QSmartCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,15 @@ QSmartCard::ErrorType QSmartCard::pinChange(QSmartCardData::PinType type, QSmart
}
else
{
SslCertificate cert = d->t.authCert();
QString title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
PinPopup::PinFlags flags = {};
switch(type)
PinPopup::TokenFlags flags = PinPopup::PinpadChangeFlag;
switch(d->t.retryCount(type))
{
case QSmartCardData::Pin1Type: flags = PinPopup::Pin1Type; break;
case QSmartCardData::Pin2Type: flags = PinPopup::Pin2Type; break;
case QSmartCardData::PukType: flags = PinPopup::PukType; break;
default: return UnknownError;
case 2: flags |= PinPopup::PinCountLow; break;
case 1: flags |= PinPopup::PinFinalTry; break;
case 0: flags |= PinPopup::PinLocked; break;
default: break;
}
popup.reset(new PinPopup(PinPopup::PinFlags(flags|PinPopup::PinpadChangeFlag), title, {}, parent,
popup.reset(new PinPopup(type, flags, d->t.authCert(), parent,
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))));
popup->open();
}
Expand All @@ -579,8 +577,6 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, QSmar
}
else
{
SslCertificate cert = d->t.authCert();
QString title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber"));
QString bodyText;
switch(action)
{
Expand All @@ -594,14 +590,17 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, QSmar
default:
break;
}
PinPopup::PinFlags flags = {};
switch(type)
if(type == QSmartCardData::PukType)
return UnknownError;
PinPopup::TokenFlags flags = PinPopup::PinpadChangeFlag;
switch(d->t.retryCount(QSmartCardData::PukType))
{
case QSmartCardData::Pin1Type: flags = PinPopup::Pin1Type; break;
case QSmartCardData::Pin2Type: flags = PinPopup::Pin2Type; break;
default: return UnknownError;
case 2: flags |= PinPopup::PinCountLow; break;
case 1: flags |= PinPopup::PinFinalTry; break;
case 0: flags |= PinPopup::PinLocked; break;
default: break;
}
popup.reset(new PinPopup(PinPopup::PinFlags(flags|PinPopup::PinpadChangeFlag), title, {}, parent, bodyText));
popup.reset(new PinPopup(QSmartCardData::PukType, flags, d->t.authCert(), parent, bodyText));
popup->open();
}

Expand Down
32 changes: 14 additions & 18 deletions client/dialogs/PinPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@
#include <QtWidgets/QPushButton>
#include <QSvgWidget>

PinPopup::PinPopup(PinFlags flags, const SslCertificate &c, TokenFlags count, QWidget *parent)
: PinPopup(flags, c.toString(c.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")), count, parent)
{
if(c.type() & SslCertificate::TempelType)
{
regexp->setRegularExpression(QRegularExpression(QStringLiteral("^.{4,}$")));
ui->pin->setMaxLength(32767);
}
}

PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidget *parent, QString text)
PinPopup::PinPopup(QSmartCardData::PinType type, TokenFlags flags, const SslCertificate &c, QWidget *parent, QString text)
: QDialog(parent)
, ui(new Ui::PinPopup)
{
Expand All @@ -60,7 +50,7 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg

if(!text.isEmpty())
ui->labelPin->hide();
else if( flags & Pin2Type )
else if(type == QSmartCardData::Pin2Type)
{
text = tr("Selected action requires sign certificate.");
ui->labelPin->setText(flags & PinpadFlag ?
Expand All @@ -76,12 +66,12 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
tr("For using authentication certificate enter PIN1"));
setPinLen(4);
}
ui->label->setText(title);
ui->label->setText(c.toString(c.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")));
ui->text->setText(text);
if(count & PinFinalTry)
ui->errorPin->setText(tr("PIN will be locked next failed attempt"));
else if(count & PinCountLow)
ui->errorPin->setText(tr("PIN has been entered incorrectly at least once"));
if(flags & PinFinalTry)
ui->errorPin->setText(tr("%1 will be locked next failed attempt").arg(QSmartCardData::typeString(type)));
else if(flags & PinCountLow)
ui->errorPin->setText(tr("%1 has been entered incorrectly at least once").arg(QSmartCardData::typeString(type)));
else
ui->errorPin->hide();

Expand All @@ -90,12 +80,13 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
ui->pin->hide();
ui->ok->hide();
ui->cancel->hide();
ui->errorPin->setAlignment(Qt::AlignCenter);
auto *movie = new QSvgWidget(QStringLiteral(":/images/wait.svg"), this);
movie->setFixedSize(ui->pin->size().height(), ui->pin->size().height());
movie->show();
ui->layoutContent->addWidget(movie, 0, Qt::AlignCenter);
}
if( flags & PinpadFlag )
else if(flags & PinpadFlag)
{
ui->pin->hide();
ui->ok->hide();
Expand Down Expand Up @@ -123,6 +114,11 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg
ui->text->setBuddy( ui->pin );
ui->ok->setDisabled(true);
}
if(c.type() & SslCertificate::TempelType)
{
regexp->setRegularExpression(QRegularExpression(QStringLiteral("^.{4,}$")));
ui->pin->setMaxLength(32767);
}
}

PinPopup::~PinPopup()
Expand Down
23 changes: 7 additions & 16 deletions client/dialogs/PinPopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <QDialog>

#include "QSmartCard.h"
#include "WaitDialog.h"

namespace Ui {
Expand All @@ -35,27 +36,17 @@ class PinPopup final : public QDialog
Q_OBJECT

public:
enum PinFlags
{
Pin1Type = 0,
Pin2Type = 1 << 0,
PukType = 1 << 1,
PinpadFlag = 1 << 2,
PinpadChangeFlag = 1 << 4,
Pin1PinpadType = Pin1Type|PinpadFlag,
Pin2PinpadType = Pin2Type|PinpadFlag,
PukPinpadType = PukType|PinpadFlag
};
enum TokenFlag
{
PinCountLow = (1<<1),
PinFinalTry = (1<<2),
PinLocked = (1<<3)
PinCountLow = 1<<1,
PinFinalTry = 1<<2,
PinLocked = 1<<3,
PinpadFlag = 1 << 4,
PinpadChangeFlag = 1 << 5,
};
Q_DECLARE_FLAGS(TokenFlags, TokenFlag)

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

void setPinLen(unsigned long minLen, unsigned long maxLen = 12);
Expand Down
16 changes: 8 additions & 8 deletions client/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1755,14 +1755,6 @@ ID-Card</translation>
</context>
<context>
<name>PinPopup</name>
<message>
<source>PIN will be locked next failed attempt</source>
<translation>PIN will be locked next failed attempt</translation>
</message>
<message>
<source>PIN has been entered incorrectly at least once</source>
<translation>PIN has been entered incorrectly at least once</translation>
</message>
<message>
<source>For using sign certificate enter PIN2 at the reader</source>
<translation>For using sign certificate enter PIN2 at the reader</translation>
Expand All @@ -1783,6 +1775,14 @@ ID-Card</translation>
<source>For using authentication certificate enter PIN1</source>
<translation>For using authentication certificate enter PIN1</translation>
</message>
<message>
<source>%1 will be locked next failed attempt</source>
<translation>%1 will be locked next failed attempt</translation>
</message>
<message>
<source>%1 has been entered incorrectly at least once</source>
<translation>%1 has been entered incorrectly at least once</translation>
</message>
<message>
<source>Selected action requires authentication certificate.</source>
<translation>Selected action requires authentication certificate.</translation>
Expand Down
16 changes: 8 additions & 8 deletions client/translations/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1755,14 +1755,6 @@ ID-kaardiga</translation>
</context>
<context>
<name>PinPopup</name>
<message>
<source>PIN will be locked next failed attempt</source>
<translation>Vale koodi sisestamisel PIN lukustub</translation>
</message>
<message>
<source>PIN has been entered incorrectly at least once</source>
<translation>PIN on vähemalt ühe korra valesti sisestatud</translation>
</message>
<message>
<source>For using sign certificate enter PIN2 at the reader</source>
<translation>Sertifikaadi kasutamiseks sisesta PIN2 kaardilugeja sõrmistikult</translation>
Expand All @@ -1783,6 +1775,14 @@ ID-kaardiga</translation>
<source>For using authentication certificate enter PIN1</source>
<translation>Sertifikaadi kasutamiseks sisesta PIN1</translation>
</message>
<message>
<source>%1 will be locked next failed attempt</source>
<translation>Vale koodi sisestamisel %1 lukustub</translation>
</message>
<message>
<source>%1 has been entered incorrectly at least once</source>
<translation>%1 on vähemalt ühe korra valesti sisestatud</translation>
</message>
<message>
<source>Selected action requires authentication certificate.</source>
<translation>Valitud tegevuse jaoks on vaja kasutada isikutuvastuse sertifikaati.</translation>
Expand Down
16 changes: 8 additions & 8 deletions client/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1756,14 +1756,6 @@ ID-картой</translation>
</context>
<context>
<name>PinPopup</name>
<message>
<source>PIN will be locked next failed attempt</source>
<translation>PIN будет заблокирован при следующей неудачной попытке</translation>
</message>
<message>
<source>PIN has been entered incorrectly at least once</source>
<translation>По меньшей мере один раз был введен неправильный PIN</translation>
</message>
<message>
<source>For using sign certificate enter PIN2 at the reader</source>
<translation>Для использования сертификата цифровой подписи введите PIN2&lt;br/&gt;с клавиатуры считывателя</translation>
Expand All @@ -1784,6 +1776,14 @@ ID-картой</translation>
<source>For using authentication certificate enter PIN1</source>
<translation>Для использования сертификата идентификации введите PIN1</translation>
</message>
<message>
<source>%1 will be locked next failed attempt</source>
<translation>%1 будет заблокирован при следующей неудачной попытке</translation>
</message>
<message>
<source>%1 has been entered incorrectly at least once</source>
<translation>По меньшей мере один раз был введен неправильный %1</translation>
</message>
<message>
<source>Selected action requires authentication certificate.</source>
<translation>Данная операция требует сертификат идентификации.</translation>
Expand Down
Loading