SK.gnome.dwarf.http
Class RAMSessionManager

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.thread.ThreadServer
              extended bySK.gnome.dwarf.http.RAMSessionManager
All Implemented Interfaces:
SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service, SessionManager

public class RAMSessionManager
extends SK.gnome.dwarf.thread.ThreadServer
implements SessionManager

This class provides the memory-based session management.

It implements the SessionManager interface. The sessions are stored and maintained in the operational memory only. This class provides the automatic session expiration, too.


Field Summary
protected  boolean checkAddress
          Whether or not to check the client's IP address.
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadServer
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
RAMSessionManager(java.lang.String name)
          Creates a new SessionManager.
 
Method Summary
protected  boolean enableThread()
           
 Session getSession(Request request, java.lang.String id, boolean create)
          Returns the session for the given request.
 void init(SK.gnome.dwarf.Server parent)
           
protected  void loop()
          Checks for the session expiration.
 java.lang.String report()
          Returns the service report.
 void setCheckAddress(boolean enable)
          Enables or disables checking of the client's IP address.
 void shutdown()
          Shuts down the service.
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadServer
finish, run, setDaemon, start, stop
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Field Detail

checkAddress

protected boolean checkAddress
Whether or not to check the client's IP address.

If enabled the client's IP address will be compared to the address of the client, which initiated the session creation, each time a session is requested via the getSession method. This should prevent a possible session-stealing attacks.

Default value: true

See Also:
setCheckAddress(boolean)
Constructor Detail

RAMSessionManager

public RAMSessionManager(java.lang.String name)
Creates a new SessionManager.

Method Detail

setCheckAddress

public void setCheckAddress(boolean enable)
Enables or disables checking of the client's IP address.

Parameters:
enable - true to enable the address checking
See Also:
checkAddress

init

public void init(SK.gnome.dwarf.Server parent)
          throws SK.gnome.dwarf.ServiceException
Specified by:
init in interface SK.gnome.dwarf.Service
Throws:
SK.gnome.dwarf.ServiceException

shutdown

public void shutdown()
Shuts down the service.

It invalidates all sessions currently stored before returning from the method.

Specified by:
shutdown in interface SK.gnome.dwarf.Service

report

public java.lang.String report()
Returns the service report.

Returns a detailed information about sessions currently stored in the session manager.

Specified by:
report in interface SK.gnome.dwarf.Reportable

getSession

public Session getSession(Request request,
                          java.lang.String id,
                          boolean create)
Description copied from interface: SessionManager
Returns the session for the given request.

A new session should be created if no session exists with the given id if the create argument is true.

Specified by:
getSession in interface SessionManager
Parameters:
request - the request
id - the session id
create - whether to create a new session if no session with the given id exists
Returns:
the session or null if no session exists with the given id and the create argument is false

enableThread

protected boolean enableThread()

loop

protected void loop()
Checks for the session expiration.

It periodically checks for the expired sessions, invalidates them and removes from the session store.



Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.