Class UifSessionTimeoutFilter
- All Implemented Interfaces:
javax.servlet.Filter
IMPORTANT! In order to work correctly this filter should be the first filter invoked (even before the login filter)
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filerChain) Checks for a session timeout and if one has occurred pulls the view session policy to determine whether a redirect needs to happenprotected StringgetRedirectUrl(ViewSessionPolicy sessionPolicy, javax.servlet.http.HttpServletRequest httpServletRequest) Inspects the given view session policy to determine how the request should be redirectedprotected ViewDictionaryServiceRetrieves implementation of the view dictionary serviceprotected StringgetViewIdFromRequest(javax.servlet.http.HttpServletRequest request) Attempts to resolve a view id from the given requestprotected static ViewServicevoidinit(javax.servlet.FilterConfig filterConfig) protected voidsendRedirect(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, String redirectUrl) Sends a redirect request either through the standard http redirect mechanism, or by sending back an Ajax response indicating a redirect should occur
-
Constructor Details
-
UifSessionTimeoutFilter
public UifSessionTimeoutFilter()
-
-
Method Details
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException - Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filerChain) throws IOException, javax.servlet.ServletException Checks for a session timeout and if one has occurred pulls the view session policy to determine whether a redirect needs to happenTo determine whether a session timeout has occurred, the filter looks for the existence of a request parameter named
UifParameters.SESSION_ID. If found it then compares that id to the id on the current session. If they are different, or a session does not currently exist a timeout is assumed. In addition, if a request was made for a form key and the view has session storage enabled, a check is made to verify the form manager contains a session form. If not this is treated like a session timeoutIf a timeout has occurred an attempt is made to resolve a view from the request (based on the view id or type parameters), then the associated
ViewSessionPolicyis pulled which indicates how the timeout should be handled. This either results in doing a redirect or nothing- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException- See Also:
-
getViewIdFromRequest
Attempts to resolve a view id from the given requestFirst an attempt will be made to find the view id as a request parameter. If no such request parameter is found, the request will be looked at for view type information and a call will be made to the view service to find the view id by type
If a view id is found it is stuck in the request as an attribute (under the key
UifParameters.VIEW_ID) for subsequent retrieval- Parameters:
request- instance to resolve view id for- Returns:
- view id if one is found, null if not found
-
getRedirectUrl
protected String getRedirectUrl(ViewSessionPolicy sessionPolicy, javax.servlet.http.HttpServletRequest httpServletRequest) Inspects the given view session policy to determine how the request should be redirectedThe request will either be redirected to the application home, a custom URL, the same request URL but modified to call the
sessionTimeoutmethod, or a redirect to show the session timeout view- Parameters:
sessionPolicy- session policy instance to inspecthttpServletRequest- request instance for pulling parameters- Returns:
- redirect URL or null if no redirect was configured
-
sendRedirect
protected void sendRedirect(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, String redirectUrl) throws IOException Sends a redirect request either through the standard http redirect mechanism, or by sending back an Ajax response indicating a redirect should occur- Parameters:
httpServletRequest- request instance the timeout occurred forhttpServletResponse- response object that redirect should occur onredirectUrl- url to redirect to- Throws:
IOException
-
getViewService
-
getViewDictionaryService
Retrieves implementation of the view dictionary service- Returns:
- view dictionary service instance
-
destroy
public void destroy()- Specified by:
destroyin interfacejavax.servlet.Filter- See Also:
-