8173024: Replace direct use of AuthResources resource bundle from jdk.security.auth
authormchung
Sat, 21 Jan 2017 20:31:21 -0800
changeset 43243 a48dab17a356
parent 43242 6c33c81be927
child 43244 7324550409ac
8173024: Replace direct use of AuthResources resource bundle from jdk.security.auth Reviewed-by: weijun
jdk/src/java.base/share/classes/module-info.java
jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java
jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java
jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java
jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java
jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java
jdk/src/jdk.security.auth/share/classes/module-info.java
--- a/jdk/src/java.base/share/classes/module-info.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/java.base/share/classes/module-info.java	Sat Jan 21 20:31:21 2017 -0800
@@ -310,7 +310,6 @@
     // JDK-internal service types
     uses jdk.internal.logger.DefaultLoggerFinder;
     uses sun.security.ssl.ClientKeyExchangeService;
-    uses sun.security.util.AuthResourcesProvider;
     uses sun.text.spi.JavaTimeDateTimePatternProvider;
     uses sun.util.spi.CalendarProvider;
     uses sun.util.locale.provider.LocaleDataMetaInfo;
@@ -322,6 +321,4 @@
 
     provides java.nio.file.spi.FileSystemProvider with
         jdk.internal.jrtfs.JrtFileSystemProvider;
-    provides sun.security.util.AuthResourcesProvider with
-        sun.security.util.AuthResourcesProviderImpl;
 }
--- a/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java	Sat Jan 21 20:31:21 2017 -0800
@@ -331,9 +331,8 @@
                 if (debugConfig != null) {
                     debugConfig.println(fnfe.toString());
                 }
-                throw new IOException(ResourcesMgr.getString
-                    ("Configuration.Error.No.such.file.or.directory",
-                    "sun.security.util.AuthResources"));
+                throw new IOException(ResourcesMgr.getAuthResourceString
+                    ("Configuration.Error.No.such.file.or.directory"));
             }
         }
 
@@ -661,8 +660,8 @@
         }
 
         private IOException ioException(String resourceKey, Object... args) {
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
-                (resourceKey, "sun.security.util.AuthResources"));
+            MessageFormat form = new MessageFormat(
+                ResourcesMgr.getAuthResourceString(resourceKey));
             return new IOException(form.format(args));
         }
     }
--- a/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java	Sat Jan 21 20:31:21 2017 -0800
@@ -34,6 +34,7 @@
 
 import javax.security.auth.Subject;
 import sun.security.provider.PolicyParser.PrincipalEntry;
