2929 * @modules jdk.crypto.cryptoki/sun.security.pkcs11
3030 * @run main/othervm
3131 * -DCUSTOM_P11_CONFIG=${test.src}/MultipleLogins-nss.txt
32- * -DCUSTOM_DB_DIR=${test.src}
32+ * -DCUSTOM_DB_DIR=./nss/db
3333 * MultipleLogins
3434 */
3535
4545
4646import java .io .IOException ;
4747import java .lang .ref .WeakReference ;
48+ import java .nio .file .Files ;
49+ import java .nio .file .Path ;
4850import java .nio .file .Paths ;
4951import java .nio .file .StandardCopyOption ;
5052import java .security .*;
@@ -60,18 +62,25 @@ public class MultipleLogins {
6062
6163 private static void copyDbFiles () throws IOException {
6264 final var testFolder = System .getProperty ("test.src" , "." );
63- final var destination = Paths .get (testFolder );
65+ final var srcDbFolder = Paths .get (testFolder ).getParent ().resolve ("nss" , "db" );
66+
67+ // Getting path & creating the temporary scratch directory ./nss/db
68+ final var nssFolder = Path .of ("." ).resolve ("nss" );
69+ Files .createDirectory (nssFolder );
70+ final var destination = nssFolder .resolve ("db" );
71+
6472 final var sourceFiles = List .of (
65- Paths . get ( testFolder + "/../nss/db/ cert9.db" ),
66- Paths . get ( testFolder + "/../nss/db/ key4.db" ),
67- Paths . get ( testFolder + "/../nss/db/ cert8.db" ),
68- Paths . get ( testFolder + "/../nss/db/ key3.db" )
73+ srcDbFolder . resolve ( " cert9.db" ),
74+ srcDbFolder . resolve ( " key4.db" ),
75+ srcDbFolder . resolve ( " cert8.db" ),
76+ srcDbFolder . resolve ( " key3.db" )
6977 );
7078
71- final var list = Utils .copyFiles (sourceFiles , destination , StandardCopyOption .REPLACE_EXISTING );
79+ final var copiedFiles = Utils .copyFiles (sourceFiles , destination , StandardCopyOption .REPLACE_EXISTING );
80+ copiedFiles .forEach (path -> path .toFile ().setWritable (true ));
7281
7382 System .out .println ("NSS db files copied to: " );
74- list .forEach (System .out ::println );
83+ copiedFiles .forEach (System .out ::println );
7584 }
7685
7786 public static void main (String [] args ) throws Exception {
0 commit comments