Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7105065

The class SunPKCS11 is not available even in JDK/JRE 7 for WIndows 64 bit

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • security-libs

      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

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: