Blame SOURCES/pr2737-allow_multiple_pkcs11_library_initialisation_to_be_a_non_critical_error.patch

53c576
# HG changeset patch
53c576
# User andrew
53c576
# Date 1352129932 0
53c576
# Node ID e9c857dcb964dbfa5eef3a3590244cb4d999cf7a
53c576
# Parent  1406789608b76d0906881979335d685855f44190
53c576
Allow multiple PKCS11 library initialisation to be a non-critical error.
53c576
53c576
diff -r 1406789608b7 -r e9c857dcb964 src/share/classes/sun/security/pkcs11/Config.java
53c576
--- jdk8/jdk/src/share/classes/sun/security/pkcs11/Config.java Tue Oct 30 13:05:14 2012 +0000
53c576
+++ jdk8/jdk/src/share/classes/sun/security/pkcs11/Config.java Mon Nov 05 15:38:52 2012 +0000
53c576
@@ -52,6 +52,7 @@
53c576
     static final int ERR_HALT       = 1;
53c576
     static final int ERR_IGNORE_ALL = 2;
53c576
     static final int ERR_IGNORE_LIB = 3;
53c576
+    static final int ERR_IGNORE_MULTI_INIT = 4;
53c576
 
53c576
     // same as allowSingleThreadedModules but controlled via a system property
53c576
     // and applied to all providers. if set to false, no SunPKCS11 instances
53c576
@@ -980,6 +981,8 @@
53c576
             handleStartupErrors = ERR_IGNORE_LIB;
53c576
         } else if (val.equals("halt")) {
53c576
             handleStartupErrors = ERR_HALT;
53c576
+        } else if (val.equals("ignoreMultipleInitialisation")) {
53c576
+            handleStartupErrors = ERR_IGNORE_MULTI_INIT;
53c576
         } else {
53c576
             throw excToken("Invalid value for handleStartupErrors:");
53c576
         }
53c576
diff -r 1406789608b7 -r e9c857dcb964 src/share/classes/sun/security/pkcs11/SunPKCS11.java
53c576
--- jdk8/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java  Tue Oct 30 13:05:14 2012 +0000
53c576
+++ jdk8/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java  Mon Nov 05 15:38:52 2012 +0000
53c576
@@ -168,26 +168,37 @@
53c576
                 String nssLibraryDirectory = config.getNssLibraryDirectory();
53c576
                 String nssSecmodDirectory = config.getNssSecmodDirectory();
53c576
                 boolean nssOptimizeSpace = config.getNssOptimizeSpace();
53c576
+                int errorHandling = config.getHandleStartupErrors();
53c576
 
53c576
                 if (secmod.isInitialized()) {
53c576
                     if (nssSecmodDirectory != null) {
53c576
                         String s = secmod.getConfigDir();
53c576
                         if ((s != null) &&
53c576
                                 (s.equals(nssSecmodDirectory) == false)) {
53c576
-                            throw new ProviderException("Secmod directory "
53c576
-                                + nssSecmodDirectory
53c576
-                                + " invalid, NSS already initialized with "
53c576
-                                + s);
53c576
+                            String msg = "Secmod directory " + nssSecmodDirectory
53c576
+                                + " invalid, NSS already initialized with " + s;
53c576
+                            if (errorHandling == Config.ERR_IGNORE_MULTI_INIT ||
53c576
+                                errorHandling == Config.ERR_IGNORE_ALL) {
53c576
+                                throw new UnsupportedOperationException(msg);
53c576
+                            } else {
53c576
+                                throw new ProviderException(msg);
53c576
+                            }
53c576
                         }
53c576
                     }
53c576
                     if (nssLibraryDirectory != null) {
53c576
                         String s = secmod.getLibDir();
53c576
                         if ((s != null) &&
53c576
                                 (s.equals(nssLibraryDirectory) == false)) {
53c576
-                            throw new ProviderException("NSS library directory "
53c576
+                            String msg = "NSS library directory "
53c576
                                 + nssLibraryDirectory
53c576
                                 + " invalid, NSS already initialized with "
53c576
-                                + s);
53c576
+                                + s;
53c576
+                            if (errorHandling == Config.ERR_IGNORE_MULTI_INIT ||
53c576
+                                errorHandling == Config.ERR_IGNORE_ALL) {
53c576
+                                throw new UnsupportedOperationException(msg);
53c576
+                            } else {
53c576
+                                throw new ProviderException(msg);
53c576
+                            }
53c576
                         }
53c576
                     }
53c576
                 } else {