Skip to content

Commit

Permalink
MOSIP-28970
Browse files Browse the repository at this point in the history
Signed-off-by: Pankaj Godiyal <[email protected]>
  • Loading branch information
pg-techno123 committed Nov 8, 2023
1 parent d6d0381 commit 22baf7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MockMDS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>io.mosip.mock.mds</groupId>
<artifactId>mock-mds</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.2-SNAPSHOT</version>
<name>mock-mds</name>
<description>A mock project for biometric provider</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String, PrivateKey> 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;
}
}

0 comments on commit 22baf7b

Please sign in to comment.