org.apache.hc.client5.http.impl.auth

## Class BasicAuthCache

- java.lang.Object
- - org.apache.hc.client5.http.impl.auth.BasicAuthCache

- All Implemented Interfaces:
    AuthCache

      @Contract(threading=SAFE_CONDITIONAL)
      public class BasicAuthCache
      extends Object
      implements AuthCache

  Default implementation of `AuthCache`. This implements expects `AuthScheme` to be `Serializable` in order to be cacheable.

  Instances of this class are thread safe as of version 4.4.

  Since:
    4.1

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicAuthCache()`
    `BasicAuthCache(SchemePortResolver schemePortResolver)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `AuthScheme` | `get(org.apache.hc.core5.http.HttpHost host)` Returns the authentication state with the given authentication scope from the cache if available.
    `AuthScheme` | `get(org.apache.hc.core5.http.HttpHost host, String pathPrefix)` Returns the authentication state with the given authentication scope from the cache if available.
    `void` | `put(org.apache.hc.core5.http.HttpHost host, AuthScheme authScheme)` Stores the authentication state with the given authentication scope in the cache.
    `void` | `put(org.apache.hc.core5.http.HttpHost host, String pathPrefix, AuthScheme authScheme)` Stores the authentication state with the given authentication scope in the cache.
    `void` | `remove(org.apache.hc.core5.http.HttpHost host)` Removes the authentication state with the given authentication scope from the cache if found.
    `void` | `remove(org.apache.hc.core5.http.HttpHost host, String pathPrefix)` Removes the authentication state with the given authentication scope from the cache if found.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BasicAuthCache

          public BasicAuthCache(SchemePortResolver schemePortResolver)

      Default constructor.
      Since:
        4.3

    - #### BasicAuthCache

          public BasicAuthCache()

  - ### Method Detail

    - #### put

          public void put(org.apache.hc.core5.http.HttpHost host,
                          AuthScheme authScheme)

      Description copied from interface: `AuthCache`
      Stores the authentication state with the given authentication scope in the cache.
      Specified by:
        `put` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.
        `authScheme` - the cacheable authentication state.

    - #### get

          public AuthScheme get(org.apache.hc.core5.http.HttpHost host)

      Description copied from interface: `AuthCache`
      Returns the authentication state with the given authentication scope from the cache if available.
      Specified by:
        `get` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.
      Returns:
        the authentication state ir `null` if not available in the cache.

    - #### remove

          public void remove(org.apache.hc.core5.http.HttpHost host)

      Description copied from interface: `AuthCache`
      Removes the authentication state with the given authentication scope from the cache if found.
      Specified by:
        `remove` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.

    - #### put

          public void put(org.apache.hc.core5.http.HttpHost host,
                          String pathPrefix,
                          AuthScheme authScheme)

      Description copied from interface: `AuthCache`
      Stores the authentication state with the given authentication scope in the cache.
      Specified by:
        `put` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.
        `pathPrefix` - the path prefix (the path component up to the last segment separator). Can be `null`.
        `authScheme` - the cacheable authentication state.

    - #### get

          public AuthScheme get(org.apache.hc.core5.http.HttpHost host,
                                String pathPrefix)

      Description copied from interface: `AuthCache`
      Returns the authentication state with the given authentication scope from the cache if available.
      Specified by:
        `get` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.
        `pathPrefix` - the path prefix (the path component up to the last segment separator). Can be `null`.
      Returns:
        the authentication state ir `null` if not available in the cache.

    - #### remove

          public void remove(org.apache.hc.core5.http.HttpHost host,
                             String pathPrefix)

      Description copied from interface: `AuthCache`
      Removes the authentication state with the given authentication scope from the cache if found.
      Specified by:
        `remove` in interface `AuthCache`
      Parameters:
        `host` - the authentication authority.
        `pathPrefix` - the path prefix (the path component up to the last segment separator). Can be `null`.

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `AuthCache`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.