Came up with this solution:
String userId = "myName";
String password = "verySecret";
Credentials credentials = new UsernamePasswordCredentials(userId, password);
HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(AuthScope.ANY, credentials);
httpClient.getParams().setAuthenticationPreemptive(true);
ClientExecutor clientExecutor = new ApacheHttpClientExecutor(httpClient);
try {
URI uri = new URI("http://.....");
ClientRequestFactory fac = new ClientRequestFactory(clientExecutor,uri);
ClientRequest request = fac.createRequest("http://.....);
I don't know if there is a better way, as there are a lot of steps to do here. Just thought I should share as documentation is a little sparse here.
2 comments:
Yep, we are doing it about the same way, but using the apache4 client.
Combined this with SSL and You get a pretty good security.
Hello
Can you post sample working example?
Thanks in advance.
Post a Comment