|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
22 | 22 | */
|
23 | 23 |
|
24 | 24 | /*
|
25 |
| - * see ./DKSTest.sh |
| 25 | + * @test |
| 26 | + * @bug 8007755 |
| 27 | + * @library /test/lib |
| 28 | + * @summary Support the logical grouping of keystores |
26 | 29 | */
|
27 | 30 |
|
28 | 31 | import java.io.*;
|
29 | 32 | import java.net.*;
|
| 33 | +import java.nio.file.Paths; |
30 | 34 | import java.security.*;
|
31 | 35 | import java.security.KeyStore;
|
32 | 36 | import java.security.cert.*;
|
33 | 37 | import java.security.cert.Certificate;
|
34 | 38 | import java.util.*;
|
| 39 | +import jdk.test.lib.process.ProcessTools; |
| 40 | +import jdk.test.lib.process.OutputAnalyzer; |
35 | 41 |
|
36 | 42 | // Load and store entries in domain keystores
|
37 | 43 |
|
38 | 44 | public class DKSTest {
|
39 | 45 |
|
40 | 46 | private static final String TEST_SRC = System.getProperty("test.src");
|
41 |
| - private static final String USER_DIR = System.getProperty("user.dir"); |
42 |
| - private static final String CERT = TEST_SRC + "/../../pkcs12/trusted.pem"; |
43 |
| - private static final String CONFIG = "file://" + TEST_SRC + "/domains.cfg"; |
| 47 | + private static final String USER_DIR = System.getProperty("user.dir", "."); |
| 48 | + private static final String CERT = Paths.get( |
| 49 | + TEST_SRC, "..", "..", "pkcs12", "trusted.pem").toAbsolutePath().toString(); |
| 50 | + private static final String CONFIG = Paths.get( |
| 51 | + TEST_SRC, "domains.cfg").toUri().toString(); |
44 | 52 | private static final Map<String, KeyStore.ProtectionParameter> PASSWORDS =
|
45 | 53 | new HashMap<String, KeyStore.ProtectionParameter>() {{
|
46 | 54 | put("keystore",
|
@@ -74,6 +82,18 @@ public class DKSTest {
|
74 | 82 | }};
|
75 | 83 |
|
76 | 84 | public static void main(String[] args) throws Exception {
|
| 85 | + if (args.length == 0) { |
| 86 | + // Environment variable and system properties referred in domains.cfg used by this Test. |
| 87 | + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(List.of( |
| 88 | + "-Dtest.src=" + TEST_SRC , "-Duser.dir=" + USER_DIR, "DKSTest", "run")); |
| 89 | + pb.environment().putAll(System.getenv()); |
| 90 | + pb.environment().put("KEYSTORE_PWD", "test12"); |
| 91 | + pb.environment().put("TRUSTSTORE_PWD", "changeit"); |
| 92 | + OutputAnalyzer output = ProcessTools.executeProcess(pb); |
| 93 | + output.shouldHaveExitValue(0); |
| 94 | + output.outputTo(System.out); |
| 95 | + return; |
| 96 | + } |
77 | 97 | /*
|
78 | 98 | * domain keystore: keystores with wrong passwords
|
79 | 99 | */
|
|
0 commit comments