Skip to content

Commit 88c3c6c

Browse files
committed
feat(cards): add support for MS CryptoAPI tokens
WE2-716 Signed-off-by: Mart Somermaa <[email protected]>
1 parent ad1fc5b commit 88c3c6c

File tree

13 files changed

+133
-64
lines changed

13 files changed

+133
-64
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ src/app/web-eid
1616
tests-build/
1717
tests/tests/web-eid-tests
1818
build-web-eid-*/
19+
CMakeSettings.json
20+
.vs/

src/controller/command-handlers/certificatereader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ void CertificateReader::run(const std::vector<CardInfo::ptr>& cards)
8585
std::vector<CardCertificateAndPinInfo> certInfos;
8686
certInfos.reserve(cards.size());
8787
for (const auto& card : cards) {
88-
certInfos.emplace_back(getCertificateWithStatusAndInfo(card, certificateType));
88+
try {
89+
certInfos.push_back(getCertificateWithStatusAndInfo(card, certificateType));
90+
} catch (const WrongCertificateTypeError&) {
91+
// Ignore eIDs that don't support the given ceritifcate type.
92+
}
8993
}
9094

9195
if (certInfos.empty()) {

src/controller/command-handlers/sign.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ QPair<QString, QVariantMap> signHash(const ElectronicID& eid, const pcsc_cpp::by
4848

4949
Sign::Sign(const CommandWithArguments& cmd) : CertificateReader(cmd)
5050
{
51-
const auto arguments = cmd.second;
51+
const auto& arguments = cmd.second;
5252

5353
requireArgumentsAndOptionalLang(
5454
{"hash", "hashFunction", "certificate", "origin"}, arguments,
@@ -119,7 +119,9 @@ QVariantMap Sign::onConfirm(WebEidUI* window, const CardCertificateAndPinInfo& c
119119
default:
120120
emit verifyPinFailed(failure.status(), failure.retries());
121121
}
122-
if (failure.retries() > 0) {
122+
// Retries > 0 means that there are retries remaining,
123+
// < 0 means that retry count is unknown, == 0 means that the PIN is blocked.
124+
if (failure.retries() != 0) {
123125
throw CommandHandlerVerifyPinFailed(failure.what());
124126
}
125127
throw;

src/controller/inputoutputmode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
#include <QJsonDocument>
2626
#include <QJsonObject>
2727

28-
#ifdef _WIN32
28+
#ifdef Q_OS_WIN
2929
#include <stdio.h>
3030
#include <io.h>
3131
#include <fcntl.h>
3232
#endif
3333

34-
#ifdef _WIN32
34+
#ifdef Q_OS_WIN
3535
// On Windows, the default I/O mode is O_TEXT. Set this to O_BINARY
3636
// to avoid unwanted modifications of the input/output streams.
3737
// See http://msdn.microsoft.com/en-us/library/tw4k6df8.aspx
@@ -64,7 +64,7 @@ void writeResponseLength(std::ostream& stream, const uint32_t responseLength)
6464
CommandWithArgumentsPtr readCommandFromStdin()
6565
{
6666

67-
#ifdef _WIN32
67+
#ifdef Q_OS_WIN
6868
setIoStreamsToBinaryMode();
6969
#endif
7070

src/controller/utils.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424

2525
#include "pcsc-cpp/pcsc-cpp-utils.hpp"
2626

27-
#define REQUIRE_NON_NULL(val) \
28-
if (!val) { \
29-
throw std::logic_error("Null " + std::string(#val) + " in " \
30-
+ pcsc_cpp::removeAbsolutePathPrefix(__FILE__) + ':' \
31-
+ std::to_string(__LINE__) + ':' + __func__); \
32-
}
33-
3427
#define REQUIRE_NOT_EMPTY_CONTAINS_NON_NULL_PTRS(vec) \
3528
if (vec.empty()) { \
3629
throw std::logic_error(std::string(#vec) + " is empty in " \

src/ui/translations/en.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@
171171
<source>The card in the reader is not supported. Make sure that the entered ID-card is supported by the Web eID application.</source>
172172
<translation>The card in the reader is not supported. Make sure that the entered ID-card is supported by the Web eID application.</translation>
173173
</message>
174-
<message>
175-
<source>The certificates of the ID-card have expired. Valid certificates are required for the electronic use of the ID-card.</source>
176-
<translation>The certificates of the ID-card have expired. Valid certificates are required for the electronic use of the ID-card.</translation>
177-
</message>
178174
<message>
179175
<source>Unknown error</source>
180176
<translation>Unknown error</translation>
@@ -259,5 +255,17 @@
259255
<source>The certificate of the ID card in the reader does not match the originally submitted certificate. Please insert the original ID card.</source>
260256
<translation>The certificate of the ID card in the reader does not match the originally submitted certificate. Please insert the original ID card.</translation>
261257
</message>
258+
<message>
259+
<source>The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation.</source>
260+
<translation>The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation.</translation>
261+
</message>
262+
<message>
263+
<source>Please enter PIN for authentication in the PIN dialog window that opens.</source>
264+
<translation>Please enter PIN for authentication in the PIN dialog window that opens.</translation>
265+
</message>
266+
<message>
267+
<source>Please enter PIN for signing in the PIN dialog window that opens.</source>
268+
<translation>Please enter PIN for signing in the PIN dialog window that opens.</translation>
269+
</message>
262270
</context>
263271
</TS>

src/ui/translations/et.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@
167167
<source>The card in the reader is not supported. Make sure that the entered ID-card is supported by the Web eID application.</source>
168168
<translation>Lugejas on mittetoetatud kaart. Palun veendu, et sisestatud ID-kaart on Web eID rakenduses toetatud.</translation>
169169
</message>
170-
<message>
171-
<source>The certificates of the ID-card have expired. Valid certificates are required for the electronic use of the ID-card.</source>
172-
<translation>ID-kaardi sertifikaadid on aegunud. ID-kaardi elektrooniliseks kasutamiseks on vaja kehtivaid sertifikaate.</translation>
173-
</message>
174170
<message>
175171
<source>Unknown error</source>
176172
<translation>Tundmatu viga</translation>
@@ -259,5 +255,17 @@
259255
<source>The certificate of the ID card in the reader does not match the originally submitted certificate. Please insert the original ID card.</source>
260256
<translation>Lugejas oleva ID-kaardi sertifikaat ei ühti algselt esitatud sertifikaadiga. Palun sisesta algne ID-kaart.</translation>
261257
</message>
258+
<message>
259+
<source>The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation.</source>
260+
<translation>Sisestatud ID-kaardil ei ole sertifikaati soovitud toimingu jaoks. Palun sisestage soovitud toimingut toetav ID-kaart.</translation>
261+
</message>
262+
<message>
263+
<source>Please enter PIN for authentication in the PIN dialog window that opens.</source>
264+
<translation>Palun sisesta avanevas PIN-dialoogiaknas isikutuvastuseks PIN-kood.</translation>
265+
</message>
266+
<message>
267+
<source>Please enter PIN for signing in the PIN dialog window that opens.</source>
268+
<translation>Palun sisesta avanevas PIN-dialoogiaknas allkirjastamiseks PIN-kood.</translation>
269+
</message>
262270
</context>
263271
</TS>

src/ui/translations/fi.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@
183183
<source>By signing, I agree to the transfer of my name and personal identification code to the service provider.</source>
184184
<translation>Kirjautumalla suostun antamaan nimeni ja henkilötunnukseni palveluntarjoajalle.</translation>
185185
</message>
186-
<message>
187-
<source>The certificates of the ID-card have expired. Valid certificates are required for the electronic use of the ID-card.</source>
188-
<translation>Henkilökortin varmenteet ovat vanhentuneet. Varmenteiden tulee olla voimassa, jotta henkilökorttia voi käyttää sähköisesti.</translation>
189-
</message>
190186
<message>
191187
<source>An error occurred in the Smart Card service required to use the ID-card. Make sure that the ID-card and the card reader are connected correctly or relaunch the Smart Card service.</source>
192188
<translation>Henkilökortin käyttöön vaadittavassa älykorttipalvelussa tapahtui virhe. Varmista, että henkilökortti ja kortinlukija on kytketty oikein tai käynnistä älykorttipalvelu uudelleen.</translation>
@@ -259,5 +255,17 @@
259255
<source>The certificate of the ID card in the reader does not match the originally submitted certificate. Please insert the original ID card.</source>
260256
<translation>Lukijassa oleva henkilökortin varmenne ei vastaa alun perin lähetettyä varmennetta. Aseta alkuperäinen henkilökortti kortinlukijaan.</translation>
261257
</message>
258+
<message>
259+
<source>The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation.</source>
260+
<translation type="unfinished">Asennettu henkilökortti ei sisällä varmennetta pyydettyä toimintoa varten. Aseta sisään henkilökortti, joka tukee pyydettyä toimintoa.</translation>
261+
</message>
262+
<message>
263+
<source>Please enter PIN for authentication in the PIN dialog window that opens.</source>
264+
<translation type="unfinished">Syötä PIN todennusta varten avautuvaan PIN-valintaikkunaan.</translation>
265+
</message>
266+
<message>
267+
<source>Please enter PIN for signing in the PIN dialog window that opens.</source>
268+
<translation type="unfinished">Syötä PIN kirjautumista varten avautuvaan PIN-valintaikkunaan.</translation>
269+
</message>
262270
</context>
263271
</TS>

src/ui/translations/hr.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</message>
4848
<message>
4949
<source>Get help here: &lt;a href=&quot;https://www.id.ee&quot;&gt;id.ee&lt;/a&gt;</source>
50-
<translation type="unfinished"></translation>
50+
<translation>Pomoć potražite ovdje: &lt;a href=&quot;https://www.id.ee&quot;&gt;id.ee&lt;/a&gt;</translation>
5151
</message>
5252
<message>
5353
<source>Select a certificate</source>
@@ -249,10 +249,6 @@
249249
<source>The card in the reader is not supported. Make sure that the entered ID-card is supported by the Web eID application.</source>
250250
<translation>Osobna iskaznica u čitaču nije podržana. Provjerite je li umetnuta osobna iskaznica podržana od strane Web eID aplikacije.</translation>
251251
</message>
252-
<message>
253-
<source>The certificates of the ID-card have expired. Valid certificates are required for the electronic use of the ID-card.</source>
254-
<translation>Vjerodajnica na osobnoj iskaznici je istekla. Valjana osobna iskaznica je neophodna za elektroničku uporabu.</translation>
255-
</message>
256252
<message>
257253
<source>Operation failed. Make sure that the driver of the corresponding card reader is used. Read more &lt;a href=&quot;https://www.id.ee/en/article/using-pinpad-card-reader-drivers/&quot;&gt;here&lt;/a&gt;.</source>
258254
<translation>Radnja nije uspjela. Provjerite koristi li se ispravan pokretački program za osobnu iskaznicu. Pročitajte više o tome na &lt;a href=&quot;https://www.id.ee/en/article/using-pinpad-card-reader-drivers/&quot;&gt;ovdje&lt;/a&gt;.</translation>
@@ -261,5 +257,17 @@
261257
<source>Unknown error</source>
262258
<translation>Nepoznata greška</translation>
263259
</message>
260+
<message>
261+
<source>The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation.</source>
262+
<translation type="unfinished">Umetnuta iskaznica ne sadrži potvrdu za traženu operaciju. Molimo umetnite osobnu iskaznicu koja podržava traženu operaciju.</translation>
263+
</message>
264+
<message>
265+
<source>Please enter PIN for authentication in the PIN dialog window that opens.</source>
266+
<translation type="unfinished">Unesite PIN za autentifikaciju u dijaloški prozor PIN-a koji se otvara.</translation>
267+
</message>
268+
<message>
269+
<source>Please enter PIN for signing in the PIN dialog window that opens.</source>
270+
<translation type="unfinished">Unesite PIN za prijavu u dijaloški prozor PIN-a koji se otvara.</translation>
271+
</message>
264272
</context>
265273
</TS>

0 commit comments

Comments
 (0)