pt.digitalis.dif.controller.objects
Class DIFSession

java.lang.Object
  extended by pt.digitalis.dif.controller.objects.DIFSession
All Implemented Interfaces:
IDIFSession, IPrivateDIFSession

public class DIFSession
extends Object
implements IPrivateDIFSession

Base implementation of a DIF Session. Should be extended by each specific channel session. (i.e. DIFSessionHTTPImpl)

Author:
Rodrigo Gonçalves rgoncalves@digitalis.pt, Pedro Viegas pviegas@digitalis.pt
Created on:
Nov 29, 2007

Field Summary
static String REMOTE_AUTHENTICATION_PROVIDER_LOGIN
          The session key indicating that authentication was performed by a remote provider
static String REMOTE_AUTHENTICATION_PROVIDER_LOGOUT
          The session key indicating that authentication was performed by a remote provider
 
Constructor Summary
DIFSession(String sessionID)
          Default constructor.
DIFSession(String sessionID, DIFUserInSession user)
          One-argument constructor that receives an user.
 
Method Summary
 void addAttribute(String key, Object value)
          Stores a new attribute in the session.
 boolean containsAttribute(String key)
          Stores a new attribute in the session.
 void forceKeepAlive()
          Touches the session so it remains active.
 Object getAttribute(String key)
          Retrieves a given attributes by id.
 Map<String,Object> getAttributes()
          Retrieves all session attributes.
 long getFirstAccessTime()
          Inspector for the 'firstAccessTime' property.
 String getLanguage()
           
 long getLastAccessTime()
          Inspector for the 'lastAccessTime' property.
 INavigationHistory getNavigationHistory()
          Provides the current session navigation history objet
 String getSessionID()
           
 long getSessionTimeOut()
          Inspector for the session time-out value.
 DIFUserInSession getUser()
          Gets the user in session.
 boolean hasExpiredAfterTimeOut()
          The criteria for a timed out session is that the last access time plus the session time out must be higher than the current time.
 boolean hasTimedOut()
          The criteria for a timed out session is that the last access time plus the session time out must be higher than the current time.
 boolean isLogged()
          Checks if the session has a logged user
 boolean isMarkedForRemoval()
           
 void keepAlive()
          Sets the 'lastAccesTime' property to "now".
 void setAttributes(Map<String,Object> attributes)
          Sets all session attributes.
 void setLanguage(String language)
           
 void setLastAccessTime(long lastAccessTime)
          Modifier for the 'lastAccessTime' property.
 void setMarkedForRemoval(Boolean markedForRemoval)
          Marks the session to be removed
 void setSessionTimeOut(long sessionTimeOut)
          Sets the session time-out value.
 void setUser(DIFUserInSession user)
          Sets the user in session.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REMOTE_AUTHENTICATION_PROVIDER_LOGIN

public static final String REMOTE_AUTHENTICATION_PROVIDER_LOGIN
The session key indicating that authentication was performed by a remote provider

See Also:
Constant Field Values

REMOTE_AUTHENTICATION_PROVIDER_LOGOUT

public static final String REMOTE_AUTHENTICATION_PROVIDER_LOGOUT
The session key indicating that authentication was performed by a remote provider

See Also:
Constant Field Values
Constructor Detail

DIFSession

public DIFSession(String sessionID)
Default constructor. Sets the first access time.

Parameters:
sessionID - the session unique identifier

DIFSession

public DIFSession(String sessionID,
                  DIFUserInSession user)
One-argument constructor that receives an user.

Parameters:
sessionID - the session unique identifier
user - a DIF user
Method Detail

addAttribute

public void addAttribute(String key,
                         Object value)
Description copied from interface: IDIFSession
Stores a new attribute in the session.

Specified by:
addAttribute in interface IDIFSession
Parameters:
key - the key of the attribute
value - the value of the new attribute
See Also:
IDIFSession.addAttribute(java.lang.String, java.lang.Object)

containsAttribute

public boolean containsAttribute(String key)
Description copied from interface: IDIFSession
Stores a new attribute in the session.

Specified by:
containsAttribute in interface IDIFSession
Parameters:
key - the key of the attribute
Returns:
T if the attribute for the given key exists
See Also:
IDIFSession.containsAttribute(java.lang.String)

forceKeepAlive

public void forceKeepAlive()
Description copied from interface: IPrivateDIFSession
Touches the session so it remains active.

Specified by:
forceKeepAlive in interface IPrivateDIFSession
See Also:
IPrivateDIFSession.forceKeepAlive()

getAttribute

public Object getAttribute(String key)
Description copied from interface: IDIFSession
Retrieves a given attributes by id.

Specified by:
getAttribute in interface IDIFSession
Parameters:
key - the key of the attribute
Returns:
the attribute value
See Also:
IDIFSession.getAttribute(java.lang.String)

getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: IDIFSession
Retrieves all session attributes.

Specified by:
getAttributes in interface IDIFSession
Returns:
the session attributes Map
See Also:
IDIFSession.getAttributes()

getFirstAccessTime

public long getFirstAccessTime()
Inspector for the 'firstAccessTime' property.

Returns:
the 'firstAccessTime' value

getLanguage

public String getLanguage()
Specified by:
getLanguage in interface IDIFSession
Returns:
the language
See Also:
IDIFSession.getLanguage()

getLastAccessTime

public long getLastAccessTime()
Inspector for the 'lastAccessTime' property.

Returns:
the 'lastAccessTime' value

getNavigationHistory

public INavigationHistory getNavigationHistory()
Description copied from interface: IDIFSession
Provides the current session navigation history objet

Specified by:
getNavigationHistory in interface IDIFSession
Returns:
the navigation history object in session
See Also:
IDIFSession.getNavigationHistory()

getSessionID

public String getSessionID()
Specified by:
getSessionID in interface IDIFSession
Returns:
the sessionID
See Also:
IDIFSession.getSessionID()

getSessionTimeOut

public long getSessionTimeOut()
Description copied from interface: IDIFSession
Inspector for the session time-out value.

Specified by:
getSessionTimeOut in interface IDIFSession
Returns:
the session time-out value
See Also:
IDIFSession.getSessionTimeOut()

getUser

public DIFUserInSession getUser()
Description copied from interface: IDIFSession
Gets the user in session.

Specified by:
getUser in interface IDIFSession
Returns:
the user in session
See Also:
IDIFSession.getUser()

hasExpiredAfterTimeOut

public boolean hasExpiredAfterTimeOut()
Description copied from interface: IPrivateDIFSession
The criteria for a timed out session is that the last access time plus the session time out must be higher than the current time.

Specified by:
hasExpiredAfterTimeOut in interface IPrivateDIFSession
Returns:
T time after the session has timed out that the cleanup Collection will consider before purging the session (ms).
See Also:
IPrivateDIFSession.hasExpiredAfterTimeOut()

hasTimedOut

public boolean hasTimedOut()
The criteria for a timed out session is that the last access time plus the session time out must be higher than the current time.

Specified by:
hasTimedOut in interface IDIFSession
Returns:
T if session has timed out, F otherwise
See Also:
IDIFSession.hasTimedOut()

isLogged

public boolean isLogged()
Description copied from interface: IDIFSession
Checks if the session has a logged user

Specified by:
isLogged in interface IDIFSession
Returns:
T if if is logged
See Also:
IDIFSession.isLogged()

isMarkedForRemoval

public boolean isMarkedForRemoval()
Specified by:
isMarkedForRemoval in interface IDIFSession
Returns:
T if the session has been marked for removal
See Also:
IDIFSession.isMarkedForRemoval()

keepAlive

public void keepAlive()
Sets the 'lastAccesTime' property to "now".

Specified by:
keepAlive in interface IPrivateDIFSession
See Also:
IPrivateDIFSession.keepAlive()

setAttributes

public void setAttributes(Map<String,Object> attributes)
Description copied from interface: IDIFSession
Sets all session attributes.

Specified by:
setAttributes in interface IDIFSession
Parameters:
attributes - the session attributes to set
See Also:
IDIFSession.setAttributes(Map)

setLanguage

public void setLanguage(String language)
Specified by:
setLanguage in interface IDIFSession
Parameters:
language - the language to set
See Also:
IDIFSession.setLanguage(java.lang.String)

setLastAccessTime

public void setLastAccessTime(long lastAccessTime)
Modifier for the 'lastAccessTime' property.

Parameters:
lastAccessTime - the 'lastAccessTime' new value to set

setMarkedForRemoval

public void setMarkedForRemoval(Boolean markedForRemoval)
Description copied from interface: IPrivateDIFSession
Marks the session to be removed

Specified by:
setMarkedForRemoval in interface IPrivateDIFSession
Parameters:
markedForRemoval -

setSessionTimeOut

public void setSessionTimeOut(long sessionTimeOut)
Description copied from interface: IDIFSession
Sets the session time-out value.

Specified by:
setSessionTimeOut in interface IDIFSession
Parameters:
sessionTimeOut - the session time out new value to set
See Also:
IDIFSession.setSessionTimeOut(long)

setUser

public void setUser(DIFUserInSession user)
Description copied from interface: IDIFSession
Sets the user in session.

Specified by:
setUser in interface IDIFSession
Parameters:
user - the user to set
See Also:
IDIFSession.setUser(pt.digitalis.dif.controller.objects.DIFUserInSession)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.