// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends RuntimeException {
// 
//   public ApiException(String message) {
//     super(message);
//   }
// 
//   public ApiException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// 
//   public ApiException(ErrorResponse response, Throwable throwable) {
//     super(response.getError(), throwable);
//   }
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/AppsManager.java
// public interface AppsManager {
// 
//   AppsResponse getApps(WebResource resource, ResourcePath<Apps> appsResponsePath);
// 
//   AppResponse postNewApp(WebResource resource, ResourcePath<Apps> appsResponsePath,
//       AppDetailsRequest appsRequest, File file);
// 
//   AppResponse getApp(WebResource resource, ResourcePath<App> appResourcePath);
// 
//   AppResponse putApp(WebResource resource, ResourcePath<App> appResourcePath, AppDetailsRequest appsRequest,
//       File file);
// 
//   SuccessResponse deleteApp(WebResource resource, ResourcePath<App> appResourcePath);
// 
//   File downloadApp(WebResource resource, ResourcePath<App> appResourcePath, Platform platform,
//       File targetDirectory);
// 
//   AppResponse updateAppDetails(WebResource resource, ResourcePath<App> keyResourcePath,
// 	      AppDetailsRequest appDetailsRequest);
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/KeysManager.java
// public interface KeysManager {
// 
//   public SuccessResponse deleteKey(WebResource resource, ResourcePath<Key> keyResourcePath);
// 
//   public IOsKeyResponse postNewKey(WebResource resource, ResourcePath<PlatformKeys> platformResourcePath,
//       IOsKeyRequest iOsKeyRequest, File cert, File profile);
// 
//   AndroidKeyResponse postNewKey(WebResource resource, ResourcePath<PlatformKeys> platformResourcePath,
//       AndroidKeyRequest androidKeyRequest, File keystore);
// 
//   public IOsKeyResponse unlockKey(WebResource resource, ResourcePath<Key> keyResourcePath,
//       IOsKeyUnlockRequest iOsKeyUnlockRequest);
// 
//   public AndroidKeyResponse unlockKey(WebResource resource, ResourcePath<Key> keyResourcePath,
//       AndroidKeyUnlockRequest androidKeyUnlockRequest);
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/MeManager.java
// public interface MeManager {
// 
//   public static final String API_V1_PATH = "/api/v1";
//   public static final String TOKEN_PATH = "/token";
// 
//   public WebResource createRootWebResource(String username, String password);
// 
//   public WebResource createRootWebResource(String username, String password, String proxyUri);
//   public WebResource createRootWebResource(String username, String password, String proxyUri, String proxyUser, String proxyPwd);
// 
//   public MeResponse requestMe(WebResource resource);
// 
// }


import java.net.URI;
import java.net.URISyntaxException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.proxy.ProxyInfo;
import com.github.chrisprice.phonegapbuild.api.ApiException;
import com.github.chrisprice.phonegapbuild.api.managers.AppsManager;
import com.github.chrisprice.phonegapbuild.api.managers.KeysManager;
import com.github.chrisprice.phonegapbuild.api.managers.MeManager;
import com.sun.jersey.api.client.WebResource;
      ProxyInfo proxyInfo = wagonManager.getProxy("http");
      if (proxyInfo != null) {
        try {
    		  getLog().info("Using Proxy username : " + proxyInfo.getUserName() );
    		  
    		  URI uri = new URI("http", null, proxyInfo.getHost(), proxyInfo.getPort(), null, null, null);
    		  
    		  rootWebResource = meManager.createRootWebResource(username, password, uri.toString(), proxyInfo.getUserName(), proxyInfo.getPassword() );
    	  } catch (URISyntaxException e) {
    		  throw new ApiException("Could not load http proxy settings", e);
    	  }
      } else {
        rootWebResource = meManager.createRootWebResource(username, password);
      }
    }
    return rootWebResource;
  }

  public void setWagonManager(WagonManager wagonManager) {
    this.wagonManager = wagonManager;
  }

  public void setServer(String server) {
    this.server = server;
  }

  public void setMeManager(MeManager meManager) {
    this.meManager = meManager;
  }

// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends RuntimeException {
// 
//   public ApiException(String message) {
//     super(message);
//   }
// 
//   public ApiException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// 
//   public ApiException(ErrorResponse response, Throwable throwable) {
//     super(response.getError(), throwable);
//   }
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/AppsManager.java
// public interface AppsManager {
// 
//   AppsResponse getApps(WebResource resource, ResourcePath<Apps> appsResponsePath);
// 
//   AppResponse postNewApp(WebResource resource, ResourcePath<Apps> appsResponsePath,
//       AppDetailsRequest appsRequest, File file);
// 
//   AppResponse getApp(WebResource resource, ResourcePath<App> appResourcePath);
// 
//   AppResponse putApp(WebResource resource, ResourcePath<App> appResourcePath, AppDetailsRequest appsRequest,
//       File file);
// 
//   SuccessResponse deleteApp(WebResource resource, ResourcePath<App> appResourcePath);
// 
//   File downloadApp(WebResource resource, ResourcePath<App> appResourcePath, Platform platform,
//       File targetDirectory);
// 
//   AppResponse updateAppDetails(WebResource resource, ResourcePath<App> keyResourcePath,
// 	      AppDetailsRequest appDetailsRequest);
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/KeysManager.java
// public interface KeysManager {
// 
//   public SuccessResponse deleteKey(WebResource resource, ResourcePath<Key> keyResourcePath);
// 
//   public IOsKeyResponse postNewKey(WebResource resource, ResourcePath<PlatformKeys> platformResourcePath,
//       IOsKeyRequest iOsKeyRequest, File cert, File profile);
// 
//   AndroidKeyResponse postNewKey(WebResource resource, ResourcePath<PlatformKeys> platformResourcePath,
//       AndroidKeyRequest androidKeyRequest, File keystore);
// 
//   public IOsKeyResponse unlockKey(WebResource resource, ResourcePath<Key> keyResourcePath,
//       IOsKeyUnlockRequest iOsKeyUnlockRequest);
// 
//   public AndroidKeyResponse unlockKey(WebResource resource, ResourcePath<Key> keyResourcePath,
//       AndroidKeyUnlockRequest androidKeyUnlockRequest);
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/managers/MeManager.java
// public interface MeManager {
// 
//   public static final String API_V1_PATH = "/api/v1";
//   public static final String TOKEN_PATH = "/token";
// 
//   public WebResource createRootWebResource(String username, String password);
// 
//   public WebResource createRootWebResource(String username, String password, String proxyUri);
//   public WebResource createRootWebResource(String username, String password, String proxyUri, String proxyUser, String proxyPwd);
// 
//   public MeResponse requestMe(WebResource resource);
// 
// }


// Path: plugin/src/main/java/com/github/chrisprice/phonegapbuild/plugin/AbstractPhoneGapBuildMojo.java
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.proxy.ProxyInfo;
import com.github.chrisprice.phonegapbuild.api.ApiException;
import com.github.chrisprice.phonegapbuild.api.managers.AppsManager;
import com.github.chrisprice.phonegapbuild.api.managers.KeysManager;
import com.github.chrisprice.phonegapbuild.api.managers.MeManager;
import com.sun.jersey.api.client.WebResource;

      ProxyInfo proxyInfo = wagonManager.getProxy("http");
      if (proxyInfo != null) {
        try {
    		  getLog().info("Using Proxy username : " + proxyInfo.getUserName() );
    		  
    		  URI uri = new URI("http", null, proxyInfo.getHost(), proxyInfo.getPort(), null, null, null);
    		  
    		  rootWebResource = meManager.createRootWebResource(username, password, uri.toString(), proxyInfo.getUserName(), proxyInfo.getPassword() );
    	  } catch (URISyntaxException e) {
    		  throw new ApiException("Could not load http proxy settings", e);
    	  }
      } else {
        rootWebResource = meManager.createRootWebResource(username, password);
      }
    }
    return rootWebResource;
  }

  public void setWagonManager(WagonManager wagonManager) {
    this.wagonManager = wagonManager;
  }

  public void setServer(String server) {
    this.server = server;
  }

  public void setMeManager(MeManager meManager) {
    this.meManager = meManager;
  }

  public void setAppsManager(AppsManager appsManager) {