_getdown = getdown;
_msgs = msgs;
+ String[] hostPortAuthUser = ProxyUtil.jalviewProxyProperties(getdown._app);
+ String host = hostPortAuthUser[0];
+ String port = hostPortAuthUser[1];
+ boolean proxyAuth = Boolean.parseBoolean(hostPortAuthUser[2]);
+ String username = hostPortAuthUser[3];
+
setLayout(new VGroupLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
add(new SaneLabelField(get("m.configure_proxy")));
JPanel row = new JPanel(new GridLayout());
row.add(new SaneLabelField(get("m.proxy_host")), BorderLayout.WEST);
row.add(_host = new SaneTextField());
+ _host.setText(host);
add(row);
row = new JPanel(new GridLayout());
row.add(new SaneLabelField(get("m.proxy_port")), BorderLayout.WEST);
row.add(_port = new SaneTextField());
+ _port.setText(port);
add(row);
add(new Spacer(5, 5));
row = new JPanel(new GridLayout());
row.add(new SaneLabelField(get("m.proxy_auth_required")), BorderLayout.WEST);
_useAuth = new JCheckBox();
+ _useAuth.setSelected(proxyAuth);
row.add(_useAuth);
add(row);
row = new JPanel(new GridLayout());
row.add(new SaneLabelField(get("m.proxy_username")), BorderLayout.WEST);
_username = new SaneTextField();
- _username.setEnabled(false);
+ _username.setText(username);
+ _username.setEnabled(_useAuth.isSelected());
row.add(_username);
add(row);
row = new JPanel(new GridLayout());
row.add(new SaneLabelField(get("m.proxy_password")), BorderLayout.WEST);
_password = new SanePasswordField();
- _password.setEnabled(false);
+ _password.setEnabled(_useAuth.isSelected());
row.add(_password);
add(row);
package com.threerings.getdown.launcher;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.util.Iterator;
import java.util.ServiceLoader;
+import jalview.bin.LaunchUtils;
+import jalview.util.ChannelProperties;
+
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RegistryValue;
import ca.beq.util.win32.registry.RootKey;
port = hostPort[1];
}
+ // look in jalview_properties
+ String[] hostPortAuthUser = jalviewProxyProperties(app);
+ host = hostPortAuthUser[0];
+ port = hostPortAuthUser[1];
+ boolean proxyAuth = Boolean.parseBoolean(hostPortAuthUser[2]);
+ String username = hostPortAuthUser[3];
+
if (StringUtil.isBlank(host)) {
return false;
}
// yay, we found a proxy configuration, configure it in the app
- initProxy(app, host, port, null, null);
+ initProxy(app, host, port, username, null);
return true;
}
+ public static String[] jalviewProxyProperties(Application app) {
+ String host = null;
+ String port = null;
+ boolean proxyAuth = false;
+ String username = null;
+ File channelProps = app.getLocalPath(ChannelProperties.CHANNEL_PROPERTIES_FILENAME);
+ if (channelProps.exists()) {
+ try {
+ InputStream is = new FileInputStream(channelProps);
+ ChannelProperties.loadProps(is);
+ } catch (IOException e) {
+ log.error(e.getMessage());
+ }
+ if (Boolean.parseBoolean(LaunchUtils.getUserPreference("USE_PROXY"))) {
+ host = LaunchUtils.getUserPreference("PROXY_SERVER_HTTPS");
+ port = LaunchUtils.getUserPreference("PROXY_PORT_HTTPS");
+ if (StringUtil.isBlank(host)) {
+ host = LaunchUtils.getUserPreference("PROXY_SERVER");
+ port = LaunchUtils.getUserPreference("PROXY_PORT");
+ }
+ proxyAuth = Boolean.parseBoolean(LaunchUtils.getUserPreference("PROXY_AUTH"));
+ if (proxyAuth) {
+ username = LaunchUtils.getUserPreference("PROXY_AUTH_USERNAME");
+ }
+ }
+ }
+ return new String[]{ host, port, String.valueOf(proxyAuth), username };
+ }
+
public static boolean canLoadWithoutProxy (URL rurl)
{
log.info("Testing whether proxy is needed, via: " + rurl);
public static void initProxy (Application app, String host, String port,
String username, String password)
{
+System.out.println("**** initProxy(app, '"+host+"', "+port+", '"+username+"', "+(password==null?"null":"*x"+password.length())+")");
// check whether we have saved proxy credentials
String appDir = app.getAppDir().getAbsolutePath();
ServiceLoader<ProxyAuth> loader = ServiceLoader.load(ProxyAuth.class);