code: public static void enableProxy( String url, String port, String user, String pwd, String nonProxyHosts ) {
          _url = url;
          _port = port;
          _user = user;
          _pwd = pwd;
          System.setProperty("http.proxyHost", url);
          System.setProperty("https.proxyHost", url);
  
          if (port != null && port.trim().length() != 0) {
              System.setProperty("http.proxyPort", port);
              System.setProperty("https.proxyPort", port);
          }
  
          if (user != null && pwd != null && user.trim().length() != 0 && pwd.trim().length() != 0) {
              System.setProperty("http.proxyUserName", user);
              System.setProperty("https.proxyUserName", user);
              System.setProperty("http.proxyUser", user);
              System.setProperty("https.proxyUser", user);
              System.setProperty("http.proxyPassword", pwd);
              System.setProperty("https.proxyPassword", pwd);
  
              Authenticator.setDefault(new ProxyAuthenticator(user, pwd));
  
          }
  
          if (nonProxyHosts != null) {
              System.setProperty("http.nonProxyHosts", nonProxyHosts);
          }
          hasProxy = true;
      }
docs: Enable the proxy usage based on the url, user and pwd.
  
  @param url the proxy server url.
  @param port the server port.
  @param user the proxy user.
  @param pwd the proxy password.
  @param nonProxyHosts hosts that do not go through proxy.
  <p>Default is: <code>localhost|127.*|[::1]</code>.</p>
  <p>Other example: *.foo.com|localhost</p>