RESTEasy (a JAX-RS implementation) has a nice client framework, eg:
ServiceApi client = ProxyFactory.create(ServiceApi.class, baseUri);
How do you provide HTTP authentication credentials to this client?
RESTEasy (a JAX-RS implementation) has a nice client framework, eg:
ServiceApi client = ProxyFactory.create(ServiceApi.class, baseUri);
How do you provide HTTP authentication credentials to this client?
Credentials can be provided by using ClientExecutor.
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);
ServiceApi client = ProxyFactory.create(ServiceApi.class, baseUri, clientExecutor);