Package org.conscrypt
Class ClientSessionContext
- java.lang.Object
-
- org.conscrypt.AbstractSessionContext
-
- org.conscrypt.ClientSessionContext
-
- All Implemented Interfaces:
javax.net.ssl.SSLSessionContext
@Internal public final class ClientSessionContext extends AbstractSessionContext
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 Modifier and Type Class Description private static class
ClientSessionContext.HostAndPort
-
Field Summary
Fields Modifier and Type Field Description private SSLClientSessionCache
persistentCache
private java.util.Map<ClientSessionContext.HostAndPort,java.util.List<NativeSslSession>>
sessionsByHostAndPort
Sessions indexed by host and port.-
Fields inherited from class org.conscrypt.AbstractSessionContext
sslCtxNativePointer
-
-
Constructor Summary
Constructors Constructor Description ClientSessionContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) NativeSslSession
getCachedSession(java.lang.String hostName, int port, SSLParametersImpl sslParameters)
Gets the suitable session reference from the session cache container.private NativeSslSession
getSession(java.lang.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 Detail
-
sessionsByHostAndPort
private final java.util.Map<ClientSessionContext.HostAndPort,java.util.List<NativeSslSession>> 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
private SSLClientSessionCache persistentCache
-
-
Method Detail
-
setPersistentCache
public void setPersistentCache(SSLClientSessionCache persistentCache)
Applications should not use this method. Instead useConscrypt.setClientSessionCache(SSLContext, SSLClientSessionCache)
.
-
getCachedSession
NativeSslSession getCachedSession(java.lang.String hostName, int port, SSLParametersImpl sslParameters)
Gets the suitable session reference from the session cache container.
-
size
int size()
-
getSession
private NativeSslSession getSession(java.lang.String host, int port)
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
private void putSession(ClientSessionContext.HostAndPort key, NativeSslSession session)
-
removeSession
private void removeSession(ClientSessionContext.HostAndPort key, NativeSslSession session)
-
onBeforeAddSession
void onBeforeAddSession(NativeSslSession session)
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
void onBeforeRemoveSession(NativeSslSession session)
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
NativeSslSession getSessionFromPersistentCache(byte[] sessionId)
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
-
-