author | jjiang |
Wed, 15 Aug 2018 18:41:18 +0800 | |
changeset 51460 | 97e361fe3433 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
1 |
/* |
51460
97e361fe3433
8164639: Configure PKCS11 tests to use user-supplied NSS libraries
jjiang
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
4 |
* |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
8 |
* |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
13 |
* accompanied this code). |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
14 |
* |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
18 |
* |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
21 |
* questions. |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
22 |
*/ |
40975
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
32423
diff
changeset
|
23 |
/* |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
24 |
* @test |
32423
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
25 |
* @bug 7003952 7191662 |
51460
97e361fe3433
8164639: Configure PKCS11 tests to use user-supplied NSS libraries
jjiang
parents:
47216
diff
changeset
|
26 |
* @library /test/lib .. |
43248
5e15de85a1a0
8172527: Rename jdk.crypto.token to jdk.crypto.cryptoki
ascarpino
parents:
42693
diff
changeset
|
27 |
* @modules jdk.crypto.cryptoki |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
28 |
* @summary load DLLs and launch executables using fully qualified path |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
29 |
*/ |
40975
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
32423
diff
changeset
|
30 |
|
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
32423
diff
changeset
|
31 |
import java.security.InvalidParameterException; |
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
32423
diff
changeset
|
32 |
import java.security.Provider; |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
33 |
|
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
34 |
public class Absolute { |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
35 |
|
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
36 |
public static void main(String[] args) throws Exception { |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
37 |
String config = |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
38 |
System.getProperty("test.src", ".") + "/Absolute.cfg"; |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
39 |
|
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
40 |
try { |
32423
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
41 |
Provider p = PKCS11Test.getSunPKCS11(config); |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
42 |
if (p == null) { |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
43 |
System.out.println("Skipping test - no PKCS11 provider available"); |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
44 |
} |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
45 |
} catch (InvalidParameterException ipe) { |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
46 |
Throwable ex = ipe.getCause(); |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
47 |
if (ex.getMessage().indexOf( |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
48 |
"Absolute path required for library value:") != -1) { |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
49 |
System.out.println("Test Passed: expected exception thrown"); |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
50 |
} else { |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
51 |
// rethrow |
2342600f2ada
8133801: sun/security/pkcs11/Provider/ConfigShortPath.java failed in jigsaw nightly at Windows
valeriep
parents:
10894
diff
changeset
|
52 |
throw ipe; |
9849
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
53 |
} |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
54 |
} |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
55 |
} |
eb437e9fba66
7003952: SEC: securely load DLLs and launch executables using fully qualified path
valeriep
parents:
diff
changeset
|
56 |
} |