X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Flauncher%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Flauncher%2FProxyUtil.java;fp=getdown%2Fsrc%2Fgetdown%2Flauncher%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Flauncher%2FProxyUtil.java;h=cb51ca4b44b318e0ec6315e960920462ee67d326;hb=b26fefd329b60deb2025aa28cdbaae30bfb58382;hp=a36b5fa671e1e632077ceb948a1e365ded6eba9f;hpb=f2bb3db094696bb382ecb8d08913c1b5dc293b53;p=jalview.git diff --git a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/ProxyUtil.java b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/ProxyUtil.java index a36b5fa..cb51ca4 100644 --- a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/ProxyUtil.java +++ b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/ProxyUtil.java @@ -6,8 +6,10 @@ 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; @@ -19,6 +21,8 @@ import java.net.URLConnection; import java.util.Iterator; import java.util.ServiceLoader; +import jalview.util.LaunchUtils; + import ca.beq.util.win32.registry.RegistryKey; import ca.beq.util.win32.registry.RegistryValue; import ca.beq.util.win32.registry.RootKey; @@ -88,15 +92,43 @@ public class ProxyUtil { 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; + LaunchUtils.loadChannelProps(app.getAppDir()); + if (LaunchUtils.getBooleanUserPreference("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 = LaunchUtils.getBooleanUserPreference("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); @@ -179,6 +211,7 @@ public class ProxyUtil { 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 loader = ServiceLoader.load(ProxyAuth.class);