Top Description Inners Fields Constructors Methods
org.apache.hc.client5.http.impl.auth

public Class BasicAuthCache

extends Object
implements AuthCache
Class Inheritance
All Implemented Interfaces
org.apache.hc.client5.http.auth.AuthCache
Annotations
@Contract
threading:SAFE_CONDITIONAL
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.util.Locale, .Map, .Objects, java.util.concurrent.ConcurrentHashMap, org.apache.hc.client5.http.SchemePortResolver, org.apache.hc.client5.http.auth.AuthCache, .AuthScheme, org.apache.hc.client5.http.impl.DefaultSchemePortResolver, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.HttpHost, org.apache.hc.core5.net.NamedEndpoint, org.apache.hc.core5.util.Args, .LangUtils, org.slf4j.Logger, .LoggerFactory

Default implementation of AuthCache. This implements expects org.apache.hc.client5.http.auth.AuthScheme to be java.io.Serializable in order to be cacheable.

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

Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Logger
private final Map<BasicAuthCache.Key, byte[]>
private final SchemePortResolver

Constructor Summary

AccessConstructor and Description
public
BasicAuthCache(final SchemePortResolver schemePortResolver)

Default constructor.

public

Method Summary

Modifier and TypeMethod and Description
public void
public AuthScheme
get(final HttpHost
the authentication authority.
host
)

Implements org.apache.hc.client5.http.auth.AuthCache.get.

Returns the authentication state with the given authentication scope from the cache if available.
public AuthScheme
get(final HttpHost
the authentication authority.
host
,
final String
the path prefix (the path component up to the last segment separator). Can be null.
pathPrefix
)

Overrides default org.apache.hc.client5.http.auth.AuthCache.get.

Returns the authentication state with the given authentication scope from the cache if available.
private BasicAuthCache.Key
key(final String scheme, final NamedEndpoint authority, final String pathPrefix)

public void
put(final HttpHost
the authentication authority.
host
,
final AuthScheme
the cacheable authentication state.
authScheme
)

Implements org.apache.hc.client5.http.auth.AuthCache.put.

Stores the authentication state with the given authentication scope in the cache.
public void
put(final HttpHost
the authentication authority.
host
,
final String
the path prefix (the path component up to the last segment separator). Can be null.
pathPrefix
,
final AuthScheme
the cacheable authentication state.
authScheme
)

Overrides default org.apache.hc.client5.http.auth.AuthCache.put.

Stores the authentication state with the given authentication scope in the cache.
public void
remove(final HttpHost
the authentication authority.
host
)

Implements org.apache.hc.client5.http.auth.AuthCache.remove.

Removes the authentication state with the given authentication scope from the cache if found.
public void
remove(final HttpHost
the authentication authority.
host
,
final String
the path prefix (the path component up to the last segment separator). Can be null.
pathPrefix
)

Overrides default org.apache.hc.client5.http.auth.AuthCache.remove.

Removes the authentication state with the given authentication scope from the cache if found.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
mapback to summary
private final Map<BasicAuthCache.Key, byte[]> map
schemePortResolverback to summary
private final SchemePortResolver schemePortResolver

Constructor Detail

BasicAuthCacheback to summary
public BasicAuthCache(final SchemePortResolver schemePortResolver)

Default constructor.

Since
4.3
BasicAuthCacheback to summary
public BasicAuthCache()

Method Detail

clearback to summary
public void clear()

Implements org.apache.hc.client5.http.auth.AuthCache.clear.

Annotations
@Override
getback to summary
public AuthScheme get(final HttpHost host)

Implements org.apache.hc.client5.http.auth.AuthCache.get.

Doc from org.apache.hc.client5.http.auth.AuthCache.get.

Returns the authentication state with the given authentication scope from the cache if available.

Parameters
host:HttpHost

the authentication authority.

Returns:AuthScheme

the authentication state ir null if not available in the cache.

Annotations
@Override
getback to summary
public AuthScheme get(final HttpHost host, final String pathPrefix)

Overrides default org.apache.hc.client5.http.auth.AuthCache.get.

Doc from org.apache.hc.client5.http.auth.AuthCache.get.

Returns the authentication state with the given authentication scope from the cache if available.

Parameters
host:HttpHost

the authentication authority.

pathPrefix:String

the path prefix (the path component up to the last segment separator). Can be null.

Returns:AuthScheme

the authentication state ir null if not available in the cache.

Annotations
@Override
keyback to summary
private BasicAuthCache.Key key(final String scheme, final NamedEndpoint authority, final String pathPrefix)
putback to summary
public void put(final HttpHost host, final AuthScheme authScheme)

Implements org.apache.hc.client5.http.auth.AuthCache.put.

Doc from org.apache.hc.client5.http.auth.AuthCache.put.

Stores the authentication state with the given authentication scope in the cache.

Parameters
host:HttpHost

the authentication authority.

authScheme:AuthScheme

the cacheable authentication state.

Annotations
@Override
putback to summary
public void put(final HttpHost host, final String pathPrefix, final AuthScheme authScheme)

Overrides default org.apache.hc.client5.http.auth.AuthCache.put.

Doc from org.apache.hc.client5.http.auth.AuthCache.put.

Stores the authentication state with the given authentication scope in the cache.

Parameters
host:HttpHost

the authentication authority.

pathPrefix:String

the path prefix (the path component up to the last segment separator). Can be null.

authScheme:AuthScheme

the cacheable authentication state.

Annotations
@Override
removeback to summary
public void remove(final HttpHost host)

Implements org.apache.hc.client5.http.auth.AuthCache.remove.

Doc from org.apache.hc.client5.http.auth.AuthCache.remove.

Removes the authentication state with the given authentication scope from the cache if found.

Parameters
host:HttpHost

the authentication authority.

Annotations
@Override
removeback to summary
public void remove(final HttpHost host, final String pathPrefix)

Overrides default org.apache.hc.client5.http.auth.AuthCache.remove.

Doc from org.apache.hc.client5.http.auth.AuthCache.remove.

Removes the authentication state with the given authentication scope from the cache if found.

Parameters
host:HttpHost

the authentication authority.

pathPrefix:String

the path prefix (the path component up to the last segment separator). Can be null.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.apache.hc.client5.http.impl.auth back to summary

pack-priv Class BasicAuthCache.Key

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final String
pack-priv final String
pack-priv final int
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
Key(final String scheme, final String host, final int port, final String pathPrefix)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

hostback to summary
pack-priv final String host
pathPrefixback to summary
pack-priv final String pathPrefix
portback to summary
pack-priv final int port
schemeback to summary
pack-priv final String scheme

Constructor Detail

Keyback to summary
pack-priv Key(final String scheme, final String host, final int port, final String pathPrefix)

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override