org.opensubsystems.core.www
Class WebSessionUtils

java.lang.Object
  extended by org.opensubsystems.core.www.WebSessionUtils

public final class WebSessionUtils
extends java.lang.Object

Collection of useful methods to work with sessions objects.

Version:
$Id: WebSessionUtils.java,v 1.4 2007/01/07 06:14:09 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
static java.lang.String HTTP_SESSION_TRACKER
          Object which tracks when the session is invalidated by the web container.
static java.lang.String INTERNAL_SESSIONID_SESSION_PARAM
          Name of the attribute in the session containing the internal session id.
static java.lang.String LOGGEDIN_USERID_SESSION_PARAM
          Identification of logged in user.
 
Method Summary
static java.security.Principal getLoggedInUserInfo(javax.servlet.http.HttpSession hsSession)
          If the user has logged in, this method will return information about who is logged in.
static java.lang.String getSessionId(javax.servlet.http.HttpSession hsSession)
          Get identifier of current user session.
static boolean isLoggedIn(javax.servlet.http.HttpSession hsSession)
          If the user has logged in, this method will return true.
static void resetSessionAndUserInfo(javax.servlet.http.HttpSession hsSession)
          Reset identifier of current user session and user information.
static void setSessionAndUserInfo(javax.servlet.http.HttpSession hsSession, java.lang.String sessionId, java.security.Principal credentials)
          Set identifier of current user session and user information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_SESSIONID_SESSION_PARAM

public static final java.lang.String INTERNAL_SESSIONID_SESSION_PARAM
Name of the attribute in the session containing the internal session id. If it exists, then user is logged in.

See Also:
Constant Field Values

LOGGEDIN_USERID_SESSION_PARAM

public static final java.lang.String LOGGEDIN_USERID_SESSION_PARAM
Identification of logged in user.

See Also:
Constant Field Values

HTTP_SESSION_TRACKER

public static final java.lang.String HTTP_SESSION_TRACKER
Object which tracks when the session is invalidated by the web container.

See Also:
Constant Field Values
Method Detail

isLoggedIn

public static boolean isLoggedIn(javax.servlet.http.HttpSession hsSession)
If the user has logged in, this method will return true.

Parameters:
hsSession - - HTTP session object, can be null
Returns:
boolean

getLoggedInUserInfo

public static java.security.Principal getLoggedInUserInfo(javax.servlet.http.HttpSession hsSession)
If the user has logged in, this method will return information about who is logged in.

Parameters:
hsSession - - HTTP session object, can be null
Returns:
Object - identication of user who is logged in or null if nobody is logged in

getSessionId

public static java.lang.String getSessionId(javax.servlet.http.HttpSession hsSession)
Get identifier of current user session.

Parameters:
hsSession - - current HTTP session user is using
Returns:
String - user session identifier or null if no user is logged in

setSessionAndUserInfo

public static void setSessionAndUserInfo(javax.servlet.http.HttpSession hsSession,
                                         java.lang.String sessionId,
                                         java.security.Principal credentials)
Set identifier of current user session and user information

Parameters:
hsSession - - current HTTP session user is using
sessionId - - user session identifier
credentials - - credentials for user

resetSessionAndUserInfo

public static void resetSessionAndUserInfo(javax.servlet.http.HttpSession hsSession)
Reset identifier of current user session and user information. If the user is still logged in, this will expire his server session.

Parameters:
hsSession - - current HTTP session user is using


Copyright © 2003 - 2006 OpenSubsystems s.r.o.