Credentials credentials = null;
if (model.isBasicAuth()) {
authScope = createAuthScope(model.getBasicAuthConfig().getHost(), model.getBasicAuthConfig().getPort(), model.getBasicAuthConfig().getRealm());
credentials = new UsernamePasswordCredentials(model.getBasicAuthConfig().getUser(), model.getBasicAuthConfig().getPassword());
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
authCache.put(new HttpHost(authScope.getHost(), authScope.getPort()), new BasicScheme(ChallengeState.TARGET));
BasicHttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
((ApacheHttpClient4Executor)_executor).setHttpContext(context);
} else {
authScope = createAuthScope(model.getNtlmAuthConfig().getHost(), model.getNtlmAuthConfig().getPort(), model.getNtlmAuthConfig().getRealm());
credentials = new NTCredentials(model.getNtlmAuthConfig().getUser(),
model.getNtlmAuthConfig().getPassword(),
"",
model.getNtlmAuthConfig().getDomain());
}
((DefaultHttpClient)httpClient).getCredentialsProvider().setCredentials(authScope, credentials);
} else {
ProxyModel proxy = model.getProxyConfig();
if (proxy != null) {
HttpHost proxyHost = null;
if (proxy.getPort() != null) {
proxyHost = new HttpHost(proxy.getHost(), Integer.valueOf(proxy.getPort()).intValue());
} else {
proxyHost = new HttpHost(proxy.getHost(), -1);
}
if (proxy.getUser() != null) {
AuthScope authScope = new AuthScope(proxy.getHost(), Integer.valueOf(proxy.getPort()).intValue(), AuthScope.ANY_REALM);
Credentials credentials = new UsernamePasswordCredentials(proxy.getUser(), proxy.getPassword());
AuthCache authCache = new BasicAuthCache();
authCache.put(proxyHost, new BasicScheme(ChallengeState.PROXY));
((DefaultHttpClient)httpClient).getCredentialsProvider().setCredentials(authScope, credentials);
BasicHttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
((ApacheHttpClient4Executor)_executor).setHttpContext(context);
}