coinbase / coinbase-java

Coinbase API v1 library for Java
Apache License 2.0
149 stars 98 forks source link

Added Coinbase custom connection support for thrid party system that cannot use default URL connection implementation #7

Closed dincek closed 9 years ago

dincek commented 9 years ago

Hi,

I tried to use official library on Google AppEngine and I found out that URLConnection urlConnection = url.openConnection() does not return HttpsURLConnection, this caused that library could not be used.

So I prepared fix for your official, so that Google AppEngine users can inject their CoinbaseConnection implementation which uses Google URL Fetch Service and wrapped your offical way in CoinbaseConnection implementation CoinbaseConnectionImpl.java. I added CoinbaseBuilder().withCoinbaseConnection(connection) function to inject custom implementation. Your tests are still OK.

Could you pull changes to official library? If you will, I will prepare and release package coinbase-java-appengine to add support for Google App Engine users.

Thanks, Dean Gostiša

dincek commented 9 years ago

Will this be merged to master?

aianus commented 9 years ago

Hey, thanks for the PR and sorry for the delay in responding.

I didn't know Google App Engine did this, that's really frustrating.

Does Google App Engine allow for pinned certificates? The reason we cast to HttpsURLConnection is so we can manually validate the connection's cert against the one included with the library and I wouldn't recommend using the library in production without this feature.

Separately, if we do want to merge this, why do you prefer releasing a separate package with the Google App Engine connection implementation? I think it'd be better to include the alternate connection implementation in the official library and add a short blurb to the README, no?

dincek commented 9 years ago

Hi,

Google App Engine does not allow custom pinned certificates, but it supports pinning connection to trusted certificates (signed by trusted root). But to do this pinned connection to trusted certificate on HTTP fetch I had to use Google AppEngine SDK functions.

I restructured base project and added support for Google AppEngine. Please check out my new pull request.

Dean