JAL-3633 Small changes to allow future fitting with ApplicationSingletonI/Jalview...
[jalview.git] / src / jalview / bin / Cache.java
index dc28902..677e9ad 100755 (executable)
@@ -1226,9 +1226,11 @@ public class Cache
     setProxyProperties(startupProxyProperties[0], startupProxyProperties[1],
             startupProxyProperties[2], startupProxyProperties[3],
             startupProxyProperties[4],
-            startupProxyProperties[5].toCharArray(),
+            startupProxyProperties[5] == null ? null
+                    : startupProxyProperties[5].toCharArray(),
             startupProxyProperties[6],
-            startupProxyProperties[7].toCharArray(),
+            startupProxyProperties[7] == null ? null
+                    : startupProxyProperties[7].toCharArray(),
             startupProxyProperties[8]);
     StringBuilder sb = new StringBuilder();
     sb.append("Setting proxy properties to: http.proxyHost=")
@@ -1342,11 +1344,11 @@ public class Cache
     {
       try
       {
+        char[] displayHttpPw = new char[httpPassword == null ? 0
+                : httpPassword.length];
+        Arrays.fill(displayHttpPw, '*');
         Cache.debug("CACHE Proxy: setting new Authenticator with httpUser='"
-                + httpUser + "' httpPassword='"
-                + (proxyAuthPassword == null ? "null"
-                        : new String(proxyAuthPassword))
-                + "'"); // DELETE THIS LINE (password in logs)
+                + httpUser + "' httpPassword='" + displayHttpPw + "'");
         Authenticator.setDefault(new Authenticator()
         {
           @Override
@@ -1374,7 +1376,7 @@ public class Cache
                         .getString("label.proxy_password_required");
                 Preferences.openPreferences(Preferences.CONNECTIONS_TAB,
                         message);
-                Preferences.getPreferences().proxyAuthPasswordFocus();
+                Preferences.getInstance().proxyAuthPasswordHighlight(true);
               }
               else
               {
@@ -1385,8 +1387,6 @@ public class Cache
                           && getRequestingPort() == Integer
                                   .valueOf(httpPort))
                   {
-                    char[] displayHttpPw = new char[httpPassword.length];
-                    Arrays.fill(displayHttpPw, '*');
                     Cache.debug(
                             "AUTHENTICATOR returning PasswordAuthentication(\""
                                     + httpUser + "\", '"
@@ -1437,6 +1437,9 @@ public class Cache
     {
       // reset the Authenticator to protect http.proxyUser and
       // http.proxyPassword Just In Case
+      /* as noted above, due to bug in java this doesn't work if the sun.net.www.protocol.http.AuthCache
+       * has working credentials. No workaround for Java 11.
+       */
       Cache.debug("AUTHENTICATOR setting default Authenticator to null");
       Authenticator.setDefault(null);
     }