示例#1
0
  // For backward compatibility, provide
  // programmatic access for setting proxy info
  // Extract proxy info from command line -D parameters
  // extended 5/7/2012 to get NTLM domain
  // H/T: [email protected]
  static void getGlobalProxyD() {
    Proxy proxy = new Proxy();
    String host = System.getProperty("http.proxyHost");
    String port = System.getProperty("http.proxyPort");
    int portno = -1;

    if (host != null) {
      host = host.trim();
      if (host.length() == 0) host = null;
    }
    if (port != null) {
      port = port.trim();
      if (port.length() > 0) {
        try {
          portno = Integer.parseInt(port);
        } catch (NumberFormatException nfe) {
          portno = -1;
        }
      }
    }

    if (host != null) {
      proxy.host = host;
      proxy.port = portno;
      globalproxy = proxy;
    }
  }
示例#2
0
 public static synchronized void setGlobalProxy(String host, int port) {
   if (globalproxy == null) {
     globalproxy = new Proxy();
     globalproxy.host = host;
     globalproxy.port = port;
   }
 }
示例#3
0
 public void setProxy(String host, int port) {
   Proxy proxy = new Proxy();
   proxy.host = host;
   proxy.port = port;
   setProxy(proxy);
 }