public void authFailed(HttpHost authhost, AuthScheme authScheme, HttpContext context) {
    Args.notNull(authhost, "Host");
    Args.notNull(context, "HTTP context");

    HttpClientContext clientContext = HttpClientContext.adapt(context);

    AuthCache authCache = clientContext.getAuthCache();
    if (authCache != null) {
      if (this.log.isDebugEnabled()) {
        this.log.debug("Clearing cached auth scheme for " + authhost);
      }
      authCache.remove(authhost);
    }
  }
  public void authSucceeded(HttpHost authhost, AuthScheme authScheme, HttpContext context) {
    Args.notNull(authhost, "Host");
    Args.notNull(authScheme, "Auth scheme");
    Args.notNull(context, "HTTP context");

    HttpClientContext clientContext = HttpClientContext.adapt(context);
    if (isCachable(authScheme)) {
      AuthCache authCache = clientContext.getAuthCache();
      if (authCache == null) {
        authCache = new BasicAuthCache();
        clientContext.setAuthCache(authCache);
      }
      if (this.log.isDebugEnabled()) {
        this.log.debug("Caching '" + authScheme.getSchemeName() + "' auth scheme for " + authhost);
      }
      authCache.put(authhost, authScheme);
    }
  }