Since HttpClient 4.3, I have been using the HttpClientBuilder. I am connecting to a REST service that has basic authentication. I am setting the credentials as follows:
Actually, since you already trust the server, it's probably easiest to just construct the authorization header yourself.
byte[] credentials = Base64.encodeBase64((username + ":" + password).getBytes(StandardCharsets.UTF_8));
request.setHeader("Authorization", "Basic " + new String(credentials, StandardCharsets.UTF_8));
httpClient.execute(request);
This is just one of those cases were it's easier to read the spec, and roll it yourself.