|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.opensubsystems.core.www.WebSessionServlet
public class WebSessionServlet
Base class for all servlets developed as part of this project. It's main responsibility is to provide session information if required therefore making sure that nobody who is not logged in (or otherwise authenticated) can proceed. This servlet intercepts all requests, makes sure that valid HTTP session is established and after credentials are verified, let the request proceed. Developers are adviced to derive all servlets from this servlet since this helps us to establish effective security policy at a single place.
| Field Summary | |
|---|---|
static java.lang.String |
APPLICATION_SECURE
Configuration setting specifying if all pages of the application should be displayed in a secure mode using SSL protocol. |
static java.lang.String |
ATTACH_INTERNAL_SESSION_ID_URL_PARAM
Parameter which must be specified in URL if the user should be attached to this server after it was logged in at some other server. |
static boolean |
DEFAULT_APPLICATION_SECURE
Default value for APPLICATION_SECURE. |
static boolean |
DEFAULT_LOGIN_SECURE
Default value for LOGIN_SECURE. |
static java.lang.String |
LOGIN_FORWARD_SESSION_PARAM
Name of the HTTP session object storing path where to continue after login. |
static java.lang.String |
LOGIN_SECURE
Configuration setting specifying if the login page should be displayed in a secure mode using SSL protocol. |
protected javax.servlet.ServletContext |
m_scServletContext
Servlets context. |
protected SessionValidator |
m_sessionValidator
If not null, then this instance will be used to validate session for each request. |
protected java.lang.String |
m_strHandshakeURL
URL of the hadnshake page in case handshake is requried. |
protected static boolean |
s_bApplicationSecure
Flag signaling if whole application will be using SSL. |
protected static boolean |
s_bLoginSecure
Flag signaling if login will be processed using SSL. |
static java.lang.String |
SERVLET_PATH_REQUEST_PARAM
Full URL how this servlet was invoked so that GUI can use it for callbacks. |
static java.lang.String |
SESSION_VALIDATOR_CLASS
Configuration setting specifying name of the class implementing SessionValidator interface to verify validity of a session each time a request is submitted to the server. |
static java.lang.String |
WEBSESSION_DISPATCHER_CACHED
Configuration setting specifying if the web tier should cache the request dispatchers used to dispatch client requests to various web resources. |
static boolean |
WEBSESSION_DISPATCHER_CACHED_DEFAULT
Default value for WEBSESSION_DISPATCHER_CACHED. |
static boolean |
WEBSESSION_HADSHAKE_REQUIRED_DEFAULT
Default value for WEBSESSION_HANDSHAKE_REQUIRED |
static java.lang.String |
WEBSESSION_HANDSHAKE_REQUIRED
Configuration setting specifying if the server must ensure that the client accepted the server session before it allows further communication. |
static java.lang.String |
WEBSESSION_HANDSHAKE_URL
Configuration setting specifying the URL of handshake page to which user will be redirected if handshake is required and session wasn't confirmed at the time when the request is submitted to the server. |
static java.lang.String |
WEBSESSION_LOGIN_REQUIRED
Configuration setting specifying if user has to be logged in in order to process his or her request sent to the server. |
static boolean |
WEBSESSION_LOGIN_REQUIRED_DEFAULT
Default value for WEBSESSION_LOGIN_REQUIRED |
static java.lang.String |
WEBSESSION_LOGIN_URL
Configuration setting specifying the URL of login page to which user will be redirected if login is required and user is not logged in at the time when request is submitted to the server. |
| Constructor Summary | |
|---|---|
WebSessionServlet()
|
|
| Method Summary | |
|---|---|
void |
destroy()
|
protected java.lang.String |
getLoginRedirect(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest)
Get the URL to which user should be redirected after he is successfully logged into the system. |
java.lang.String |
getServletInfo()
|
protected void |
handleNewSession(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
This function handles the scenarios, when the HTTP session generated for the client is still new and the client doesn't know about it yet. |
void |
init(javax.servlet.ServletConfig scConfig)
|
protected boolean |
isApplicationSecure()
Return true if application is running as secure (SSL) |
protected boolean |
isDispatcherCachingEnabled()
Check if caching of request dispatchers is enabled. |
protected boolean |
isLoginSecure()
Return true if login is running as secure (SSL) |
protected void |
preservice(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse,
boolean bLoginVerified)
This method gives derived servlets execute common logic which needs to be executed for each request. |
protected void |
redirect(java.lang.String strUrl,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Redirect client to another page propagating the internal session ID if any. |
protected void |
redirectToHandshake(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Redirect client to the handshake. |
protected void |
redirectToLogin(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Redirect client to the login page. |
protected void |
resetLoginRedirect(javax.servlet.http.HttpSession hsSession)
Reset the URL to which user should be redirected after he is successfully logge to the system to uninitialized value. |
protected boolean |
saveLoginRedirect(javax.servlet.http.HttpSession hsSession,
java.lang.String strFullRedirectURL)
Save the URL to which user should be redirected after he is successfully logged in to the system. |
protected void |
service(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Main service routine for the Servlet. |
protected boolean |
shouldRequestBeSecure()
Return flag if request should be secure. |
protected java.security.Principal |
verifyLogin(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Verify, if user has already logged into this session. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String WEBSESSION_DISPATCHER_CACHED
WEBSESSION_DISPATCHER_CACHED_DEFAULT,
Constant Field Valuespublic static final java.lang.String WEBSESSION_HANDSHAKE_REQUIRED
WEBSESSION_HADSHAKE_REQUIRED_DEFAULT,
Constant Field Valuespublic static final java.lang.String WEBSESSION_HANDSHAKE_URL
public static final java.lang.String WEBSESSION_LOGIN_REQUIRED
WEBSESSION_LOGIN_REQUIRED_DEFAULT,
Constant Field Valuespublic static final java.lang.String WEBSESSION_LOGIN_URL
public static final java.lang.String SESSION_VALIDATOR_CLASS
public static final java.lang.String LOGIN_SECURE
s_bLoginSecure,
DEFAULT_LOGIN_SECURE,
Constant Field Valuespublic static final java.lang.String APPLICATION_SECURE
s_bApplicationSecure,
DEFAULT_APPLICATION_SECURE,
Constant Field Valuespublic static final boolean WEBSESSION_DISPATCHER_CACHED_DEFAULT
WEBSESSION_DISPATCHER_CACHED,
Constant Field Valuespublic static final boolean WEBSESSION_HADSHAKE_REQUIRED_DEFAULT
WEBSESSION_HANDSHAKE_REQUIRED,
Constant Field Valuespublic static final boolean WEBSESSION_LOGIN_REQUIRED_DEFAULT
WEBSESSION_LOGIN_REQUIRED,
Constant Field Valuespublic static final java.lang.String LOGIN_FORWARD_SESSION_PARAM
public static final java.lang.String SERVLET_PATH_REQUEST_PARAM
public static final java.lang.String ATTACH_INTERNAL_SESSION_ID_URL_PARAM
public static final boolean DEFAULT_LOGIN_SECURE
s_bLoginSecure,
LOGIN_SECURE,
Constant Field Valuespublic static final boolean DEFAULT_APPLICATION_SECURE
s_bApplicationSecure,
APPLICATION_SECURE,
Constant Field Valuesprotected java.lang.String m_strHandshakeURL
protected javax.servlet.ServletContext m_scServletContext
protected SessionValidator m_sessionValidator
protected static boolean s_bLoginSecure
LOGIN_SECURE,
DEFAULT_LOGIN_SECUREprotected static boolean s_bApplicationSecure
APPLICATION_SECURE,
DEFAULT_APPLICATION_SECURE| Constructor Detail |
|---|
public WebSessionServlet()
| Method Detail |
|---|
public void init(javax.servlet.ServletConfig scConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.Servletdestroy in class javax.servlet.GenericServlet
protected final void service(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
service in class javax.servlet.http.HttpServlethsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - an error has occured while serving request
java.io.IOException - - an error has occured while writing responsepublic java.lang.String getServletInfo()
getServletInfo in interface javax.servlet.ServletgetServletInfo in class javax.servlet.GenericServletprotected boolean isDispatcherCachingEnabled()
protected void handleNewSession(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
hsSession - - HTTP session objecthsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - problem has occured while processing request
java.io.IOException - - problem has occured while processing requestWEBSESSION_HANDSHAKE_REQUIRED
protected java.security.Principal verifyLogin(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
hsSession - - HTTP session objecthsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - problem has occured while processing request
java.io.IOException - - problem has occured while processing request
protected java.lang.String getLoginRedirect(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest)
hsSession - - HTTP session objecthsrqRequest - - the servlet request
protected boolean saveLoginRedirect(javax.servlet.http.HttpSession hsSession,
java.lang.String strFullRedirectURL)
hsSession - - HTTP session objectstrFullRedirectURL - - URL to redirect user after login
protected void resetLoginRedirect(javax.servlet.http.HttpSession hsSession)
hsSession - - HTTP session object
protected void redirectToLogin(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
hsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - problems redirecting to login
java.io.IOException - - problems redirecting to login
protected void redirectToHandshake(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
hsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - problems redirecting to login
java.io.IOException - - problems redirecting to login
protected void redirect(java.lang.String strUrl,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws javax.servlet.ServletException,
java.io.IOException
strUrl - - part of the URL used for constructing final URLhsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
javax.servlet.ServletException - - problems redirecting to login
java.io.IOException - - problems redirecting to login
protected void preservice(javax.servlet.http.HttpSession hsSession,
javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse,
boolean bLoginVerified)
throws javax.servlet.ServletException,
java.io.IOException
hsSession - - HTTP session objecthsrqRequest - - the servlet request.hsrpResponse - - the servlet response.bLoginVerified - - true if login was verified or it is not required,
false if we are redirecting to the login page
javax.servlet.ServletException - - problems redirecting to login
java.io.IOException - - problems redirecting to loginprotected boolean shouldRequestBeSecure()
protected boolean isApplicationSecure()
protected boolean isLoginSecure()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||