com.niggle.data
Class SessionImpl

java.lang.Object
  |
  +--com.niggle.data.DefaultRecord
        |
        +--com.niggle.data.SessionImpl
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, Record, java.io.Serializable, Session

public class SessionImpl
extends DefaultRecord
implements Session

An implementation of com.niggle.data.Session that leverages the functionality of the DefaultRecord implementation

Author:
Jonathan Revusky
See Also:
SimpleSessionManager, Serialized Form

Fields inherited from interface com.niggle.data.Record
INVALID_ID, STATUS_KEY, TYPE_KEY
 
Constructor Summary
SessionImpl()
           
 
Method Summary
 java.lang.String getUniqueKey()
          Get the unique key that identifies this session.
 java.lang.String getUsername()
           
 boolean isStale()
          Is this session stale (e.g.
 boolean isValidSession(java.lang.String username)
          Checks the validity of the session.
 
Methods inherited from class com.niggle.data.DefaultRecord
checkValidity, clearFields, equals, get, get, get, getCreationDate, getDisplayLocale, getLastModified, getMetadata, getMutableCopy, getPrimaryKey, getType, getVersion, isImmutable, postCheck, preCheck, readExternal, set, set, set, setMetadata, setPrimaryKey, setValuesFromTable, toString, touch, writeExternal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionImpl

public SessionImpl()
Method Detail

getUsername

public java.lang.String getUsername()

getUniqueKey

public java.lang.String getUniqueKey()
Description copied from interface: Session
Get the unique key that identifies this session. This should be difficult to guess, of course. Of course, just just how difficult might depend on your requirements. You would want something that is cryptographically random.
Specified by:
getUniqueKey in interface Session

isValidSession

public boolean isValidSession(java.lang.String username)
Checks the validity of the session. If the owner matches the session's owner, and expirationTime + lifeTime < currentTime, returns true; otherwise, returns false.
Specified by:
isValidSession in interface Session
Parameters:
owner - the supposed owner of the session.
Returns:
the validity of the session.

isStale

public boolean isStale()
Is this session stale (e.g. expired through inactivity or an explicit logout)
Overrides:
isStale in class DefaultRecord
Returns:
true if stale.