private void useCredentials(DefaultHttpClient httpClient, PasswordCredentials credentials, String host, int port) {
Credentials basicCredentials = new UsernamePasswordCredentials(credentials.getUsername(), credentials.getPassword());
httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port), basicCredentials);
NTLMCredentials ntlmCredentials = new NTLMCredentials(credentials);
Credentials ntCredentials = new NTCredentials(ntlmCredentials.getUsername(), ntlmCredentials.getPassword(), ntlmCredentials.getWorkstation(), ntlmCredentials.getDomain());
httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthPolicy.NTLM), ntCredentials);
LOGGER.debug("Using {} and {} for authenticating against '{}:{}'", new Object[]{credentials, ntlmCredentials, host, port});
}