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 classClientSessionContext.HostAndPort
-
Field Summary
Fields Modifier and Type Field Description private SSLClientSessionCachepersistentCacheprivate java.util.Map<ClientSessionContext.HostAndPort,java.util.List<NativeSslSession>>sessionsByHostAndPortSessions 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) NativeSslSessiongetCachedSession(java.lang.String hostName, int port, SSLParametersImpl sslParameters)Gets the suitable session reference from the session cache container.private NativeSslSessiongetSession(java.lang.String host, int port)Finds a cached session for the given host name and port.(package private) NativeSslSessiongetSessionFromPersistentCache(byte[] sessionId)Called for server sessions only.(package private) voidonBeforeAddSession(NativeSslSession session)Called when the given session is about to be added.(package private) voidonBeforeRemoveSession(NativeSslSession session)Called when a session is about to be removed.private voidputSession(ClientSessionContext.HostAndPort key, NativeSslSession session)private voidremoveSession(ClientSessionContext.HostAndPort key, NativeSslSession session)voidsetPersistentCache(SSLClientSessionCache persistentCache)Applications should not use this method.(package private) intsize()-
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:AbstractSessionContextCalled when the given session is about to be added. Used byClientSessionContextto update its host-and-port based cache.Visible for extension only, not intended to be called directly.
- Specified by:
onBeforeAddSessionin classAbstractSessionContext
-
onBeforeRemoveSession
void onBeforeRemoveSession(NativeSslSession session)
Description copied from class:AbstractSessionContextCalled when a session is about to be removed. Used byClientSessionContextto update its host-and-port based cache.Visible for extension only, not intended to be called directly.
- Specified by:
onBeforeRemoveSessionin classAbstractSessionContext
-
getSessionFromPersistentCache
NativeSslSession getSessionFromPersistentCache(byte[] sessionId)
Description copied from class:AbstractSessionContextCalled 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:
getSessionFromPersistentCachein classAbstractSessionContext
-
-