mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-24 04:54:40 +02:00
8012971: PKCS11Test hiding exception failures
Reviewed-by: vinnie, valeriep
This commit is contained in:
parent
ea8bc25763
commit
a7dbbbddcd
3 changed files with 45 additions and 11 deletions
|
@ -255,6 +255,23 @@ sun/rmi/transport/proxy/EagerHttpFallback.java generic-all
|
||||||
|
|
||||||
# jdk_security
|
# jdk_security
|
||||||
|
|
||||||
|
# 8012971 PKCS11Test hiding exception failures
|
||||||
|
sun/security/pkcs11/KeyStore/SecretKeysBasic.java solaris-all
|
||||||
|
sun/security/pkcs11/KeyStore/SecretKeysBasic.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestCurves.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestCurves.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestECDH.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestECDH2.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestECDH2.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestECDSA.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestECDSA.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestECDSA2.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestECDSA2.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestECGenSpec.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestECGenSpec.java linux-all
|
||||||
|
sun/security/pkcs11/ec/TestKeyFactory.java solaris-all
|
||||||
|
sun/security/pkcs11/ec/TestKeyFactory.java linux-all
|
||||||
|
|
||||||
# 7164518: no PortUnreachableException on Mac
|
# 7164518: no PortUnreachableException on Mac
|
||||||
sun/security/krb5/auto/Unreachable.java macosx-all
|
sun/security/krb5/auto/Unreachable.java macosx-all
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -54,6 +54,11 @@ public abstract class PKCS11Test {
|
||||||
|
|
||||||
static String NSPR_PREFIX = "";
|
static String NSPR_PREFIX = "";
|
||||||
|
|
||||||
|
// The NSS library we need to search for in getNSSLibDir()
|
||||||
|
// Default is "libsoftokn3.so", listed as "softokn3"
|
||||||
|
// The other is "libnss3.so", listed as "nss3".
|
||||||
|
static String nss_library = "softokn3";
|
||||||
|
|
||||||
static Provider getSunPKCS11(String config) throws Exception {
|
static Provider getSunPKCS11(String config) throws Exception {
|
||||||
Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");
|
Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");
|
||||||
Constructor cons = clazz.getConstructor(new Class[] {String.class});
|
Constructor cons = clazz.getConstructor(new Class[] {String.class});
|
||||||
|
@ -79,24 +84,28 @@ public abstract class PKCS11Test {
|
||||||
testNSS(test);
|
testNSS(test);
|
||||||
testDeimos(test);
|
testDeimos(test);
|
||||||
} finally {
|
} finally {
|
||||||
|
// NOTE: Do not place a 'return' in any finally block
|
||||||
|
// as it will suppress exceptions and hide test failures.
|
||||||
Provider[] newProviders = Security.getProviders();
|
Provider[] newProviders = Security.getProviders();
|
||||||
|
boolean found = true;
|
||||||
// Do not restore providers if nothing changed. This is especailly
|
// Do not restore providers if nothing changed. This is especailly
|
||||||
// useful for ./Provider/Login.sh, where a SecurityManager exists.
|
// useful for ./Provider/Login.sh, where a SecurityManager exists.
|
||||||
if (oldProviders.length == newProviders.length) {
|
if (oldProviders.length == newProviders.length) {
|
||||||
boolean found = false;
|
found = false;
|
||||||
for (int i = 0; i<oldProviders.length; i++) {
|
for (int i = 0; i<oldProviders.length; i++) {
|
||||||
if (oldProviders[i] != newProviders[i]) {
|
if (oldProviders[i] != newProviders[i]) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) return;
|
|
||||||
}
|
}
|
||||||
for (Provider p: newProviders) {
|
if (found) {
|
||||||
Security.removeProvider(p.getName());
|
for (Provider p: newProviders) {
|
||||||
}
|
Security.removeProvider(p.getName());
|
||||||
for (Provider p: oldProviders) {
|
}
|
||||||
Security.addProvider(p);
|
for (Provider p: oldProviders) {
|
||||||
|
Security.addProvider(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +187,8 @@ public abstract class PKCS11Test {
|
||||||
}
|
}
|
||||||
String nssLibDir = null;
|
String nssLibDir = null;
|
||||||
for (String dir : nssLibDirs) {
|
for (String dir : nssLibDirs) {
|
||||||
if (new File(dir).exists()) {
|
if (new File(dir).exists() &&
|
||||||
|
new File(dir + System.mapLibraryName(nss_library)).exists()) {
|
||||||
nssLibDir = dir;
|
nssLibDir = dir;
|
||||||
System.setProperty("pkcs11test.nss.libdir", nssLibDir);
|
System.setProperty("pkcs11test.nss.libdir", nssLibDir);
|
||||||
break;
|
break;
|
||||||
|
@ -207,6 +217,11 @@ public abstract class PKCS11Test {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to set the nss_library file to search for libsoftokn3.so
|
||||||
|
public static void useNSS() {
|
||||||
|
nss_library = "nss3";
|
||||||
|
}
|
||||||
|
|
||||||
public static void testNSS(PKCS11Test test) throws Exception {
|
public static void testNSS(PKCS11Test test) throws Exception {
|
||||||
String libdir = getNSSLibDir();
|
String libdir = getNSSLibDir();
|
||||||
if (libdir == null) {
|
if (libdir == null) {
|
||||||
|
@ -218,7 +233,7 @@ public abstract class PKCS11Test {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String libfile = libdir + System.mapLibraryName("softokn3");
|
String libfile = libdir + System.mapLibraryName(nss_library);
|
||||||
|
|
||||||
String customDBdir = System.getProperty("CUSTOM_DB_DIR");
|
String customDBdir = System.getProperty("CUSTOM_DB_DIR");
|
||||||
String dbdir = (customDBdir != null) ?
|
String dbdir = (customDBdir != null) ?
|
||||||
|
@ -252,7 +267,8 @@ public abstract class PKCS11Test {
|
||||||
osMap.put("Linux-i386-32", new String[]{
|
osMap.put("Linux-i386-32", new String[]{
|
||||||
"/usr/lib/i386-linux-gnu/", "/usr/lib/"});
|
"/usr/lib/i386-linux-gnu/", "/usr/lib/"});
|
||||||
osMap.put("Linux-amd64-64", new String[]{
|
osMap.put("Linux-amd64-64", new String[]{
|
||||||
"/usr/lib/x86_64-linux-gnu/", "/usr/lib64/"});
|
"/usr/lib/x86_64-linux-gnu/", "/usr/lib/x86_64-linux-gnu/nss/",
|
||||||
|
"/usr/lib64/"});
|
||||||
osMap.put("Windows-x86-32", new String[]{
|
osMap.put("Windows-x86-32", new String[]{
|
||||||
PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)});
|
PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)});
|
||||||
osMap.put("Windows-amd64-64", new String[]{
|
osMap.put("Windows-amd64-64", new String[]{
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class SecmodTest extends PKCS11Test {
|
||||||
static String keyAlias = "mykey";
|
static String keyAlias = "mykey";
|
||||||
|
|
||||||
static boolean initSecmod() throws Exception {
|
static boolean initSecmod() throws Exception {
|
||||||
|
useNSS();
|
||||||
LIBPATH = getNSSLibDir();
|
LIBPATH = getNSSLibDir();
|
||||||
if (LIBPATH == null) {
|
if (LIBPATH == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue