Package org.conscrypt

Class 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 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
    • Constructor Detail

      • AbstractSessionContext

        AbstractSessionContext​(int maximumSize)
        Constructs a new session context.
        Parameters:
        maximumSize - of cache
    • 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 interface javax.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 interface javax.net.ssl.SSLSessionContext
      • getSessionCacheSize

        public final int getSessionCacheSize()
        Specified by:
        getSessionCacheSize in interface javax.net.ssl.SSLSessionContext
      • getSessionTimeout

        public final int getSessionTimeout()
        Specified by:
        getSessionTimeout in interface javax.net.ssl.SSLSessionContext
      • setSessionTimeout

        public final void setSessionTimeout​(int seconds)
                                     throws java.lang.IllegalArgumentException
        Specified by:
        setSessionTimeout in interface javax.net.ssl.SSLSessionContext
        Throws:
        java.lang.IllegalArgumentException
      • setSessionCacheSize

        public final void setSessionCacheSize​(int size)
                                       throws java.lang.IllegalArgumentException
        Specified by:
        setSessionCacheSize in interface javax.net.ssl.SSLSessionContext
        Throws:
        java.lang.IllegalArgumentException
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.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 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 < maximumSize.