JAL-3633 Small changes to allow future fitting with ApplicationSingletonI/Jalview...
[jalview.git] / src / jalview / bin / Cache.java
index e96fef1..a6f05db 100755 (executable)
@@ -1400,11 +1400,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
@@ -1432,7 +1432,7 @@ public class Cache
                         .getString("label.proxy_password_required");
                 Preferences.openPreferences(Preferences.CONNECTIONS_TAB,
                         message);
-                Preferences.getPreferences().proxyAuthPasswordFocus();
+                Preferences.getInstance().proxyAuthPasswordHighlight(true);
               }
               else
               {
@@ -1443,8 +1443,6 @@ public class Cache
                           && getRequestingPort() == Integer
                                   .valueOf(httpPort))
                   {
-                    char[] displayHttpPw = new char[httpPassword.length];
-                    Arrays.fill(displayHttpPw, '*');
                     Cache.debug(
                             "AUTHENTICATOR returning PasswordAuthentication(\""
                                     + httpUser + "\", '"
@@ -1495,6 +1493,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);
     }
@@ -1527,25 +1528,32 @@ public class Cache
     }
   }
 
-  public final static int DEBUG = 10;
+  public final static int TRACE = 10;
 
-  public final static int INFO = 20;
+  public final static int DEBUG = 20;
 
-  public final static int WARN = 30;
+  public final static int INFO = 30;
 
-  public final static int ERROR = 40;
+  public final static int WARN = 40;
+
+  public final static int ERROR = 50;
 
   public static boolean println(int level, String message)
   {
     if (Cache.log == null)
     {
-      if (level >= ERROR)
+      if (level >= WARN)
         System.err.println(message);
-      else
+      else if (level >= INFO)
         System.out.println(message);
+      // not printing debug or trace messages
       return false;
     }
-    if (level >= WARN)
+    if (level >= ERROR)
+    {
+      Cache.log.error(message);
+    }
+    else if (level >= WARN)
     {
       Cache.log.warn(message);
     }
@@ -1553,13 +1561,22 @@ public class Cache
     {
       Cache.log.info(message);
     }
-    else
+    else if (level >= DEBUG)
     {
       Cache.log.debug(message);
     }
+    else
+    {
+      Cache.log.trace(message);
+    }
     return true;
   }
 
+  public static void trace(String message)
+  {
+    println(TRACE, message);
+  }
+
   public static void debug(String message)
   {
     println(DEBUG, message);
@@ -1579,4 +1596,4 @@ public class Cache
   {
     println(ERROR, message);
   }
-}
+}
\ No newline at end of file