Skip to content

Commit 70c2ed9

Browse files
committed
Make app windows resizable
- Add and update error path patches - Set windows title and icon - Update .desktop file - Get icon from repository (drop it from srpm) Signed-off-by: Luca Magrone <luca@magrone.cc>
1 parent 108aafa commit 70c2ed9

9 files changed

Lines changed: 1129 additions & 23 deletions
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 0764f206096a0964130c6edb4c7438e4642ee18d Mon Sep 17 00:00:00 2001
2+
From: Luca Magrone <luca@magrone.cc>
3+
Date: Fri, 1 Nov 2024 14:08:29 +0100
4+
Subject: [PATCH] cie-pkcs11: CSP: AbilitaCIE: fix error path
5+
6+
Currently the code tries to abilitate every token available. This might
7+
cause an error when it is not necessary.
8+
9+
Skip unrecognised tokens and stop at the first succesful abilitation.
10+
11+
Signed-off-by: Luca Magrone <luca@magrone.cc>
12+
---
13+
cie-pkcs11/CSP/AbilitaCIE.cpp | 17 ++++++++++++++++-
14+
1 file changed, 16 insertions(+), 1 deletion(-)
15+
16+
diff --git a/cie-pkcs11/CSP/AbilitaCIE.cpp b/cie-pkcs11/CSP/AbilitaCIE.cpp
17+
index 94fd225..d6032b6 100644
18+
--- a/cie-pkcs11/CSP/AbilitaCIE.cpp
19+
+++ b/cie-pkcs11/CSP/AbilitaCIE.cpp
20+
@@ -211,7 +211,17 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
21+
foundCIE = false;
22+
23+
ias.token.Reset();
24+
- ias.SelectAID_IAS();
25+
+ // Continue looking for CIE if the token is unrecognised
26+
+ try
27+
+ {
28+
+ ias.SelectAID_IAS();
29+
+ }
30+
+ catch(logged_error &err)
31+
+ {
32+
+ free(ATR);
33+
+ ATR = NULL;
34+
+ continue;
35+
+ }
36+
ias.ReadPAN();
37+
38+
39+
@@ -227,6 +237,8 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
40+
if (ias.IsEnrolled())
41+
{
42+
LOG_ERROR("AbbinaCIE - CIE already enabled. Serial number: %s\n", IdServizi.data());
43+
+ free(readers);
44+
+ free(ATR);
45+
return CARD_ALREADY_ENABLED;
46+
}
47+
48+
@@ -391,6 +403,9 @@ CK_RV CK_ENTRY AbilitaCIE(const char* szPAN, const char* szPIN, int* attempts,
49+
50+
std::string fullname = name + " " + surname;
51+
completedCallBack(span.c_str(), fullname.c_str(), st_serial.c_str());
52+
+
53+
+ // A this point a CIE has been found, stop looking for it
54+
+ break;
55+
}
56+
57+
if (!foundCIE) {
58+
--
59+
2.43.5
60+

cie-middleware-fix-FirmaConCIE-error-on-multiple-tokens.patch renamed to cie-middleware-FirmaConCIE-fix-error-path.patch

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
From 6a6063b122eea07acedd2af05b2213ec670170a6 Mon Sep 17 00:00:00 2001
2+
From: Luca Magrone <luca@magrone.cc>
3+
Date: Fri, 1 Nov 2024 15:48:20 +0100
4+
Subject: [PATCH] CSP: firmaConCIE: fix error path
5+
6+
Currently the code tries to make a signature with every token in every
7+
card reader. This way if there are multiple tokens (either CIEs or not)
8+
the signature can be completed but an error pops up to the user wich is bad
9+
UX. Furthermore if an unrecognised token or a wrong CIE is evaluated
10+
before the correct CIE the function fails, which should not.
11+
12+
Keep looking up for the correct CIE until all card readers are evaluated.
13+
Do not immediately fail if an unrecognised token is found.
14+
Fail on PAN mismatch only if the mismatch happens on every CIE.
15+
Stop looking if the correct CIE is found.
16+
17+
Also free allocated resources before returning.
18+
19+
Signed-off-by: Luca Magrone <luca@magrone.cc>
20+
---
21+
cie-pkcs11/CSP/FirmaConCIE.cpp | 45 +++++++++++++++++++++++++++++++---
22+
1 file changed, 41 insertions(+), 4 deletions(-)
23+
124
diff --git a/cie-pkcs11/CSP/FirmaConCIE.cpp b/cie-pkcs11/CSP/FirmaConCIE.cpp
2-
index 050d282..9f5bf6b 100644
25+
index 050d282..9e3b961 100644
326
--- a/cie-pkcs11/CSP/FirmaConCIE.cpp
427
+++ b/cie-pkcs11/CSP/FirmaConCIE.cpp
528
@@ -10,6 +10,7 @@
@@ -18,7 +41,7 @@ index 050d282..9f5bf6b 100644
1841
try
1942
{
2043
std::map<uint8_t, ByteDynArray> hashSet;
21-
@@ -96,12 +98,21 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
44+
@@ -96,12 +98,23 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
2245
IAS* ias = new IAS((CToken::TokenTransmitCallback)TokenTransmitCallback, atrBa);
2346
ias->SetCardContext(&conn);
2447

@@ -32,6 +55,8 @@ index 050d282..9f5bf6b 100644
3255
+ }
3356
+ catch(logged_error &err)
3457
+ {
58+
+ free(ATR);
59+
+ ATR = NULL;
3560
+ delete ias;
3661
+ continue;
3762
+ }
@@ -43,7 +68,7 @@ index 050d282..9f5bf6b 100644
4368
ByteDynArray IntAuth;
4469
ias->SelectAID_CIE();
4570
ias->ReadDappPubKey(IntAuth);
46-
@@ -112,9 +123,12 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
71+
@@ -112,9 +125,14 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
4772
ias->ReadIdServizi(IdServizi);
4873
ByteArray baPan = ByteArray((uint8_t*)pan, strlen(pan));
4974

@@ -52,26 +77,32 @@ index 050d282..9f5bf6b 100644
5277
{
5378
- return CARD_PAN_MISMATCH;
5479
+ panMismatch = true;
80+
+ free(ATR);
81+
+ ATR = NULL;
5582
+ delete ias;
5683
+ continue;
5784
}
5885

5986
ByteDynArray FullPIN;
60-
@@ -134,9 +148,13 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
87+
@@ -134,9 +152,17 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
6188
uint16_t ret = cieSign->sign(inFilePath, type, fullPinCStr, page, x, y, w, h, imagePathFile, outFilePath);
6289
if((ret & (0x63C0)) == 0x63C0)
6390
{
91+
+ free(readers);
92+
+ free(ATR);
6493
+ delete ias;
6594
+ delete cieSign;
6695
return CKR_PIN_INCORRECT;
6796
}else if (ret == 0x6983)
6897
{
98+
+ free(readers);
99+
+ free(ATR);
69100
+ delete ias;
70101
+ delete cieSign;
71102
return CKR_PIN_LOCKED;
72103
}
73104

74-
@@ -148,7 +166,14 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
105+
@@ -148,7 +174,14 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
75106
delete ias;
76107
delete cieSign;
77108

@@ -86,7 +117,7 @@ index 050d282..9f5bf6b 100644
86117
}
87118

