public abstract class AbstractSessionTracker extends Object implements SessionTracker
| Modifier and Type | Field and Description |
|---|---|
protected HashMap<String,Session> |
activeSessions |
protected long |
sessionTimeOut |
protected List<Session> |
timedOutSessions |
protected int |
type |
| Constructor and Description |
|---|
AbstractSessionTracker()
This creates a new instance of this class which is based on the default
timeout of 2 hours ( = 7200000 ms ).
|
AbstractSessionTracker(long timeout)
This initializes the tracker with the given session-timeout.
|
| Modifier and Type | Method and Description |
|---|---|
void |
eventArrived(AuditEvent event)
This method tracks an AuditEvent object and creates a session if none
existed yet.
|
void |
eventsArrived(Collection<AuditEvent> events)
This method is called for notifying the listener of arrival of
several events in a block.
|
protected void |
expireSession(Session s)
Remove the session from the hash of active sessions and store it in the
list of timed-out sessions.
|
abstract String |
extractKey(AuditEvent evt)
This method extracts the key-feature from an event which is used to
identify the session that this event is related to.
|
Session |
getSession(String sessionId)
This method returns the session with the given session-id.
|
Collection<Session> |
getSessions()
This method returns all the sessions (active and timed-out) that have
been created by the session-tracker.
|
long |
getSessionTimeOut()
Returns the session-timeout that is used by this tracker.
|
boolean |
isExpired(Session s,
AuditEvent event)
This method is used to check a session for expiration according to the
date of the given audit-event.
|
void |
reset()
This method simply resets the session-tracker to the initial state which
holds no sessions.
|
void |
setSessionTimeOut(long s)
This method is used to set the session-timeout.
|
void |
setStrictSessions(boolean b)
In a strict session the session-id is presumed to be created by the
server-side application.
|
String |
toString()
This method returns a string of all events grouped by their session-id.
|
boolean |
usesStrictSessions()
Returns
true, if the tracker only produces strict sessions. |
public AbstractSessionTracker()
public AbstractSessionTracker(long timeout)
timeout - The session-timeout in seconds.public void eventArrived(AuditEvent event)
eventArrived in interface EventListener<AuditEvent>eventArrived in interface AuditEventListenereventArrived in interface SessionTrackerevent - The AuditEvent instance that is to be associated with a
session.public void eventsArrived(Collection<AuditEvent> events)
AuditEventListenerAuditEventListener.eventArrived(AuditEvent) for each of the given
events, but may be handled in a more efficient way by implementations
capable of processing blocks of events.eventsArrived in interface AuditEventListenerevents - The block of events arrived.protected void expireSession(Session s)
s - The session to expire.public Session getSession(String sessionId)
getSession in interface SessionTrackersessionId - The id of the session that is to be retrieved.null
if the session is inactive or does not exist at all.public Collection<Session> getSessions()
getSessions in interface SessionTrackerpublic void reset()
reset in interface SessionTrackerpublic boolean isExpired(Session s, AuditEvent event)
s - The session that is to be checked.event - The event which defines the current date.true if the sessions' last access-time is no longer
that a period of X seconds away from the events date. Here X is
the session-timeout defined for this session-tracker.public void setSessionTimeOut(long s)
setSessionTimeOut in interface SessionTrackers - The number of seconds after which a session is to be timed
out.public long getSessionTimeOut()
getSessionTimeOut in interface SessionTrackerpublic void setStrictSessions(boolean b)
setStrictSessions in interface SessionTrackerb - Wether this tracker should only track strict sessions.public boolean usesStrictSessions()
SessionTrackertrue, if the tracker only produces strict sessions.usesStrictSessions in interface SessionTrackerpublic abstract String extractKey(AuditEvent evt)
evt - The event from which to extract the session-id.Copyright © 2015 jwall.org. All Rights Reserved.