PortalServletFilter Class
- public class PortalServletFilter
extends Object
implements Filter
Filters can interact with external resources. In this case, we associate the
filter with the Servlet (see web.xml) so that, each time the
servlet is called, this filter checks for user logins. If found, it delegates
to the SessionHelper for profile swapping into/out of Session, firing events,
tagging a logged in user via a Session attribute.
Configure this filter in web.xml as follows:
PortalServletFilter
com.bea.p13n.servlets.PortalServletFilter
PortalServletFilter
*
-
Hierarchy
-
Object
PortalServletFilter
-
All Implemented Interfaces
-
Filter
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
createAnonymousProfile
protected boolean createAnonymousProfile
createNewProfile
protected boolean createNewProfile
- If not tracking anonymous, and if not using anonynomus, then we don't
create a new profile wrapper. Otherwise, we always create something.
defaultSkipPattern
protected String
defaultSkipPattern
fireLoginEvent
protected boolean fireLoginEvent
- Init parameters set in web.xml, default values
skipRequestPattern
protected String
skipRequestPattern
- Patterns in the request that will cause us to bypass this request.
It's useful to skip images, java script, css, etc
trackAnonymousUsers
protected boolean trackAnonymousUsers
PortalServletFilter
public PortalServletFilter()
checkProfileType(ProfileWrapper, HttpServletRequest, HttpServletResponse) Method
protected ProfileType
checkProfileType(ProfileWrapper
profile,
HttpServletRequest
request,
HttpServletResponse
response)
throws ServletException
Check that we're dealing with the right profile type
Exceptions
-
ServletException
destroy() Method
public void destroy()
doFilter(ServletRequest, ServletResponse, FilterChain) Method
public void doFilter(ServletRequest
req,
ServletResponse
res,
FilterChain
chain)
throws IOException
, ServletException
Called when the servlet associated with this filter is invoked. Test for
presence of AnonymousProfileWrapper in Session, do stuff, then send it on
to the next filter in the chain, if there is one.
Exceptions
-
IOException
-
ServletException
doTrackAnonymousUsers(ProfileWrapper, HttpServletRequest, HttpServletResponse) Method
protected void doTrackAnonymousUsers(ProfileWrapper
profile,
HttpServletRequest
request,
HttpServletResponse
response)
throws Exception
If we're tracking anonymous users, more to be done. Make sure we've got the
right profile type in session. If user has registered, delete their cookie.
If visit threshold exceeded, hand them a new cookie.
Exceptions
-
Exception
getFilterConfig() Method
public FilterConfig
getFilterConfig()
Required by Filter interface
init(FilterConfig) Method
public void init(FilterConfig
fc)
throws ServletException
The init method is called by the container when the filter is instantiated.
These parameters are configured in web.xml as follows:
PortalServletFilter
com.bea.p13n.servlets.PortalServletFilter
skipRequestPattern
/css/, /js/, /image/, /wlwdir
Skip over these type of requests (no profile manipulation). Pattern is glob-style. This entry is REQUIRED.
fireSessionLoginEvent
false
Option to fire SessionLoginEvent , defaults to false if not set
createAnonymousProfile
true
Create an anonymous profile for every session. Defaults to true seconds if not set
enableTrackedAnonymous
false
Option to track anonymous users , defaults to false if not set. 'createAnonymousProfile' is ignored if this is true
trackedAnonymousVisitDuration
5
Length in seconds visitor must be on site before we start tracking them . Defaults to 60 seconds if not set
Exceptions
-
ServletException
setFilterConfig(FilterConfig) Method
public void setFilterConfig(FilterConfig
fc)
Required by Filter interface
setSkipRequests(String) Method
protected void setSkipRequests(String
noDo)
Construct the list of requests we're going to ignore
showHeaders(HttpServletRequest) Method
protected void showHeaders(HttpServletRequest
request)
Debug purposes, show headers
showRequest(HttpServletRequest) Method
protected void showRequest(HttpServletRequest
request)
Debug purposes, show info about request
skipRequest(HttpServletRequest) Method
protected boolean skipRequest(HttpServletRequest
request)
Determine wheter we're going to skip this request