Top Description Fields Constructors Methods
org.conscrypt

pack-priv abstract Class AbstractSessionContext

extends Object
implements SSLSessionContext
Class Inheritance
All Implemented Interfaces
javax.net.ssl.SSLSessionContext
Known Direct Subclasses
org.conscrypt.ClientSessionContext, org.conscrypt.ServerSessionContext
Imports
java.util.Arrays, .Enumeration, .Iterator, .LinkedHashMap, .Map, .NoSuchElementException, javax.net.ssl.SSLSession, .SSLSessionContext

Supports SSL session caches.

Field Summary

Modifier and TypeField and Description
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.

private volatile int
private final Map<ByteArray, NativeSslSession>
pack-priv final long
private volatile int

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractSessionContext(int
of cache
maximumSize
)

Constructs a new session context.

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
cacheSession(NativeSslSession session)

Adds the given session to the cache.

protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public final Enumeration<byte[]>
getIds()

Implements javax.net.ssl.SSLSessionContext.getIds.

This method is provided for API-compatibility only, not intended for use.
public final SSLSession
getSession(byte[]
the Session identifier
sessionId
)

Implements javax.net.ssl.SSLSessionContext.getSession.

This is provided for API-compatibility only, not intended for use.
public final int
getSessionCacheSize()

Implements javax.net.ssl.SSLSessionContext.getSessionCacheSize.

Returns the size of the cache used for storing SSLSession objects grouped under this SSLSessionContext.
pack-priv final NativeSslSession
getSessionFromCache(byte[] sessionId)

Called for server sessions only.

pack-priv abstract NativeSslSession
getSessionFromPersistentCache(byte[] sessionId)

Called for server sessions only.

public final int
getSessionTimeout()

Implements javax.net.ssl.SSLSessionContext.getSessionTimeout.

Returns the timeout limit of SSLSession objects grouped under this SSLSessionContext.
pack-priv abstract void
onBeforeAddSession(NativeSslSession session)

Called when the given session is about to be added.

pack-priv abstract void
onBeforeRemoveSession(NativeSslSession session)

Called when a session is about to be removed.

pack-priv final void
removeSession(NativeSslSession session)

Removes the given session from the cache.

public final void
setSessionCacheSize(int
the new session cache size limit; zero means there is no limit.
size
)

Implements javax.net.ssl.SSLSessionContext.setSessionCacheSize.

Sets the size of the cache used for storing SSLSession objects grouped under this SSLSessionContext.
public final void
setSessionTimeout(int
the new session timeout limit in seconds; zero means there is no limit.
seconds
)

Implements javax.net.ssl.SSLSessionContext.setSessionTimeout.

Sets the timeout limit for SSLSession objects grouped under this SSLSessionContext.
private void
trimToSize()

Makes sure cache size is < maximumSize.

Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_SESSION_TIMEOUT_SECONDSback to summary
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.

maximumSizeback to summary
private volatile int maximumSize
sessionsback to summary
private final Map<ByteArray, NativeSslSession> sessions
Annotations
@SuppressWarnings:serial
sslCtxNativePointerback to summary
pack-priv final long sslCtxNativePointer
timeoutback to summary
private volatile int timeout

Constructor Detail

AbstractSessionContextback to summary
pack-priv AbstractSessionContext(int maximumSize)

Constructs a new session context.

Parameters
maximumSize:int

of cache

Method Detail

cacheSessionback to summary
pack-priv final void cacheSession(NativeSslSession session)

Adds the given session to the cache.

finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
getIdsback to summary
public final Enumeration<byte[]> getIds()

Implements javax.net.ssl.SSLSessionContext.getIds.

This method is provided for API-compatibility only, not intended for use. No guarantees are made WRT performance.

Returns:Enumeration<byte[]>

Doc from javax.net.ssl.SSLSessionContext.getIds.

an enumeration of all the Session id's

Annotations
@Override
getSessionback to summary
public final SSLSession getSession(byte[] sessionId)

Implements javax.net.ssl.SSLSessionContext.getSession.

This is provided for API-compatibility only, not intended for use. No guarantees are made WRT performance or the validity of the returned session.

Parameters
sessionId:byte[]

Doc from javax.net.ssl.SSLSessionContext.getSession.

the Session identifier

Returns:SSLSession

Doc from javax.net.ssl.SSLSessionContext.getSession.

the SSLSession or null if the specified session id does not refer to a valid SSLSession.

Annotations
@Override
getSessionCacheSizeback to summary
public final int getSessionCacheSize()

Implements javax.net.ssl.SSLSessionContext.getSessionCacheSize.

Doc from javax.net.ssl.SSLSessionContext.getSessionCacheSize.

Returns the size of the cache used for storing SSLSession objects grouped under this SSLSessionContext.

Returns:int

size of the session cache; zero means there is no size limit.

Annotations
@Override
getSessionFromCacheback to summary
pack-priv final NativeSslSession getSessionFromCache(byte[] sessionId)

Called for server sessions only. Retrieves the session by its ID. Overridden by ServerSessionContext to

getSessionFromPersistentCacheback to summary
pack-priv 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.

getSessionTimeoutback to summary
public final int getSessionTimeout()

Implements javax.net.ssl.SSLSessionContext.getSessionTimeout.

Doc from javax.net.ssl.SSLSessionContext.getSessionTimeout.

Returns the timeout limit of SSLSession objects grouped under this SSLSessionContext.

If the timeout limit is set to 't' seconds, a session exceeds the timeout limit 't' seconds after its creation time. When the timeout limit is exceeded for a session, the SSLSession object is invalidated and future connections cannot resume or rejoin the session. A check for sessions exceeding the timeout limit is made immediately whenever the timeout limit is changed for this SSLSessionContext.

Returns:int

the session timeout limit in seconds; zero means there is no limit.

Annotations
@Override
onBeforeAddSessionback to summary
pack-priv 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.

onBeforeRemoveSessionback to summary
pack-priv 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.

removeSessionback to summary
pack-priv final void removeSession(NativeSslSession session)

Removes the given session from the cache.

setSessionCacheSizeback to summary
public final void setSessionCacheSize(int size) throws IllegalArgumentException

Implements javax.net.ssl.SSLSessionContext.setSessionCacheSize.

Doc from javax.net.ssl.SSLSessionContext.setSessionCacheSize.

Sets the size of the cache used for storing SSLSession objects grouped under this SSLSessionContext.

Parameters
size:int

the new session cache size limit; zero means there is no limit.

Annotations
@Override
Exceptions
IllegalArgumentException:
if the specified size is < 0.
setSessionTimeoutback to summary
public final void setSessionTimeout(int seconds) throws IllegalArgumentException

Implements javax.net.ssl.SSLSessionContext.setSessionTimeout.

Doc from javax.net.ssl.SSLSessionContext.setSessionTimeout.

Sets the timeout limit for SSLSession objects grouped under this SSLSessionContext.

If the timeout limit is set to 't' seconds, a session exceeds the timeout limit 't' seconds after its creation time. When the timeout limit is exceeded for a session, the SSLSession object is invalidated and future connections cannot resume or rejoin the session. A check for sessions exceeding the timeout is made immediately whenever the timeout limit is changed for this SSLSessionContext.

Parameters
seconds:int

the new session timeout limit in seconds; zero means there is no limit.

Annotations
@Override
Exceptions
IllegalArgumentException:
if the timeout specified is < 0.
trimToSizeback to summary
private void trimToSize()

Makes sure cache size is < maximumSize.