/*
 * Copyright 2011, 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an
 * "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package org.powertac.samplebroker.core;

/**
 * This is the top level of the Power TAC server.
 * @author John Collins
 */
public class BrokerMain
{
  //static private Logger log = Logger.getLogger(BrokerMain.class);

  /**
   * Sets up the broker. Single command-line arg is the username
   */
  public static void main (String[] args)
  {
    BrokerRunner runner = new BrokerRunner();
    runner.processCmdLine(args);
    
    // if we get here, it's time to exit
    System.exit(0);
  }
}

@@ -652,16 +652,89 @@
 .core;%0A%0A
+import java.net.Authenticator;%0Aimport java.net.PasswordAuthentication;%0A%0A%0A
 /**%0A * T
@@ -1033,148 +1033,809 @@
     
-BrokerRunner runner = new BrokerRunner();%0A    runner.processCmdLine(args);%0A    %0A    // if we get here, it's time to exit%0A    System.exit(0);
+String username = System.getProperty(%22java.net.socks.username%22);%0A    String password = System.getProperty(%22java.net.socks.password%22);%0A    if (!username.isEmpty()) %7B%0A      Authenticator.setDefault(new ProxyAuthenticator(username, password));%0A    %7D%0A%0A    BrokerRunner runner = new BrokerRunner();%0A    runner.processCmdLine(args);%0A    %0A    // if we get here, it's time to exit%0A    System.exit(0);%0A  %7D%0A%0A  private static class ProxyAuthenticator extends Authenticator%0A  %7B%0A    private String userName, password;%0A%0A    private ProxyAuthenticator (String userName, String password)%0A    %7B%0A      this.userName = userName;%0A      this.password = password;%0A    %7D%0A%0A    protected PasswordAuthentication getPasswordAuthentication ()%0A    %7B%0A      return new PasswordAuthentication(userName, password.toCharArray());%0A    %7D
 %0A  %7D

Add Authenticator for proxy users