88119
if (!foundCIE) {
89-
@@ -174,5 +199,9 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
120+
@@ -174,5 +207,9 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
90121
free(ATR);
91122

92123
free(readers);
@@ -96,3 +127,6 @@ index 050d282..9f5bf6b 100644
96127
+
97128
return SCARD_S_SUCCESS;
98129
}
130+
--
131+
2.43.5
132+

cie-middleware-FirmaConCIE-make-progress-more-uniform.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 5a32e804c99655dc0c9a8c303e6597fac7014424 Mon Sep 17 00:00:00 2001
1+
From f49a29963144307fa72f3f3f2e4cf05c98e0b429 Mon Sep 17 00:00:00 2001
22
From: Luca Magrone <luca@magrone.cc>
3-
Date: Sat, 26 Oct 2024 19:11:40 +0200
4-
Subject: [PATCH] CSP: firmaConCIE: make progress bar more uniform
3+
Date: Sat, 26 Oct 2024 19:16:20 +0200
4+
Subject: [PATCH] CSP: firmaConCIE: make progress more uniform
55

66
Divide the progress of the progress bar into 4 chunks. Each one
77
corresponding to 25% of the total progress.
@@ -12,7 +12,7 @@ Signed-off-by: Luca Magrone <luca@magrone.cc>
1212
1 file changed, 7 insertions(+), 4 deletions(-)
1313

