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