users@jersey.java.net

[Jersey] Re: Jersey 2 client rest help with SSL

From: Miroslav Fuksa <miroslav.fuksa_at_oracle.com>
Date: Wed, 26 Jun 2013 10:45:43 +0200

Hi,

I am not sure exactly about your case of Paypal Rest API but Oauth2 in
general requires using of SSL when access token is being sent. How to
configure the security of the client is described in the user guide:

https://jersey.java.net/documentation/latest/client.html#d0e3156

Basically, you need to setup SSLContext and use it when building new client:

Client client = ClientBuilder.newBuilder().sslContext(sslContext).build();

  

You can use jersey specific or.glassfish.jersey.SslConfigurator to setup
SSLContext. Here you can also configure keystore and truststore. Then
you need to use "https" schema in request URIs.

Mira

On 06/25/2013 05:48 PM, Kevin Duffey wrote:
> Hi all,
>
> I am trying to work with the Paypal Rest API, and can't get past the
> first call to get an access token. I am posting a form with one
> parameter to https://api.sandbox.paypal.com/v1/oauth2/token. The
> response I get back is 406.. thus my mediatype is correct and headers
> are correct, but the body I am sending in is not being accepted. I've
> followed the example on the Jersey 2 documentation on how to post a form.
>
> At this point, my one thought is that the URL is https and that I am
> sending it without any SSL context.
>
> So, I do not quite understand what is involved in setting up a client
> side SSL cert and how I go about it using it with Jersey. Jersey 2 is
> so new there isn't any examples I can find. Can anyone point me to a
> url or two that explains how I would set up my client side with a
> proper SSL cert..preferably something free for development use?
>
> I also want to make sure that this can be done on my web server
> (Glassfish 4) so that I can make the api calls from my web app once
> deployed. In other words, my JEE7 web app is using Jersey client to
> make rest calls to paypal on behalf of my app users.
>
> Thank you.