]> gitweb.fperrin.net Git - GpsPrune.git/commitdiff
Fix NPE in SetEarthdataAuthentication with no credentials set srtm-multi-sources origin/srtm-multi-sources
authorFrédéric Perrin <fred@fperrin.net>
Sun, 1 Dec 2019 21:15:53 +0000 (21:15 +0000)
committerFrédéric Perrin <fred@fperrin.net>
Sun, 1 Dec 2019 21:31:03 +0000 (21:31 +0000)
src/tim/prune/function/settings/SetEarthdataAuthentication.java

index d4a166abb89e67128f3677713e9195395c6b0589..146ed772c13a41f194778228f8c68b5cf8966882 100644 (file)
@@ -143,25 +143,25 @@ public class SetEarthdataAuthentication extends GenericFunction
 
        private void prefillCurrentAuth()
        {
+               _usernameField.setText("");
+               _passwordField.setText("");
+               _authAccepted.setText(" ");
+
                String authString = Config.getConfigString(Config.KEY_EARTHDATA_AUTH);
-               if (authString == null)
-               {
-                       _usernameField.setText("");
-                       _passwordField.setText("");
-               }
-               String decoded = new String(Base64.getDecoder().decode(authString));
-               if (decoded.contains(":"))
+               try
                {
-                       _usernameField.setText(decoded.split(":", 2)[0]);
-                       _passwordField.setText(decoded.split(":", 2)[1]);
+                       String decoded = new String(Base64.getDecoder().decode(authString));
+                       if (decoded.contains(":"))
+                       {
+                               _usernameField.setText(decoded.split(":", 2)[0]);
+                               _passwordField.setText(decoded.split(":", 2)[1]);
+                       }
                }
-               else
+               catch (Exception e)
                {
-                       _usernameField.setText("");
-                       _passwordField.setText("");
+                       // empty settings, or invalid base64 data --leave blank
+                       return;
                }
-
-               _authAccepted.setText(" ");
        }
 
        private void testUsernameAndPassword()