chrisprice / phonegap-build

This project aims to provide a stand-alone Java API for communicating with the PhoneGap Build REST API and a Maven Plugin which makes use of the API to turn WAR projects into binaries for mobile platforms.
http://chrisprice.github.com/phonegap-build/phonegap-build-maven-plugin
Apache License 2.0
11 stars 18 forks source link

Maven Proxy credentials settings not used #15

Closed FredChap closed 10 years ago

FredChap commented 10 years ago

In method getRootWebResource of class AbstractPhoneGapBuildMojo, proxy credentials are not used. Instead the Phonegap Build server credentials are used which fails when building behind a proxy.

FredChap commented 10 years ago

Hello,

Starting from the 0.0.7-SNAPSHOT sources, I could have it work behind a proxy requiring authentication. Here below is what I did.

Suggested fix in the API:

  1. Add new method signature in interface MeManager.java: public WebResource createRootWebResource(String username, String password, String proxyUri, String proxyUser, String proxyPwd);
  2. Replace previous createRootWebResource method implementation with a call to new method signature: @Override public WebResource createRootWebResource(String username, String password, String proxyUri) { return createRootWebResource(username, password, proxyUri, null, null); }
  3. Add following code in new method implementation of class MeManagerImpl.java: ... // set proxy auth credentials if ( proxyUser != null & proxyPwd != null ) { config.getState().setProxyCredentials(null, null, -1, proxyUser, proxyPwd ); } // set http auth credentials ...

Corresponding fix in the plugin class AbstractPhoneGapBuildMojo.java : 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); }

chrisprice commented 10 years ago

I'm glad you fixed your problem and thanks for providing the solution, if you're willing to put it into a PR I can make it available to others?

On Tue, Feb 4, 2014 at 12:57 PM, FredChap notifications@github.com wrote:

Hello,

Starting from the 0.0.7-SNAPSHOT sources, I could have it work behind a proxy requiring authentication. Here below is what I did.

Suggested fix in the API:

  1. Add new method signature in interface MeManager.java: public WebResource createRootWebResource(String username, String password, String proxyUri, String proxyUser, String proxyPwd);
  2. Replace previous createRootWebResource method implementation with a call to new method signature: @Override https://github.com/Override public WebResource createRootWebResource(String username, String password, String proxyUri) { return createRootWebResource(username, password, proxyUri, null, null); }
  3. Add following code in new method implementation of class MeManagerImpl.java: ... // set proxy auth credentials if ( proxyUser != null & proxyPwd != null ) { config.getState().setProxyCredentials(null, null, -1, proxyUser, proxyPwd ); } // set http auth credentials ...

Corresponding fix in the plugin class AbstractPhoneGapBuildMojo.java : 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); }

Reply to this email directly or view it on GitHubhttps://github.com/chrisprice/phonegap-build/issues/15#issuecomment-34056567 .

FredChap commented 10 years ago

Sure you can, do you want me to send the complete files ?

chrisprice commented 10 years ago

That would be great, ideally as part of a pull request.

FredChap commented 10 years ago

Ok, it's been forked and pushed. Don't know exactly how it works but I guess you are the one who can pull the changes for a future release.

chrisprice commented 10 years ago

Normally you'd just press the Pull Request button, but I managed to find this site which let me do it for you.

Thanks again, I'll pull this in and do a release as soon as I get a chance.

buildhive commented 10 years ago

Chris Price » phonegap-build #59 UNSTABLE Looks like there's a problem with this pull request (what's this?)

chrisprice commented 10 years ago

Doh, it looks like there's a test failure.

FredChap commented 10 years ago

Yes, I've seen that, I did all this skipping tests. I'll have a look asap.

FredChap commented 10 years ago

Well I know nothing about jmock so I will need some advice. Apparently, since I am calling the new method with 2 strings added for credential information, I guess test method testGetRootWebResource_proxySpecifiedPositive() should check something like: oneOf(meManager).createRootWebResource("user", "pass", "http://localhost:8888",null,null); Right ?

buildhive commented 10 years ago

Chris Price » phonegap-build #60 SUCCESS This pull request looks good (what's this?)