final Scheme scheme = schemeRegistry.getScheme(target);
target = new HttpHost(target.getHostName(),
scheme.resolvePort(target.getPort()), target.getSchemeName());
}
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
}
switch (targetState.getState()) { // TODO add SUCCESS, UNCHALLENGED and HANDSHAKE cases
case CHALLENGED:
cache(authCache, target, targetState.getAuthScheme());
break;
case FAILURE:
uncache(authCache, target, targetState.getAuthScheme());
}
}
}
final HttpHost proxy = (HttpHost) context.getAttribute(ExecutionContext.HTTP_PROXY_HOST);
final AuthState proxyState = (AuthState) context.getAttribute(ClientContext.PROXY_AUTH_STATE);
if (proxy != null && proxyState != null) {
if (this.log.isDebugEnabled()) {
this.log.debug("Proxy auth state: " + proxyState.getState());
}
if (isCachable(proxyState)) {
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
}
switch (proxyState.getState()) { // TODO add SUCCESS, UNCHALLENGED and HANDSHAKE cases
case CHALLENGED:
cache(authCache, proxy, proxyState.getAuthScheme());