Package org.conscrypt

Class AbstractSessionContext

java.lang.Object
org.conscrypt.AbstractSessionContext
All Implemented Interfaces:
SSLSessionContext
Direct Known Subclasses:
ClientSessionContext, ServerSessionContext

abstract class AbstractSessionContext extends Object implements SSLSessionContext
Supports SSL session caches.
  • Field Details

    • 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:
    • maximumSize

      private volatile int maximumSize
    • timeout

      private volatile int timeout
    • sslCtxNativePointer

      final long sslCtxNativePointer
    • sessions

      private final Map<ByteArray,NativeSslSession> sessions
  • Constructor Details

    • AbstractSessionContext

      AbstractSessionContext(int maximumSize)
      Constructs a new session context.
      Parameters:
      maximumSize - of cache
  • Method Details

    • getIds

      public final 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 interface SSLSessionContext
    • getSession

      public final 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 interface SSLSessionContext
    • getSessionCacheSize

      public final int getSessionCacheSize()
      Specified by:
      getSessionCacheSize in interface SSLSessionContext
    • getSessionTimeout

      public final int getSessionTimeout()
      Specified by:
      getSessionTimeout in interface SSLSessionContext
    • setSessionTimeout

      public final void setSessionTimeout(int seconds) throws IllegalArgumentException
      Specified by:
      setSessionTimeout in interface SSLSessionContext
      Throws:
      IllegalArgumentException
    • setSessionCacheSize

      public final void setSessionCacheSize(int size) throws IllegalArgumentException
      Specified by:
      setSessionCacheSize in interface SSLSessionContext
      Throws:
      IllegalArgumentException
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      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 by ServerSessionContext to
    • onBeforeAddSession

      abstract void onBeforeAddSession(NativeSslSession session)
      Called when the given session is about to be added. Used by ClientSessionContext 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 by ClientSessionContext 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 invalid input: '<' maximumSize.