This snippet may also help or inform. It does not use any Apache client
bits:
ClientConfig cc = new DefaultClientConfig();
HTTPSProperties httpsProps = new HTTPSProperties(null,
getlSslContext());
cc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
httpsProps);
client = Client.create(cc);
The getSslContext() returns an SSLContext that implements your custom Key-
and TrustManagers.
On Sun, Feb 20, 2011 at 6:19 AM, Christopher Piggott <cpiggott_at_gmail.com>wrote:
> Got it, thanks.
>
> I did file a JIRA enhancement request on this. I fumbled for words,
> though - I don't really know the right way to solve this.
>
> My "ideal" solution would be everything gets done via guice :-) but
> that doesn't help non-guice users, does it.
>
> --Chris
>
>
>
> DefaultApacheHttpClientConfig cc = new
> DefaultApacheHttpClientConfig();
> cc.getState().setCredentials(null, null, -1, login, password);
>
> HostConfiguration hostConfig = new HostConfiguration();
> // set local source address here
>
> HttpClient apacheClient = new HttpClient();
> apacheClient.setHostConfiguration(hostConfig);
>
>
> ApacheHttpClientHandler handler = new
> ApacheHttpClientHandler(apacheClient, cc);
> ApacheHttpClient jerseyClient = new ApacheHttpClient(handler);
> jerseyClient.addFilter(new GZIPContentEncodingFilter(true));
>
> On Sun, Feb 20, 2011 at 3:50 AM, Petr Jurák <petr.jurak_at_gmail.com> wrote:
> > Hi,
> > look at ApacheHttpClient and ApacheHttpClientHandler. You can create
> > Apache client, pass it to handler and use that handler in
> > com.sun.jersey.client.apache.ApacheHttpClient.
> > But I think, there is no way to achieve this behavior with
> > com.sun.jersey.api.client.Client. I think you can create on Jira new
> > improvement task for this.
> > Regards,
> > Petr
> >
> > 2011/2/20 Christopher Piggott <cpiggott_at_gmail.com>:
> >> Hi,
> >>
> >> On Fri, Feb 11, 2011 at 9:59 AM, Petr Jurák <petr.jurak_at_gmail.com>
> wrote:
> >>> Ok, I see what you want.
> >>> So try jersey with apache client:
> >>>
> >>> HostConfiguration hostConfiguration = new HostConfiguration();
> >>> byte b[] = new byte[4];
> >>> b[0] = new Integer(192).byteValue();
> >>> b[1] = new Integer(168).byteValue();
> >>> b[2] = new Integer(1).byteValue();
> >>> b[3] = new Integer(11).byteValue();
> >>>
> >>> hostConfiguration.setLocalAddress(InetAddress.getByAddress(b));
> >>> HttpClient client = new HttpClient();
> >>> client.setHostConfiguration(hostConfiguration);
> >>>
> >>> Something like that. I hope this help.
> >>>
> >>> Regards,
> >>> Petr
> >>
> >> That gets me an HttpClient object, but how do I get from there to a
> >> jersey client (com.sun.jersey.api.client.Client) ?
> >>
> >
>
--
Mark