diff --git a/jdk/src/share/classes/sun/security/pkcs11/Secmod.java b/jdk/src/share/classes/sun/security/pkcs11/Secmod.java index a872739563f..de4d12ef33f 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/Secmod.java +++ b/jdk/src/share/classes/sun/security/pkcs11/Secmod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -405,7 +405,16 @@ public final class Secmod { + "module: " + libraryName + ", " + commonName); } } - this.libraryName = (new File(libraryDir, libraryName)).getPath(); + // On Ubuntu the libsoftokn3 library is located in a subdirectory + // of the system libraries directory. (Since Ubuntu 11.04.) + File libraryFile = new File(libraryDir, libraryName); + if (!libraryFile.isFile()) { + File failover = new File(libraryDir, "nss/" + libraryName); + if (failover.isFile()) { + libraryFile = failover; + } + } + this.libraryName = libraryFile.getPath(); this.commonName = commonName; this.slot = slot; this.type = type; diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java index 3fc5d86f423..deb7302a2da 100644 --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java @@ -167,17 +167,23 @@ public abstract class PKCS11Test { } String osid = osName + "-" + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); - String nssLibDir = osMap.get(osid); - if (nssLibDir == null) { + String[] nssLibDirs = osMap.get(osid); + if (nssLibDirs == null) { System.out.println("Unsupported OS, skipping: " + osid); return null; -// throw new Exception("Unsupported OS " + osName); } - if (nssLibDir.length() == 0) { + if (nssLibDirs.length == 0) { System.out.println("NSS not supported on this platform, skipping test"); return null; } - System.setProperty("pkcs11test.nss.libdir", nssLibDir); + String nssLibDir = null; + for (String dir : nssLibDirs) { + if (new File(dir).exists()) { + nssLibDir = dir; + System.setProperty("pkcs11test.nss.libdir", nssLibDir); + break; + } + } return nssLibDir; } @@ -234,21 +240,23 @@ public abstract class PKCS11Test { } - private static final Map osMap; + private static final Map osMap; // Location of the NSS libraries on each supported platform static { - osMap = new HashMap(); - osMap.put("SunOS-sparc-32", "/usr/lib/mps/"); - osMap.put("SunOS-sparcv9-64", "/usr/lib/mps/64/"); - osMap.put("SunOS-x86-32", "/usr/lib/mps/"); - osMap.put("SunOS-amd64-64", "/usr/lib/mps/64/"); - osMap.put("Linux-i386-32", "/usr/lib/"); - osMap.put("Linux-amd64-64", "/usr/lib64/"); - osMap.put("Windows-x86-32", - PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)); - osMap.put("Windows-amd64-64", - PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)); + osMap = new HashMap(); + osMap.put("SunOS-sparc-32", new String[]{"/usr/lib/mps/"}); + osMap.put("SunOS-sparcv9-64", new String[]{"/usr/lib/mps/64/"}); + osMap.put("SunOS-x86-32", new String[]{"/usr/lib/mps/"}); + osMap.put("SunOS-amd64-64", new String[]{"/usr/lib/mps/64/"}); + osMap.put("Linux-i386-32", new String[]{ + "/usr/lib/i386-linux-gnu/", "/usr/lib/"}); + osMap.put("Linux-amd64-64", new String[]{ + "/usr/lib/x86_64-linux-gnu/", "/usr/lib64/"}); + osMap.put("Windows-x86-32", new String[]{ + PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)}); + osMap.put("Windows-amd64-64", new String[]{ + PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)}); } private final static char[] hexDigits = "0123456789abcdef".toCharArray(); diff --git a/jdk/test/sun/security/pkcs11/Secmod/keystore.jks b/jdk/test/sun/security/pkcs11/Secmod/keystore.jks index b59a2ab43c6..d195b4dadd5 100644 Binary files a/jdk/test/sun/security/pkcs11/Secmod/keystore.jks and b/jdk/test/sun/security/pkcs11/Secmod/keystore.jks differ