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

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    final AuthCache authCache = clientContext.getAuthCache();
    if (authCache != null) {
      if (Logger.isLoggable(TAG, Logger.DEBUG)) {
        Logger.d(TAG, "Clearing cached auth scheme for " + authhost);
      }
      authCache.remove(authhost);
    }
  }
  public void authSucceeded(
      final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
    Args.notNull(authhost, "Host");
    Args.notNull(authScheme, "Auth scheme");
    Args.notNull(context, "HTTP context");

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    if (isCachable(authScheme)) {
      AuthCache authCache = clientContext.getAuthCache();
      if (authCache == null) {
        authCache = new BasicAuthCache();
        clientContext.setAuthCache(authCache);
      }
      if (Logger.isLoggable(TAG, Logger.DEBUG)) {
        Logger.d(TAG, "Caching '" + authScheme.getSchemeName() + "' auth scheme for " + authhost);
      }
      authCache.put(authhost, authScheme);
    }
  }