UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("mo", "password");
client.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY), credentials);
ClientRequest request = new ClientRequest(generateURL("/secured/authorized"), executor);
ClientResponse<?> response = request.get();
Assert.assertEquals(HttpResponseCodes.SC_FORBIDDEN, response.getStatus());
response.releaseConnection();
}
}
/**
* Create a ClientExecutor which does preemptive authentication.