Arrays.fill(displayHttpPw, '*');
Cache.debug("CACHE Proxy: setting new Authenticator with httpUser='"
+ httpUser + "' httpPassword='" + displayHttpPw + "'");
- Authenticator.setDefault(new Authenticator()
+ if (!Platform.isJS())
+ /* *
+ * java.net.Authenticator not implemented in SwingJS yet
+ *
+ * @j2sIgnore
+ *
+ */
{
- @Override
- protected PasswordAuthentication getPasswordAuthentication()
+ Authenticator.setDefault(new Authenticator()
{
- if (getRequestorType() == RequestorType.PROXY)
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication()
{
- String protocol = getRequestingProtocol();
- boolean needProxyPasswordSet = false;
- if (customProxySet &&
- // we have a username but no password for the scheme being
- // requested
- (protocol.equalsIgnoreCase("http")
- && (httpUser != null && httpUser.length() > 0
- && (httpPassword == null
- || httpPassword.length == 0)))
- || (protocol.equalsIgnoreCase("https")
- && (httpsUser != null
- && httpsUser.length() > 0
- && (httpsPassword == null
- || httpsPassword.length == 0))))
+ if (getRequestorType() == RequestorType.PROXY)
{
- // open Preferences -> Connections
- String message = MessageManager
- .getString("label.proxy_password_required");
- Preferences.openPreferences(Preferences.CONNECTIONS_TAB,
- message);
- Preferences.getInstance()
- .proxyAuthPasswordCheckHighlight(true, true);
- }
- else
- {
- try
+ String protocol = getRequestingProtocol();
+ boolean needProxyPasswordSet = false;
+ if (customProxySet &&
+ // we have a username but no password for the scheme being
+ // requested
+ (protocol.equalsIgnoreCase("http")
+ && (httpUser != null && httpUser.length() > 0
+ && (httpPassword == null
+ || httpPassword.length == 0)))
+ || (protocol.equalsIgnoreCase("https")
+ && (httpsUser != null
+ && httpsUser.length() > 0
+ && (httpsPassword == null
+ || httpsPassword.length == 0))))
+ {
+ // open Preferences -> Connections
+ String message = MessageManager
+ .getString("label.proxy_password_required");
+ Preferences.openPreferences(Preferences.CONNECTIONS_TAB,
+ message);
+ Preferences.getInstance()
+ .proxyAuthPasswordCheckHighlight(true, true);
+ }
+ else
{
- if (protocol.equalsIgnoreCase("http")
- && getRequestingHost().equalsIgnoreCase(httpHost)
- && getRequestingPort() == Integer
- .valueOf(httpPort))
+ try
{
- Cache.debug(
- "AUTHENTICATOR returning PasswordAuthentication(\""
- + httpUser + "\", '"
- + new String(displayHttpPw) + "')");
- return new PasswordAuthentication(httpUser,
- httpPassword);
- }
- if (protocol.equalsIgnoreCase("https")
- && getRequestingHost().equalsIgnoreCase(httpsHost)
- && getRequestingPort() == Integer
- .valueOf(httpsPort))
+ if (protocol.equalsIgnoreCase("http")
+ && getRequestingHost()
+ .equalsIgnoreCase(httpHost)
+ && getRequestingPort() == Integer
+ .valueOf(httpPort))
+ {
+ Cache.debug(
+ "AUTHENTICATOR returning PasswordAuthentication(\""
+ + httpUser + "\", '"
+ + new String(displayHttpPw) + "')");
+ return new PasswordAuthentication(httpUser,
+ httpPassword);
+ }
+ if (protocol.equalsIgnoreCase("https")
+ && getRequestingHost()
+ .equalsIgnoreCase(httpsHost)
+ && getRequestingPort() == Integer
+ .valueOf(httpsPort))
+ {
+ char[] displayHttpsPw = new char[httpPassword.length];
+ Arrays.fill(displayHttpsPw, '*');
+ Cache.debug(
+ "AUTHENTICATOR returning PasswordAuthentication(\""
+ + httpsUser + "\", '" + displayHttpsPw
+ + "'");
+ return new PasswordAuthentication(httpsUser,
+ httpsPassword);
+ }
+ } catch (NumberFormatException e)
{
- char[] displayHttpsPw = new char[httpPassword.length];
- Arrays.fill(displayHttpsPw, '*');
- Cache.debug(
- "AUTHENTICATOR returning PasswordAuthentication(\""
- + httpsUser + "\", '" + displayHttpsPw
- + "'");
- return new PasswordAuthentication(httpsUser,
- httpsPassword);
+ Cache.error("Problem with proxy port values [http:"
+ + httpPort + ", https:" + httpsPort + "]");
}
- } catch (NumberFormatException e)
- {
- Cache.error("Problem with proxy port values [http:"
- + httpPort + ", https:" + httpsPort + "]");
+ Cache.debug(
+ "AUTHENTICATOR after trying to get PasswordAuthentication");
}
- Cache.debug(
- "AUTHENTICATOR after trying to get PasswordAuthentication");
}
+ // non proxy request
+ Cache.debug("AUTHENTICATOR returning null");
+ return null;
}
- // non proxy request
- Cache.debug("AUTHENTICATOR returning null");
- return null;
- }
- });
+ });
+ } // end of j2sIgnore for java.net.Authenticator
+
// required to re-enable basic authentication (should be okay for a
// local proxy)
Cache.debug(
/* 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);
+ if (!Platform.isJS())
+ /* *
+ * java.net.Authenticator not implemented in SwingJS yet
+ *
+ * @j2sIgnore
+ *
+ */
+ {
+ Cache.debug("AUTHENTICATOR setting default Authenticator to null");
+ Authenticator.setDefault(null);
+ }
}
// nonProxyHosts not currently configurable in Preferences
gbc.gridy++;
proxyPanel.add(hpPanel, gbc);
- // Require authentication checkbox
- gbc.gridy++;
- proxyPanel.add(proxyAuth, gbc);
-
- // username and password
- JPanel upPanel = new JPanel();
- upPanel.setLayout(new GridBagLayout());
- // username row
- c.gridy = 0;
- c.gridx = 0;
- c.gridwidth = 1;
- c.weightx = 0.4;
- c.anchor = GridBagConstraints.LINE_END;
- upPanel.add(proxyAuthUsernameLabel, c);
-
- c.gridx++;
- c.weightx = 1.0;
- c.anchor = GridBagConstraints.LINE_START;
- upPanel.add(proxyAuthUsernameTB, c);
-
- // password row
- c.gridy++;
- c.gridx = 0;
- c.weightx = 0.4;
- c.anchor = GridBagConstraints.LINE_END;
- upPanel.add(proxyAuthPasswordLabel, c);
-
- c.gridx++;
- c.weightx = 1.0;
- c.anchor = GridBagConstraints.LINE_START;
- upPanel.add(proxyAuthPasswordPB, c);
-
- c.gridx++;
- c.weightx = 0.4;
- c.anchor = GridBagConstraints.LINE_START;
- upPanel.add(passwordNotStoredLabel, c);
-
- gbc.gridy++;
- proxyPanel.add(upPanel, gbc);
+ if (!Platform.isJS())
+ /**
+ * java.net.Authenticator is not implemented in SwingJS. Not displaying the
+ * Authentication options in Preferences.
+ *
+ * @j2sIgnore
+ *
+ */
+ {
+ // Require authentication checkbox
+ gbc.gridy++;
+ proxyPanel.add(proxyAuth, gbc);
+
+ // username and password
+ JPanel upPanel = new JPanel();
+ upPanel.setLayout(new GridBagLayout());
+ // username row
+ c.gridy = 0;
+ c.gridx = 0;
+ c.gridwidth = 1;
+ c.weightx = 0.4;
+ c.anchor = GridBagConstraints.LINE_END;
+ upPanel.add(proxyAuthUsernameLabel, c);
+
+ c.gridx++;
+ c.weightx = 1.0;
+ c.anchor = GridBagConstraints.LINE_START;
+ upPanel.add(proxyAuthUsernameTB, c);
+
+ // password row
+ c.gridy++;
+ c.gridx = 0;
+ c.weightx = 0.4;
+ c.anchor = GridBagConstraints.LINE_END;
+ upPanel.add(proxyAuthPasswordLabel, c);
+
+ c.gridx++;
+ c.weightx = 1.0;
+ c.anchor = GridBagConstraints.LINE_START;
+ upPanel.add(proxyAuthPasswordPB, c);
+
+ c.gridx++;
+ c.weightx = 0.4;
+ c.anchor = GridBagConstraints.LINE_START;
+ upPanel.add(passwordNotStoredLabel, c);
+
+ gbc.gridy++;
+ proxyPanel.add(upPanel, gbc);
+
+ } // end j2sIgnore
applyProxyButton.setText(MessageManager.getString("action.apply"));
applyProxyButton.addActionListener(new ActionListener()