Package org.conscrypt
Class ClientSessionContext
java.lang.Object
org.conscrypt.AbstractSessionContext
org.conscrypt.ClientSessionContext
- All Implemented Interfaces:
SSLSessionContext
Caches client sessions. Indexes by host and port. Users are typically
looking to reuse any session for a given host and port.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SSLClientSessionCache
private final Map
<ClientSessionContext.HostAndPort, List<NativeSslSession>> Sessions indexed by host and port.Fields inherited from class org.conscrypt.AbstractSessionContext
sslCtxNativePointer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) NativeSslSession
getCachedSession
(String hostName, int port, SSLParametersImpl sslParameters) Gets the suitable session reference from the session cache container.private NativeSslSession
getSession
(String host, int port) Finds a cached session for the given host name and port.(package private) NativeSslSession
getSessionFromPersistentCache
(byte[] sessionId) Called for server sessions only.(package private) void
onBeforeAddSession
(NativeSslSession session) Called when the given session is about to be added.(package private) void
onBeforeRemoveSession
(NativeSslSession session) Called when a session is about to be removed.private void
putSession
(ClientSessionContext.HostAndPort key, NativeSslSession session) private void
removeSession
(ClientSessionContext.HostAndPort key, NativeSslSession session) void
setPersistentCache
(SSLClientSessionCache persistentCache) Applications should not use this method.(package private) int
size()
Methods inherited from class org.conscrypt.AbstractSessionContext
cacheSession, finalize, getIds, getSession, getSessionCacheSize, getSessionFromCache, getSessionTimeout, removeSession, setSessionCacheSize, setSessionTimeout
-
Field Details
-
sessionsByHostAndPort
Sessions indexed by host and port. Protect from concurrent access by holding a lock on sessionsByHostAndPort. Invariant: Each list includes either exactly one multi-use session or one or more single-use sessions. The types of sessions are never mixed, and adding a session of one kind will remove all sessions of the other kind. -
persistentCache
-
-
Constructor Details
-
ClientSessionContext
ClientSessionContext()
-
-
Method Details
-
setPersistentCache
Applications should not use this method. Instead useConscrypt.setClientSessionCache(SSLContext, SSLClientSessionCache)
. -
getCachedSession
Gets the suitable session reference from the session cache container. -
size
int size() -
getSession
Finds a cached session for the given host name and port.- Parameters:
host
- of serverport
- of server- Returns:
- cached session or null if none found
-
putSession
-
removeSession
-
onBeforeAddSession
Description copied from class:AbstractSessionContext
Called when the given session is about to be added. Used byClientSessionContext
to update its host-and-port based cache.Visible for extension only, not intended to be called directly.
- Specified by:
onBeforeAddSession
in classAbstractSessionContext
-
onBeforeRemoveSession
Description copied from class:AbstractSessionContext
Called when a session is about to be removed. Used byClientSessionContext
to update its host-and-port based cache.Visible for extension only, not intended to be called directly.
- Specified by:
onBeforeRemoveSession
in classAbstractSessionContext
-
getSessionFromPersistentCache
Description copied from class:AbstractSessionContext
Called for server sessions only. Retrieves the session by ID from the persistent cache.Visible for extension only, not intended to be called directly.
- Specified by:
getSessionFromPersistentCache
in classAbstractSessionContext
-