Cache.debug(sb.toString());
}
+ public static void setProxyPropertiesFromPreferences()
+ {
+ setProxyPropertiesFromPreferences(Cache.PROXYTYPE_SYSTEM);
+ }
+
+ public static void setProxyPropertiesFromPreferences(
+ String previousProxyType)
+ {
+ String proxyType = Cache.getDefault("USE_PROXY",
+ Cache.PROXYTYPE_SYSTEM);
+ if (proxyType.equals(Cache.PROXYTYPE_NONE))
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting no proxy settings");
+ Cache.setProxyProperties(null, null, null, null, null, null, null,
+ null, null);
+ }
+ else if (proxyType.equals(Cache.PROXYTYPE_CUSTOM))
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting custom proxy settings");
+ boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false);
+ Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null),
+ Cache.getDefault("PROXY_PORT", null),
+ Cache.getDefault("PROXY_SERVER_HTTPS", null),
+ Cache.getDefault("PROXY_PORT_HTTPS", null),
+ proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
+ : null,
+ proxyAuthSet ? Cache.proxyAuthPassword : null,
+ proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
+ : null,
+ proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost");
+ }
+ else // systemProxy should be selected and is sensible default anyway
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting system proxy settings");
+ Cache.resetProxyProperties();
+ }
+ }
+
public static void setProxyProperties(String httpHost, String httpPort,
String httpsHost, String httpsPort, String httpUser,
char[] httpPassword, String httpsUser, char[] httpsPassword,
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
+ Cache.debug(
+ "*** START PasswordAuthentication.getPasswordAuthentication()");
+ Cache.debug("*** getRequestorType()=" + getRequestorType());
if (getRequestorType() == RequestorType.PROXY)
{
- String scheme = getRequestingScheme();
+ String protocol = getRequestingProtocol();
boolean needProxyPasswordSet = false;
+ Cache.debug("*** customProxySet = " + customProxySet);
+ Cache.debug("*** protocol = " + protocol);
+ Cache.debug("*** httpUser = " + httpUser);
+ Cache.debug(
+ "*** httpPassword = \"" + (httpPassword == null ? null
+ : new String(httpPassword)) + "\"");
+ Cache.debug("*** httpsUser = " + httpsUser);
+ Cache.debug("*** httpsPassword = \""
+ + (httpsPassword == null ? null
+ : new String(httpsPassword))
+ + "\"");
if (customProxySet &&
// we have a username but no password for the scheme being
// requested
- (scheme.equalsIgnoreCase("http")
+ (protocol.equalsIgnoreCase("http")
&& (httpUser != null && httpUser.length() > 0
&& (httpPassword == null
|| httpPassword.length == 0)))
- || (scheme.equalsIgnoreCase("https")
+ || (protocol.equalsIgnoreCase("https")
&& (httpsUser != null
&& httpsUser.length() > 0
&& (httpsPassword == null
// open Preferences -> Connections
String message = MessageManager
.getString("label.proxy_password_required");
+ Cache.debug("***+ TRYING TO OPEN PREFERENCES");
openPreferencesConnectionsForProxyPassword(message);
+ Cache.debug("***+ AFTER TRYING TO OPEN PREFERENCES");
}
else
{
+ Cache.debug("***+ TRYING TO GET PASSWORDAUTHENTICATION");
try
{
- if (scheme.equalsIgnoreCase("http")
+ if (protocol.equalsIgnoreCase("http")
&& getRequestingHost().equalsIgnoreCase(httpHost)
&& getRequestingPort() == Integer
.valueOf(httpPort))
{
+ Cache.debug("***+ RETURNING PasswordAuthentication(\""
+ + httpUser + "\", \"" + new String(httpPassword)
+ + "\"");
return new PasswordAuthentication(httpUser,
httpPassword);
}
- if (scheme.equalsIgnoreCase("https")
+ if (protocol.equalsIgnoreCase("https")
&& getRequestingHost().equalsIgnoreCase(httpsHost)
&& getRequestingPort() == Integer
.valueOf(httpsPort))
{
+ Cache.debug("***+ RETURNING PasswordAuthentication(\""
+ + httpsUser + "\", \"" + httpsPassword + "\"");
return new PasswordAuthentication(httpsUser,
httpsPassword);
}
Cache.error("Problem with proxy port values [http:"
+ httpPort + ", https:" + httpsPort + "]");
}
+ Cache.debug(
+ "***+ AFTER TRYING TO GET PASSWORDAUTHENTICATION");
}
}
// non proxy request
+ Cache.debug("***+ Returning null");
return null;
}
});
// required to re-enable basic authentication (should be okay for a
// local proxy)
+ Cache.debug(
+ "***+ Setting jdk.http.auth.tunneling.disabledSchemes to ''");
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
} catch (SecurityException e)
{
{
// reset the Authenticator to protect http.proxyUser and
// http.proxyPassword Just In Case
+ Cache.debug("***+ Setting default Authenticator to null");
Authenticator.setDefault(null);
}
// nonProxyHosts not currently configurable in Preferences
+ Cache.debug("***+ Setting http.nonProxyHosts property to \""
+ + nonProxyHosts + "\"");
setOrClearSystemProperty("http.nonProxyHosts", nonProxyHosts);
}
//
Cache.info("Opening Preferences for proxy password");
// Desktop.instance.preferences_actionPerformed(null);
- Preferences p = new Preferences(GPreferences.CONNECTIONS_TAB);
+ Cache.debug("***+########## TRYING TO OPEN PREFERENCES: " + message);
+ Preferences p = new Preferences(GPreferences.CONNECTIONS_TAB, message);
p.grabFocus();
}
public static void setOrClearSystemProperty(String key, char[] value)
{
setOrClearSystemProperty(key,
- (value == null) ? null : value.toString());
+ (value == null) ? null : new String(value));
}
public static void setOrClearSystemProperty(String key, String value)
public Preferences(int selectTab)
{
- super(selectTab);
+ new Preferences(selectTab, null);
+ }
+
+ public Preferences(int selectTab, String message)
+ {
+ super(selectTab, message);
frame = new JInternalFrame();
frame.setContentPane(this);
if (!Platform.isJS())
proxyType.setSelected(customProxy.getModel(), true);
break;
default:
- String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
- + proxyTypeString;
- Cache.log.warn(message);
+ Cache.log.warn(
+ "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
+ + proxyTypeString);
}
proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
.setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
// we are not storing or retrieving proxy password from .jalview_properties
proxyAuthPasswordTB.setText(Cache.proxyAuthPassword == null ? ""
- : Cache.proxyAuthPassword.toString());
+ : new String(Cache.proxyAuthPassword));
setCustomProxyEnabled();
defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
}
}
- public void setProxyFromSettings()
- {
- String proxyType = Cache.getDefault("USE_PROXY",
- Cache.PROXYTYPE_SYSTEM);
- if (proxyType.equals(Cache.PROXYTYPE_NONE))
- {
- if (!previousProxyType.equals(proxyType))
- Cache.log.info("Setting no proxy settings");
- Cache.setProxyProperties(null, null, null, null, null, null, null,
- null, null);
- }
- else if (proxyType.equals(Cache.PROXYTYPE_CUSTOM))
- {
- if (!previousProxyType.equals(proxyType))
- Cache.log.info("Setting custom proxy settings");
- boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false);
- Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null),
- Cache.getDefault("PROXY_PORT", null),
- Cache.getDefault("PROXY_SERVER_HTTPS", null),
- Cache.getDefault("PROXY_PORT_HTTPS", null),
- proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
- : null,
- proxyAuthSet ? Cache.proxyAuthPassword : null,
- proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
- : null,
- proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost");
- }
- else // systemProxy should be selected and is sensible default anyway
- {
- if (!previousProxyType.equals(proxyType))
- Cache.log.info("Setting system proxy settings");
- Cache.resetProxyProperties();
- }
- }
-
public void saveProxySettings()
{
Cache.applicationProperties.setProperty("USE_PROXY",
Boolean.toString(proxyAuth.isSelected()));
Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
Cache.proxyAuthPassword = proxyAuthPasswordTB.getPassword();
- setProxyFromSettings();
+ Cache.setProxyPropertiesFromPreferences(previousProxyType);
}
/**