Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.net.ssl.provider
Class SessionContext  view SessionContext download SessionContext.java

java.lang.Object
  extended bygnu.javax.net.ssl.provider.SessionContext
All Implemented Interfaces:
javax.net.ssl.SSLSessionContext
Direct Known Subclasses:
JDBCSessionContext, XMLSessionContext

class SessionContext
extends java.lang.Object
implements javax.net.ssl.SSLSessionContext

A collection of SSL sessions. This implementation is a memory-only store; subclasses may implement persistent storage.


Field Summary
protected  int cacheSize
          The number of sessions to cache.
protected  java.util.HashMap sessions
          The map of Session.ID objects to Sessions.
protected  int timeout
          The session timeout, in seconds.
 
Constructor Summary
(package private) SessionContext()
           
 
Method Summary
(package private)  boolean addSession(Session.ID sessionId, Session session)
          Adds a session to this context.
(package private)  boolean containsSessionID(Session.ID sessionId)
          Returns whether or not a session with the given ID is cached by this context.
 java.util.Enumeration getIds()
          Returns an enumeration of all saved session IDs.
 javax.net.ssl.SSLSession getSession(byte[] sessionId)
          Gets the session specified by its ID, or null if there is no session, or if it has expired.
 int getSessionCacheSize()
          Returns the maximum number of sessions that may be cached by this session context.
 int getSessionTimeout()
          Returns the period of time (in seconds) that a session may be cached for before becoming invalid.
(package private)  void notifyAccess(Session session)
          Notifies this context of an access event on a session.
(package private)  boolean removeSession(Session.ID sessionId)
          Removes a session from this context.
 void setSessionCacheSize(int cacheSize)
          Sets the maximum number of sessions that may be cached by this session context.
 void setSessionTimeout(int timeout)
          Sets the period of time (in seconds) that a session may be cached for before becoming invalid.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessions

protected final java.util.HashMap sessions
The map of Session.ID objects to Sessions.


cacheSize

protected int cacheSize
The number of sessions to cache.


timeout

protected int timeout
The session timeout, in seconds.

Constructor Detail

SessionContext

SessionContext()
Method Detail

getIds

public java.util.Enumeration getIds()
Description copied from interface: javax.net.ssl.SSLSessionContext
Returns an enumeration of all saved session IDs. Every element in the returned enumeration is a byte array.

Specified by:
getIds in interface javax.net.ssl.SSLSessionContext

getSession

public javax.net.ssl.SSLSession getSession(byte[] sessionId)
Description copied from interface: javax.net.ssl.SSLSessionContext
Gets the session specified by its ID, or null if there is no session, or if it has expired.

Specified by:
getSession in interface javax.net.ssl.SSLSessionContext

getSessionCacheSize

public int getSessionCacheSize()
Description copied from interface: javax.net.ssl.SSLSessionContext
Returns the maximum number of sessions that may be cached by this session context.

Specified by:
getSessionCacheSize in interface javax.net.ssl.SSLSessionContext

setSessionCacheSize

public void setSessionCacheSize(int cacheSize)
Description copied from interface: javax.net.ssl.SSLSessionContext
Sets the maximum number of sessions that may be cached by this session context. A cache size of 0 means no limit.

Specified by:
setSessionCacheSize in interface javax.net.ssl.SSLSessionContext

getSessionTimeout

public int getSessionTimeout()
Description copied from interface: javax.net.ssl.SSLSessionContext
Returns the period of time (in seconds) that a session may be cached for before becoming invalid.

Specified by:
getSessionTimeout in interface javax.net.ssl.SSLSessionContext

setSessionTimeout

public void setSessionTimeout(int timeout)
Description copied from interface: javax.net.ssl.SSLSessionContext
Sets the period of time (in seconds) that a session may be cached for before becoming invalid. A timeout of 0 means that sessions never expire.

Specified by:
setSessionTimeout in interface javax.net.ssl.SSLSessionContext

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


addSession

boolean addSession(Session.ID sessionId,
                   Session session)
Adds a session to this context. This method:
  1. Will do nothing if the cache already contains the given ID.
  2. Will do nothing if the cache limit has been reached (and is not zero).
  3. Will remove any invalid sessions in the cache before trying to insert the new one.
  4. Will remove any expired sessions before trying to insert the new one.


containsSessionID

boolean containsSessionID(Session.ID sessionId)
Returns whether or not a session with the given ID is cached by this context.


removeSession

boolean removeSession(Session.ID sessionId)
Removes a session from this context.


notifyAccess

void notifyAccess(Session session)
Notifies this context of an access event on a session.