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.SSLSessionContext
Supports SSL session caches.
-
-
Field Summary
Fields Modifier and Type Field Description private static 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.private int
maximumSize
private java.util.Map<ByteArray,NativeSslSession>
sessions
(package private) long
sslCtxNativePointer
private int
timeout
-
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) void
cacheSession(NativeSslSession session)
Adds the given session to the cache.protected void
finalize()
java.util.Enumeration<byte[]>
getIds()
This method is provided for API-compatibility only, not intended for use.javax.net.ssl.SSLSession
getSession(byte[] sessionId)
This is provided for API-compatibility only, not intended for use.int
getSessionCacheSize()
(package private) NativeSslSession
getSessionFromCache(byte[] sessionId)
Called for server sessions only.(package private) abstract NativeSslSession
getSessionFromPersistentCache(byte[] sessionId)
Called for server sessions only.int
getSessionTimeout()
(package private) abstract void
onBeforeAddSession(NativeSslSession session)
Called when the given session is about to be added.(package private) abstract void
onBeforeRemoveSession(NativeSslSession session)
Called when a session is about to be removed.(package private) void
removeSession(NativeSslSession session)
Removes the given session from the cache.void
setSessionCacheSize(int size)
void
setSessionTimeout(int seconds)
private void
trimToSize()
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:
getIds
in 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:
getSession
in interfacejavax.net.ssl.SSLSessionContext
-
getSessionCacheSize
public final int getSessionCacheSize()
- Specified by:
getSessionCacheSize
in interfacejavax.net.ssl.SSLSessionContext
-
getSessionTimeout
public final int getSessionTimeout()
- Specified by:
getSessionTimeout
in interfacejavax.net.ssl.SSLSessionContext
-
setSessionTimeout
public final void setSessionTimeout(int seconds) throws java.lang.IllegalArgumentException
- Specified by:
setSessionTimeout
in interfacejavax.net.ssl.SSLSessionContext
- Throws:
java.lang.IllegalArgumentException
-
setSessionCacheSize
public final void setSessionCacheSize(int size) throws java.lang.IllegalArgumentException
- Specified by:
setSessionCacheSize
in interfacejavax.net.ssl.SSLSessionContext
- Throws:
java.lang.IllegalArgumentException
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in 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 byServerSessionContext
to
-
onBeforeAddSession
abstract void onBeforeAddSession(NativeSslSession session)
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.
-
onBeforeRemoveSession
abstract void onBeforeRemoveSession(NativeSslSession session)
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.
-
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.
-
-