+import sun.security.util.ResourcesMgr;
 
 /**
  * <p> This <code>SubjectCodeSource</code> class contains
@@ -47,15 +48,6 @@
 
     private static final long serialVersionUID = 6039418085604715275L;
 
-    private static final java.util.ResourceBundle rb =
-        java.security.AccessController.doPrivileged
-        (new java.security.PrivilegedAction<java.util.ResourceBundle>() {
-            public java.util.ResourceBundle run() {
-                return (java.util.ResourceBundle.getBundle
-                        ("sun.security.util.AuthResources"));
-            }
-        });
-
     private Subject subject;
     private LinkedList<PrincipalEntry> principals;
     private static final Class<?>[] PARAMS = { String.class };
@@ -391,7 +383,7 @@
             ListIterator<PrincipalEntry> li = principals.listIterator();
             while (li.hasNext()) {
                 PrincipalEntry pppe = li.next();
-                returnMe = returnMe + rb.getString("NEWLINE") +
+                returnMe = returnMe + ResourcesMgr.getAuthResourceString("NEWLINE") +
                         pppe.getPrincipalClass() + " " +
                         pppe.getPrincipalName();
             }
--- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java	Sat Jan 21 14:31:57 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-public interface AuthResourcesProvider extends java.util.spi.ResourceBundleProvider {
-}
--- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java	Sat Jan 21 14:31:57 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-import java.util.spi.AbstractResourceBundleProvider;
-
-public final class AuthResourcesProviderImpl extends AbstractResourceBundleProvider
-       implements AuthResourcesProvider {
-    public AuthResourcesProviderImpl() {
-        super("java.class");
-    }
-}
\ No newline at end of file
--- a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Sat Jan 21 20:31:21 2017 -0800
@@ -25,18 +25,22 @@
 
 package sun.security.util;
 
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+import jdk.internal.misc.VM;
+
 /**
  */
 public class ResourcesMgr {
+    // intended for java.security, javax.security and sun.security resources
+    private final static String RESOURCES = "sun.security.util.Resources";
+    private final static String AUTH_RESOURCES = "sun.security.util.AuthResources";
 
-    // intended for java.security, javax.security and sun.security resources
-    private static java.util.ResourceBundle bundle;
-
-    // intended for com.sun.security resources
-    private static java.util.ResourceBundle altBundle;
+    private final static Map<String, ResourceBundle> bundles = new ConcurrentHashMap<>();
 
     public static String getString(String s) {
-
+        ResourceBundle bundle = bundles.get(RESOURCES);
         if (bundle == null) {
 
             // only load if/when needed
@@ -52,19 +56,15 @@
         return bundle.getString(s);
     }
 
-    public static String getString(String s, final String altBundleName) {
-
-        if (altBundle == null) {
-
-            // only load if/when needed
-            altBundle = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<java.util.ResourceBundle>() {
-                public java.util.ResourceBundle run() {
-                    return (java.util.ResourceBundle.getBundle(altBundleName));
-                }
-            });
+    public static String getAuthResourceString(String s) {
+        if (VM.initLevel() == 3) {
+            // cannot trigger loading of any resource bundle as
+            // it depends on the system class loader fully initialized.
+            throw new InternalError("system class loader is being initialized");
         }
 
-        return altBundle.getString(s);
+        return bundles.computeIfAbsent(AUTH_RESOURCES, ResourceBundle::getBundle)
+                      .getString(s);
     }
+
 }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -65,9 +65,8 @@
     public NTDomainPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -92,9 +91,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTDomainPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTDomainPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java	Sat Jan 21 20:31:21 2017 -0800
@@ -61,9 +61,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTNumericCredential.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTNumericCredential.name"));
         Object[] source = {Long.toString(impersonationToken)};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java	Sat Jan 21 20:31:21 2017 -0800
@@ -70,17 +70,15 @@
     public NTSid (String stringSid) {
         if (stringSid == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"stringSid"};
             throw new NullPointerException(form.format(source));
         }
         if (stringSid.length() == 0) {
             throw new IllegalArgumentException
-                (sun.security.util.ResourcesMgr.getString
-                        ("Invalid.NTSid.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("Invalid.NTSid.value"));
         }
         sid = new String(stringSid);
     }
@@ -101,9 +99,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSid.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSid.name"));
         Object[] source = {sid};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -68,9 +68,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidDomainPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidDomainPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -63,9 +63,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidGroupPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidGroupPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -65,9 +65,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidPrimaryGroupPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidPrimaryGroupPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -62,9 +62,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidUserPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -61,9 +61,8 @@
     public NTUserPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -86,9 +85,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTUserPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -26,6 +26,7 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class implements the {@code Principal} interface
@@ -53,9 +54,6 @@
 
     private static final long serialVersionUID = 2345199581042573224L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -82,7 +80,7 @@
      */
     public SolarisNumericGroupPrincipal(String name, boolean primaryGroup) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
         this.primaryGroup = primaryGroup;
@@ -146,11 +144,11 @@
      *          {@code SolarisNumericGroupPrincipal}.
      */
     public String toString() {
-        return((primaryGroup ?
-            rb.getString
+        return primaryGroup ?
+            getAuthResourceString
             ("SolarisNumericGroupPrincipal.Primary.Group.") + name :
-            rb.getString
-            ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name));
+            getAuthResourceString
+            ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name;
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -26,6 +26,7 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class implements the {@code Principal} interface
@@ -52,9 +53,6 @@
 
     private static final long serialVersionUID = -3178578484679887104L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -72,7 +70,7 @@
      */
     public SolarisNumericUserPrincipal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
     }
@@ -118,7 +116,7 @@
      *          {@code SolarisNumericUserPrincipal}.
      */
     public String toString() {
-        return(rb.getString("SolarisNumericUserPrincipal.") + name);
+        return(getAuthResourceString("SolarisNumericUserPrincipal.") + name);
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -26,6 +26,8 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
+
 
 /**
  * This class implements the {@code Principal} interface
@@ -50,10 +52,6 @@
 
     private static final long serialVersionUID = -7840670002439379038L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
-
     /**
      * @serial
      */
@@ -69,7 +67,7 @@
      */
     public SolarisPrincipal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
     }
@@ -89,7 +87,7 @@
      * @return a string representation of this {@code SolarisPrincipal}.
      */
     public String toString() {
-        return(rb.getString("SolarisPrincipal.") + name);
+        return(getAuthResourceString("SolarisPrincipal.") + name);
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -74,9 +74,8 @@
     public UnixNumericGroupPrincipal(String name, boolean primaryGroup) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -146,16 +145,14 @@
 
         if (primaryGroup) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixNumericGroupPrincipal.Primary.Group.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixNumericGroupPrincipal.Primary.Group.name"));
             Object[] source = {name};
             return form.format(source);
         } else {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                    ("UnixNumericGroupPrincipal.Supplementary.Group.name",
-                    "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                    ("UnixNumericGroupPrincipal.Supplementary.Group.name"));
             Object[] source = {name};
             return form.format(source);
         }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -64,9 +64,8 @@
     public UnixNumericUserPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -116,9 +115,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixNumericUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixNumericUserPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -61,9 +61,8 @@
     public UnixPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -87,9 +86,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java	Sat Jan 21 20:31:21 2017 -0800
@@ -27,6 +27,7 @@
 
 import java.security.Principal;
 import sun.security.x509.X500Name;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class represents an X.500 {@code Principal}.
@@ -55,9 +56,6 @@
 
     private static final long serialVersionUID = -8222422609431628648L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -80,7 +78,7 @@
      */
     public X500Principal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         try {
             thisX500Name = new X500Name(name);
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java	Sat Jan 21 20:31:21 2017 -0800
@@ -32,15 +32,13 @@
 import javax.naming.*;
 import javax.naming.directory.*;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Map;
 import java.util.LinkedList;
-import java.util.ResourceBundle;
 
 import com.sun.security.auth.UnixPrincipal;
 import com.sun.security.auth.UnixNumericUserPrincipal;
 import com.sun.security.auth.UnixNumericGroupPrincipal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 
 /**
@@ -153,9 +151,6 @@
  */
 public class JndiLoginModule implements LoginModule {
 
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /** JNDI Provider */
     public final String USER_PROVIDER = "user.provider.url";
     public final String GROUP_PROVIDER = "group.provider.url";
@@ -677,9 +672,9 @@
 
         Callback[] callbacks = new Callback[2];
         callbacks[0] = new NameCallback(protocol + " "
-                                            + rb.getString("username."));
+                                            + getAuthResourceString("username."));
         callbacks[1] = new PasswordCallback(protocol + " " +
-                                                rb.getString("password."),
+                                                getAuthResourceString("password."),
                                             false);
 
         try {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java	Sat Jan 21 20:31:21 2017 -0800
@@ -51,6 +51,7 @@
 import javax.security.auth.spi.LoginModule;
 
 import sun.security.util.Password;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * Provides a JAAS login module that prompts for a key store alias and
@@ -112,9 +113,6 @@
  */
 public class KeyStoreLoginModule implements LoginModule {
 
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /* -- Fields -- */
 
     private static final int UNINITIALIZED = 0;
@@ -132,7 +130,7 @@
     private static final TextOutputCallback bannerCallback =
                 new TextOutputCallback
                         (TextOutputCallback.INFORMATION,
-                        rb.getString("Please.enter.keystore.information"));
+                        getAuthResourceString("Please.enter.keystore.information"));
     private final ConfirmationCallback confirmationCallback =
                 new ConfirmationCallback
                         (ConfirmationCallback.INFORMATION,
@@ -344,11 +342,10 @@
 
             NameCallback aliasCallback;
             if (keyStoreAlias == null || keyStoreAlias.length() == 0) {
-                aliasCallback = new NameCallback(
-                                        rb.getString("Keystore.alias."));
+                aliasCallback = new NameCallback(getAuthResourceString("Keystore.alias."));
             } else {
                 aliasCallback =
-                    new NameCallback(rb.getString("Keystore.alias."),
+                    new NameCallback(getAuthResourceString("Keystore.alias."),
                                      keyStoreAlias);
             }
 
@@ -360,11 +357,11 @@
                 break;
             case NORMAL:
                 keyPassCallback = new PasswordCallback
-                    (rb.getString("Private.key.password.optional."), false);
+                    (getAuthResourceString("Private.key.password.optional."), false);
                 // fall thru
             case TOKEN:
                 storePassCallback = new PasswordCallback
-                    (rb.getString("Keystore.password."), false);
+                    (getAuthResourceString("Keystore.password."), false);
                 break;
             }
             prompt(aliasCallback, storePassCallback, keyPassCallback);
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Sat Jan 21 20:31:21 2017 -0800
@@ -27,8 +27,6 @@
 package com.sun.security.auth.module;
 
 import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.text.MessageFormat;
 import java.util.*;
 
@@ -45,6 +43,7 @@
 import sun.security.jgss.krb5.Krb5Util;
 import sun.security.krb5.Credentials;
 import sun.security.util.HexDumpEncoder;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This {@code LoginModule} authenticates users using
@@ -419,8 +418,6 @@
 
     private static final String NAME = "javax.security.auth.login.name";
     private static final String PWD = "javax.security.auth.login.password";
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
 
     /**
      * Initialize this {@code LoginModule}.
@@ -831,7 +828,7 @@
 
                 Callback[] callbacks = new Callback[1];
                 MessageFormat form = new MessageFormat(
-                                       rb.getString(
+                                       getAuthResourceString(
                                        "Kerberos.username.defUsername."));
                 Object[] source =  {defUsername};
                 callbacks[0] = new NameCallback(form.format(source));
@@ -886,7 +883,7 @@
                 Callback[] callbacks = new Callback[1];
                 String userName = krb5PrincName.toString();
                 MessageFormat form = new MessageFormat(
-                                         rb.getString(
+                                         getAuthResourceString(
                                          "Kerberos.password.for.username."));
                 Object[] source = {userName};
                 callbacks[0] = new PasswordCallback(
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java	Sat Jan 21 20:31:21 2017 -0800
@@ -25,14 +25,11 @@
 
 package com.sun.security.auth.module;
 
-import java.security.AccessController;
 import java.net.SocketPermission;
 import java.security.Principal;
-import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.Set;
@@ -47,6 +44,7 @@
 
 import com.sun.security.auth.LdapPrincipal;
 import com.sun.security.auth.UserPrincipal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 
 /**
@@ -305,10 +303,6 @@
  */
 public class LdapLoginModule implements LoginModule {
 
-    // Use the default classloader for this class to load the prompt strings.
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     // Keys to retrieve the stored username and password
     private static final String USERNAME_KEY = "javax.security.auth.login.name";
     private static final String PASSWORD_KEY =
@@ -957,8 +951,8 @@
                 "to acquire authentication information from the user");
 
         Callback[] callbacks = new Callback[2];
-        callbacks[0] = new NameCallback(rb.getString("username."));
-        callbacks[1] = new PasswordCallback(rb.getString("password."), false);
+        callbacks[0] = new NameCallback(getAuthResourceString("username."));
+        callbacks[1] = new PasswordCallback(getAuthResourceString("password."), false);
 
         try {
             callbackHandler.handle(callbacks);
--- a/jdk/src/jdk.security.auth/share/classes/module-info.java	Sat Jan 21 14:31:57 2017 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/module-info.java	Sat Jan 21 20:31:21 2017 -0800
@@ -36,8 +36,6 @@
     exports com.sun.security.auth.login;
     exports com.sun.security.auth.module;
 
-    uses sun.security.util.AuthResourcesProvider;
-
     provides javax.security.auth.spi.LoginModule with
         com.sun.security.auth.module.Krb5LoginModule,
         com.sun.security.auth.module.UnixLoginModule,