From 22baf7b1f4c1a6a5aeb40499512132a34be14420 Mon Sep 17 00:00:00 2001 From: Pankaj Godiyal Date: Wed, 8 Nov 2023 12:35:31 +0530 Subject: [PATCH 1/4] MOSIP-28970 Signed-off-by: Pankaj Godiyal --- MockMDS/pom.xml | 2 +- .../sbi/devicehelper/SBIDeviceHelper.java | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/MockMDS/pom.xml b/MockMDS/pom.xml index 447d9bdd..1502147a 100644 --- a/MockMDS/pom.xml +++ b/MockMDS/pom.xml @@ -12,7 +12,7 @@ io.mosip.mock.mds mock-mds - 1.2.1-SNAPSHOT + 1.2.2-SNAPSHOT mock-mds A mock project for biometric provider diff --git a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java index 7d2e180e..eb397fc0 100644 --- a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java +++ b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java @@ -10,6 +10,7 @@ import java.security.cert.X509Certificate; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -818,8 +819,22 @@ private void loadKeys(String keyStoreFileName, String alias, String keystorePass * To be invoked in afterSuite * @param keystoreFilePath */ - public static void evictKeys(String keystoreFilePath) { - privateKeyMap.entrySet().removeIf( e -> e.getKey().startsWith(keystoreFilePath)); - certificateMap.entrySet().removeIf( e -> e.getKey().startsWith(keystoreFilePath)); + + + public static boolean evictKeys(String keystoreFilePath) { + boolean bKeyFound = false; + for (Entry entry : privateKeyMap.entrySet()) { + if (entry.getKey().startsWith(keystoreFilePath)) { + bKeyFound = true; + break; + } + } + if (bKeyFound == false) + return true; // No key to remove + boolean bRetVal = privateKeyMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); + if (bRetVal) { + bRetVal = certificateMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); + } + return bRetVal; } } From dc222aff762929cf58687026fd58f543dda9b1df Mon Sep 17 00:00:00 2001 From: Pankaj Godiyal Date: Wed, 8 Nov 2023 12:50:07 +0530 Subject: [PATCH 2/4] MOSIP-28970 Signed-off-by: Pankaj Godiyal --- MockMDS/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MockMDS/pom.xml b/MockMDS/pom.xml index 1502147a..447d9bdd 100644 --- a/MockMDS/pom.xml +++ b/MockMDS/pom.xml @@ -12,7 +12,7 @@ io.mosip.mock.mds mock-mds - 1.2.2-SNAPSHOT + 1.2.1-SNAPSHOT mock-mds A mock project for biometric provider From 29711da626fffd4bcf2a47396ebfeb27f1bb69cb Mon Sep 17 00:00:00 2001 From: Pankaj Godiyal Date: Thu, 9 Nov 2023 15:52:42 +0530 Subject: [PATCH 3/4] MOSIP-28970 Signed-off-by: Pankaj Godiyal --- .../mock/sbi/devicehelper/SBIDeviceHelper.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java index eb397fc0..a9276d05 100644 --- a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java +++ b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java @@ -821,20 +821,8 @@ private void loadKeys(String keyStoreFileName, String alias, String keystorePass */ - public static boolean evictKeys(String keystoreFilePath) { - boolean bKeyFound = false; - for (Entry entry : privateKeyMap.entrySet()) { - if (entry.getKey().startsWith(keystoreFilePath)) { - bKeyFound = true; - break; - } - } - if (bKeyFound == false) - return true; // No key to remove - boolean bRetVal = privateKeyMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); - if (bRetVal) { - bRetVal = certificateMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); - } - return bRetVal; + public static synchronized void evictKeys(String keystoreFilePath) { + privateKeyMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); + certificateMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); } } From 4bbccd2bfe5249d74140e7dcdd486bc835d6024a Mon Sep 17 00:00:00 2001 From: Pankaj Godiyal Date: Thu, 16 Nov 2023 11:32:50 +0530 Subject: [PATCH 4/4] MOSIP-28970 Signed-off-by: Pankaj Godiyal --- .../io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java index a9276d05..afd4f590 100644 --- a/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java +++ b/MockMDS/src/main/java/io/mosip/mock/sbi/devicehelper/SBIDeviceHelper.java @@ -818,11 +818,11 @@ private void loadKeys(String keyStoreFileName, String alias, String keystorePass /** * To be invoked in afterSuite * @param keystoreFilePath + * This method is not thread safe */ - - public static synchronized void evictKeys(String keystoreFilePath) { + public static void evictKeys(String keystoreFilePath) { privateKeyMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); - certificateMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); + certificateMap.entrySet().removeIf(e -> e.getKey().startsWith(keystoreFilePath)); } }