1414
diff --git a/cie-pkcs11/CSP/FirmaConCIE.cpp b/cie-pkcs11/CSP/FirmaConCIE.cpp
15-
index 9f5bf6b..c044c5f 100644
15+
index 9e3b961..15b5257 100644
1616
--- a/cie-pkcs11/CSP/FirmaConCIE.cpp
1717
+++ b/cie-pkcs11/CSP/FirmaConCIE.cpp
1818
@@ -71,6 +71,9 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
@@ -34,7 +34,7 @@ index 9f5bf6b..c044c5f 100644
3434
IAS* ias = new IAS((CToken::TokenTransmitCallback)TokenTransmitCallback, atrBa);
3535
ias->SetCardContext(&conn);
3636

37-
@@ -130,14 +131,16 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
37+
@@ -134,14 +135,16 @@ CK_RV CK_ENTRY firmaConCIE(const char* inFilePath, const char* type, const char*
3838
delete ias;
3939
continue;
4040
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From eeab052be40b9dbb90b260bf3b1efb955615333a Mon Sep 17 00:00:00 2001
2+
From: Luca Magrone <luca@magrone.cc>
3+
Date: Fri, 1 Nov 2024 14:32:07 +0100
4+
Subject: [PATCH] cie-pkcs11: CSP: PINManager: fix error path
5+
6+
Currently the code tries to perform operations on the PIN of every
7+
available token. This leads to error thrown at the user if multiple
8+
token are present in the system.
9+
10+
Skip unrecognised tokens and stop at the first succesfult PIN operation.
11+
12+
Signed-off-by: Luca Magrone <luca@magrone.cc>
13+
---
14+
cie-pkcs11/CSP/PINManager.cpp | 30 ++++++++++++++++++++++++++++--
15+
1 file changed, 28 insertions(+), 2 deletions(-)
16+
17+
diff --git a/cie-pkcs11/CSP/PINManager.cpp b/cie-pkcs11/CSP/PINManager.cpp
18+
index 8bc2ce0..4c3fbf7 100644
19+
--- a/cie-pkcs11/CSP/PINManager.cpp
20+
+++ b/cie-pkcs11/CSP/PINManager.cpp
21+
@@ -118,7 +118,17 @@ CK_RV CK_ENTRY CambioPIN(const char* szCurrentPIN, const char* szNewPIN, int*
22+
ias.attemptsRemaining = -1;
23+
24+
ias.token.Reset();
25+
- ias.SelectAID_IAS();
26+
+ // Continue looking for CIE if the token is unrecognised
27+
+ try
28+
+ {
29+
+ ias.SelectAID_IAS();
30+
+ }
31+
+ catch(logged_error &err)
32+
+ {
33+
+ free(ATR);
34+
+ ATR = NULL;
35+
+ continue;
36+
+ }
37+
ias.ReadPAN();
38+
39+
progressCallBack(20, "Lettura dati dalla CIE");
40+
@@ -204,6 +214,9 @@ CK_RV CK_ENTRY CambioPIN(const char* szCurrentPIN, const char* szNewPIN, int*
41+
42+
progressCallBack(100, "Cambio PIN eseguito");
43+
LOG_INFO("******** PINManager::ChangePIN Completed ********");
44+
+
45+
+ // A this point a CIE has been found, stop looking for it
46+
+ break;
47+
}
48+
49+
if (!foundCIE) {
50+
@@ -308,7 +321,17 @@ CK_RV CK_ENTRY SbloccoPIN(const char* szPUK, const char* szNewPIN, int* pAttem
51+
ias.attemptsRemaining = -1;
52+
53+
ias.token.Reset();
54+
- ias.SelectAID_IAS();
55+
+ // Continue looking for CIE if the token is unrecognised
56+
+ try
57+
+ {
58+
+ ias.SelectAID_IAS();
59+
+ }
60+
+ catch(logged_error &err)
61+
+ {
62+
+ free(ATR);
63+
+ ATR = NULL;
64+
+ continue;
65+
+ }
66+
ias.ReadPAN();
67+
68+
progressCallBack(30, "Lettura dati dalla CIE");
69+
@@ -394,6 +417,9 @@ CK_RV CK_ENTRY SbloccoPIN(const char* szPUK, const char* szNewPIN, int* pAttem
70+
71+
progressCallBack(100, "Sblocco carta eseguito");
72+
LOG_INFO("******** PINManager::UnlockPIN Completed ********");
73+
+
74+
+ // A this point a CIE has been found, stop looking for it
75+
+ break;
76+
}
77+
78+
if (!foundCIE) {
79+
--
80+
2.43.5
81+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
From af0de22d6509eba48d9daad5b6c2b30f548f96b0 Mon Sep 17 00:00:00 2001
2+
From: Luca Magrone <luca@magrone.cc>
3+
Date: Sun, 3 Nov 2024 15:22:11 +0100
4+
Subject: [PATCH] CIEID: Set JFrame icon and Title
5+
6+
Signed-off-by: Luca Magrone <luca@magrone.cc>
7+
---
8+
CIEID/src/it/ipzs/cieid/IntroFrame.java | 11 +++++++++++
9+
CIEID/src/it/ipzs/cieid/MainFrame.java | 10 ++++++++++
10+
2 files changed, 21 insertions(+)
11+
12+
diff --git a/CIEID/src/it/ipzs/cieid/IntroFrame.java b/CIEID/src/it/ipzs/cieid/IntroFrame.java
13+
index 4866ede..6b64425 100644
14+
--- a/CIEID/src/it/ipzs/cieid/IntroFrame.java
15+
+++ b/CIEID/src/it/ipzs/cieid/IntroFrame.java
16+
@@ -2,6 +2,7 @@ package it.ipzs.cieid;
17+
18+
import java.awt.BorderLayout;
19+
import java.awt.EventQueue;
20+
+import java.awt.Image;
21+
import java.awt.event.WindowAdapter;
22+
import java.awt.event.WindowEvent;
23+
24+
@@ -59,6 +60,16 @@ public class IntroFrame extends JFrame {
25+
* Create the frame.
26+
*/
27+
public IntroFrame() {
28+
+ try
29+
+ {
30+
+ Image logoCircle = ImageIO.read(MainFrame.class.getResource("/it/ipzs/cieid/res/logo_circle.png"));
31+
+ setIconImage(logoCircle);
32+
+ }
33+
+ catch(IOException e)
34+
+ {
35+
+ e.printStackTrace();
36+
+ }
37+
+ setTitle("Benvenuto in CIE ID");
38+
setResizable(false);
39+
setBackground(Color.WHITE);
40+
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
41+
diff --git a/CIEID/src/it/ipzs/cieid/MainFrame.java b/CIEID/src/it/ipzs/cieid/MainFrame.java
42+
index f1ea5ef..d764f36 100644
43+
--- a/CIEID/src/it/ipzs/cieid/MainFrame.java
44+
+++ b/CIEID/src/it/ipzs/cieid/MainFrame.java
45+
@@ -413,6 +413,16 @@ public class MainFrame extends JFrame {
46+
contentPane.add(leftPanel);
47+
leftPanel.setLayout(null);
48+
JLabel label_2 = new JLabel("");
49+
+ try
50+
+ {
51+
+ Image logoCircle = ImageIO.read(MainFrame.class.getResource("/it/ipzs/cieid/res/logo_circle.png"));
52+
+ setIconImage(logoCircle);
53+
+ }
54+
+ catch(IOException e)
55+
+ {
56+
+ e.printStackTrace();
57+
+ }
58+
+ setTitle("CIE ID");
59+
60+
try {
61+
label_2.setIcon(new ImageIcon(Utils.scaleimage(80, 80, ImageIO.read(MainFrame.class.getResource("/it/ipzs/cieid/res/Logo_Cie_ID_Windowed@2x.png")))));
62+
--
63+
2.43.5
64+

0 commit comments

Comments
 (0)