Java HTTP Proxy Authentication

When writing Java programs there is sometimes a need to get content from the Internet. However, to do that from within the ECS network requires authenticating with the HTTP proxy server. Below are the ECS proxy settings and a Java class wrapper to provide this functionality.

More information at Java Proxy Configuration.

ECS Proxy Settings

The ECS proxy is or and uses port 8080.

See for more information about setting your web browser proxy settings.

ECS Proxy Authenticator

Thanks to HughDavenport and Kyle Chard for this Java code that works with the ECS proxy.

Example use:
  • Command Line: java ECSAuthenticator Foo (where Foo is the name of the class you want to execute)
  • Eclipse: Inside Run Configurations, and "Main" tab set the "Main Class" option as ECSAuthenticator then in "Arguments" tab set the "Program arguments" option as Foo (name of class to execute).

public class ECSAuthenticator extends {
   protected getPasswordAuthentication() {
      return new"username", "password".toCharArray());

   public static void main(String[] args) throws Exception { ECSAuthenticator());
      System.setProperty("http.proxyHost", "");
      System.setProperty("http.proxyPort", "8080");
      System.setProperty("http.nonProxyHosts", "localhost|*|*|*");
      String[] newArgs = new String[args.length-1];
      System.arraycopy(args, 1, newArgs, 0, args.length-1);
      Class[] methodTypes = new Class[1];
      methodTypes[0] = newArgs.getClass();
      Object[] methodArgs = new Object[1];
      methodArgs[0] = newArgs;
      Class mainClass = Class.forName(args[0]);
      java.lang.reflect.Method mainMethod  = mainClass.getMethod("main", methodTypes);
      mainMethod.invoke(null, methodArgs);