JDK-7105065 : The class SunPKCS11 is not available even in JDK/JRE 7 for WIndows 64 bit
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-10-26
  • Updated: 2013-04-24
  • Resolved: 2011-10-27
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Java 6 for Windows 64 bit was lacking in support for sun.security.pkcs11.SunPKCS11 feature and actually missing the required JAR and DLL file. Almost all other Java 6 and 7 platforms include the required JAR and native library (i.e. .so or .dll). The same was the case for SunMSCAPI but this has been included in Java 7 release for Windows 64 bit but support for SunPKCS11 is still not provided in Java 7

JUSTIFICATION :
There MUST be consistent support for the feature in Java for all platforms

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application code using class sun.security.pkcs11.SunPKCS11 should be run on Java 7 for Windows 64 bit as it does for all other supported platforms
ACTUAL -
The application successfully running on Windows XP 32 bit fails on Windows 7 64 bit with following Exception:

java.lang.NoClassDefFoundError: sun/security/pkcs11/SunPKCS11
Caused by: java.lang.ClassNotFoundException: sun.security.pkcs11.SunPKCS11
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: javaapplication1.TestPkcs11.  Program will exit.

---------- BEGIN SOURCE ----------
        String pkcs11config = "name =Alladin \n library =C:/Windows/SysWOW64/eTPKCS11.dll \n slot =0";
        byte[] pkcs11configBytes = pkcs11config.getBytes();
        ByteArrayInputStream configStream = new ByteArrayInputStream(pkcs11configBytes);
        java.security.Security.removeProvider("SunPKCS11");
        Provider obj_provider = new sun.security.pkcs11.SunPKCS11(configStream);
        Security.insertProviderAt(obj_provider, 1);
        // TextCallbackHandler prompts and reads the command line for
        // name and password information.
        CallbackHandler cmdLineHdlr = new com.sun.security.auth.callback.TextCallbackHandler();
        KeyStore.Builder ksBuilder = KeyStore.Builder.newInstance("PKCS11", obj_provider, new KeyStore.CallbackHandlerProtection(cmdLineHdlr));
        KeyStore keystore = ksBuilder.getKeyStore();
        Enumeration obj_enum = keystore.aliases();
        for (; obj_enum.hasMoreElements();) {
            String alias = (String) obj_enum.nextElement();
            // Does alias refer to a private key?
            boolean b = keystore.isKeyEntry(alias);
            if (b) {
                System.out.println("*** " + alias);
            }
        }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No workaround available