Package org.conscrypt
Class AbstractSessionContext
- java.lang.Object
-
- org.conscrypt.AbstractSessionContext
-
- All Implemented Interfaces:
javax.net.ssl.SSLSessionContext
- Direct Known Subclasses:
ClientSessionContext,ServerSessionContext
abstract class AbstractSessionContext extends java.lang.Object implements javax.net.ssl.SSLSessionContextSupports SSL session caches.
-
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_SESSION_TIMEOUT_SECONDSMaximum lifetime of a session (in seconds) after which it's considered invalid and should not be used to for new connections.private intmaximumSizeprivate java.util.Map<ByteArray,NativeSslSession>sessions(package private) longsslCtxNativePointerprivate inttimeout
-
Constructor Summary
Constructors Constructor Description AbstractSessionContext(int maximumSize)Constructs a new session context.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) voidcacheSession(NativeSslSession session)Adds the given session to the cache.protected voidfinalize()java.util.Enumeration<byte[]>getIds()This method is provided for API-compatibility only, not intended for use.javax.net.ssl.SSLSessiongetSession(byte[] sessionId)This is provided for API-compatibility only, not intended for use.intgetSessionCacheSize()(package private) NativeSslSessiongetSessionFromCache(byte[] sessionId)Called for server sessions only.(package private) abstract NativeSslSessiongetSessionFromPersistentCache(byte[] sessionId)Called for server sessions only.intgetSessionTimeout()(package private) abstract voidonBeforeAddSession(NativeSslSession session)Called when the given session is about to be added.(package private) abstract voidonBeforeRemoveSession(NativeSslSession session)Called when a session is about to be removed.(package private) voidremoveSession(NativeSslSession session)Removes the given session from the cache.voidsetSessionCacheSize(int size)voidsetSessionTimeout(int seconds)private voidtrimToSize()Makes sure cache size is < maximumSize.
-
-
-
Field Detail
-
DEFAULT_SESSION_TIMEOUT_SECONDS
private static final int DEFAULT_SESSION_TIMEOUT_SECONDS
Maximum lifetime of a session (in seconds) after which it's considered invalid and should not be used to for new connections.- See Also:
- Constant Field Values
-
maximumSize
private volatile int maximumSize
-
timeout
private volatile int timeout
-
sslCtxNativePointer
final long sslCtxNativePointer
-
sessions
private final java.util.Map<ByteArray,NativeSslSession> sessions
-
-
Method Detail
-
getIds
public final java.util.Enumeration<byte[]> getIds()
This method is provided for API-compatibility only, not intended for use. No guarantees are made WRT performance.- Specified by:
getIdsin interfacejavax.net.ssl.SSLSessionContext
-
getSession
public final javax.net.ssl.SSLSession getSession(byte[] sessionId)
This is provided for API-compatibility only, not intended for use. No guarantees are made WRT performance or the validity of the returned session.- Specified by:
getSessionin interfacejavax.net.ssl.SSLSessionContext
-
getSessionCacheSize
public final int getSessionCacheSize()
- Specified by:
getSessionCacheSizein interfacejavax.net.ssl.SSLSessionContext
-
getSessionTimeout
public final int getSessionTimeout()
- Specified by:
getSessionTimeoutin interfacejavax.net.ssl.SSLSessionContext
-
setSessionTimeout
public final void setSessionTimeout(int seconds) throws java.lang.IllegalArgumentException- Specified by:
setSessionTimeoutin interfacejavax.net.ssl.SSLSessionContext- Throws:
java.lang.IllegalArgumentException
-
setSessionCacheSize
public final void setSessionCacheSize(int size) throws java.lang.IllegalArgumentException- Specified by:
setSessionCacheSizein interfacejavax.net.ssl.SSLSessionContext- Throws:
java.lang.IllegalArgumentException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
cacheSession
final void cacheSession(NativeSslSession session)
Adds the given session to the cache.
-
removeSession
final void removeSession(NativeSslSession session)
Removes the given session from the cache.
-
getSessionFromCache
final NativeSslSession getSessionFromCache(byte[] sessionId)
Called for server sessions only. Retrieves the session by its ID. Overridden byServerSessionContextto
-
onBeforeAddSession
abstract void onBeforeAddSession(NativeSslSession session)
Called 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.
-
onBeforeRemoveSession
abstract void onBeforeRemoveSession(NativeSslSession session)
Called 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.
-
getSessionFromPersistentCache
abstract NativeSslSession getSessionFromPersistentCache(byte[] sessionId)
Called for server sessions only. Retrieves the session by ID from the persistent cache.Visible for extension only, not intended to be called directly.
-
trimToSize
private void trimToSize()
Makes sure cache size is < maximumSize.
-
-