Class HTTPAuthCache

  • All Implemented Interfaces:
    org.apache.http.client.AuthCache

    @ThreadSafe
    public class HTTPAuthCache
    extends org.apache.http.impl.client.BasicAuthCache
    It turns out that the Apache httpclient code is not well setup to handle dynamic credentials providers such as UrlAuthenticatorDialog. These providers will ask the user on the fly to provide a set of credentials (typically username+pwd). The provider can be set up to cache credentials (again see UrlAuthenticatorDialog), but in the event that the user gives bad credentials, the provider cache clear function does not get called by AuthCache. So, as a work-around, we use our own implementation of BasicAuthCache that stores a list of credentials providers and when the AuthCache.remove function is called, it forwards it to the either the clear() function of the provider, or, if it is an instance of HTTPCredentialsProvider, it will call the remove function to provide finer-grain control. This is an awful hack, but seems to be the simplest solution.
    • Constructor Detail

      • HTTPAuthCache

        public HTTPAuthCache​(org.apache.http.conn.SchemePortResolver schemePortResolver)
      • HTTPAuthCache

        public HTTPAuthCache()
    • Method Detail

      • remove

        public void remove​(org.apache.http.HttpHost host)
        Specified by:
        remove in interface org.apache.http.client.AuthCache
        Overrides:
        remove in class org.apache.http.impl.client.BasicAuthCache
      • addProvider

        public HTTPAuthCache addProvider​(org.apache.http.client.CredentialsProvider cp)
      • removeProvider

        public HTTPAuthCache removeProvider​(org.apache.http.client.CredentialsProvider cp)