// Set authentication
if (_config.isBasicAuth()) {
_authScope = createAuthScope(_config.getBasicAuthConfig().getHost(), _config.getBasicAuthConfig().getPort(), _config.getBasicAuthConfig().getRealm());
_credentials = new UsernamePasswordCredentials(_config.getBasicAuthConfig().getUser(), _config.getBasicAuthConfig().getPassword());
// Create AuthCache instance
_authCache = new BasicAuthCache();
_authCache.put(new HttpHost(_authScope.getHost(), _authScope.getPort()), new BasicScheme(ChallengeState.TARGET));
} else {
_authScope = createAuthScope(_config.getNtlmAuthConfig().getHost(), _config.getNtlmAuthConfig().getPort(), _config.getNtlmAuthConfig().getRealm());
_credentials = new NTCredentials(_config.getNtlmAuthConfig().getUser(),
_config.getNtlmAuthConfig().getPassword(),
"",
_config.getNtlmAuthConfig().getDomain());
}
}
if (_config.getProxyConfig() != null) {
if (_config.getProxyConfig().getPort() != null) {
_proxyHost = new HttpHost(_config.getProxyConfig().getHost(), Integer.valueOf(_config.getProxyConfig().getPort()).intValue());
} else {
_proxyHost = new HttpHost(_config.getProxyConfig().getHost(), -1);
}
if (_config.getProxyConfig().getUser() != null) {
_authScope = createAuthScope(_config.getProxyConfig().getHost(), _config.getProxyConfig().getPort(), null);
_credentials = new UsernamePasswordCredentials(_config.getProxyConfig().getUser(), _config.getProxyConfig().getPassword());
if (_authCache == null) {
_authCache = new BasicAuthCache();
}
_authCache.put(_proxyHost, new BasicScheme(ChallengeState.PROXY));
}
}
_timeout = _config.getTimeout();