Package uk.ac.warwick.sso.client
Class SSOClientFilter
- java.lang.Object
-
- uk.ac.warwick.sso.client.HandleFilter
-
- uk.ac.warwick.sso.client.SSOClientFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public final class SSOClientFilter extends HandleFilter implements javax.servlet.Filter
SSOClientFilter is responsible for checking cookies for an existing session, looking up the details of the user if one is found, and placing this User object into a request attribute. Even if no user is found, it will place an AnonymousUser object in the request.It is generally appropriate to map this filter to run for all your application requests, i.e. mapped to "/*". It will know not to run when your ShireServlet or LogoutServlet are requested, as long as these are specified correctly in your sso-config.xml file.
getUserFromRequest(HttpServletRequest)can be used to conveniently fetch the current User object from the appropriate request attribute.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTUAL_USER_KEYstatic java.lang.StringGLOBAL_LOGIN_COOKIE_NAMEstatic java.lang.StringPROXY_TICKET_COOKIE_NAMEstatic java.lang.StringUSER_KEY
-
Constructor Summary
Constructors Constructor Description SSOClientFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)uk.ac.warwick.sso.client.AttributeAuthorityResponseFetchergetAaFetcher()uk.ac.warwick.sso.client.SSOConfigurationgetConfig()java.lang.StringgetConfigSuffix()uk.ac.warwick.sso.client.SSOHandlergetHandler()static uk.ac.warwick.userlookup.UsergetUserFromRequest(javax.servlet.http.HttpServletRequest req)Will always return an AnonymousUser if there is either no config or no user in the requeststatic java.lang.StringgetUserKey()uk.ac.warwick.userlookup.UserLookupInterfacegetUserLookup()voidinit(javax.servlet.FilterConfig ctx)voidsetAaFetcher(uk.ac.warwick.sso.client.AttributeAuthorityResponseFetcher aaFetcher)voidsetConfig(uk.ac.warwick.sso.client.SSOConfiguration _config)voidsetConfigLocation(java.lang.String path)voidsetConfigSuffix(java.lang.String configSuffix)voidsetDetectAnonymousOnCampusUsers(boolean detectAnonymousOnCampusUsers)voidsetHandler(uk.ac.warwick.sso.client.SSOClientHandler handler)voidsetRedirectToRefreshSession(boolean redirectToRefreshSession)voidsetUserLookup(uk.ac.warwick.userlookup.UserLookupInterface userLookup)-
Methods inherited from class uk.ac.warwick.sso.client.HandleFilter
filterWithHandler
-
-
-
-
Field Detail
-
USER_KEY
public static final java.lang.String USER_KEY
- See Also:
- Constant Field Values
-
ACTUAL_USER_KEY
public static final java.lang.String ACTUAL_USER_KEY
- See Also:
- Constant Field Values
-
GLOBAL_LOGIN_COOKIE_NAME
public static final java.lang.String GLOBAL_LOGIN_COOKIE_NAME
- See Also:
- Constant Field Values
-
PROXY_TICKET_COOKIE_NAME
public static final java.lang.String PROXY_TICKET_COOKIE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig ctx) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
doFilter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
getUserFromRequest
public static uk.ac.warwick.userlookup.User getUserFromRequest(javax.servlet.http.HttpServletRequest req)
Will always return an AnonymousUser if there is either no config or no user in the request- Parameters:
req- The incoming HTTP request- Returns:
-
getUserKey
public static java.lang.String getUserKey()
-
getConfig
public uk.ac.warwick.sso.client.SSOConfiguration getConfig()
- Specified by:
getConfigin classHandleFilter
-
getHandler
public uk.ac.warwick.sso.client.SSOHandler getHandler()
- Specified by:
getHandlerin classHandleFilter
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
setDetectAnonymousOnCampusUsers
public void setDetectAnonymousOnCampusUsers(boolean detectAnonymousOnCampusUsers)
-
setConfigSuffix
public void setConfigSuffix(java.lang.String configSuffix)
-
setHandler
public void setHandler(uk.ac.warwick.sso.client.SSOClientHandler handler)
-
setUserLookup
public void setUserLookup(uk.ac.warwick.userlookup.UserLookupInterface userLookup)
-
getAaFetcher
public uk.ac.warwick.sso.client.AttributeAuthorityResponseFetcher getAaFetcher()
-
getConfigSuffix
public java.lang.String getConfigSuffix()
-
getUserLookup
public uk.ac.warwick.userlookup.UserLookupInterface getUserLookup()
-
setRedirectToRefreshSession
public void setRedirectToRefreshSession(boolean redirectToRefreshSession)
-
setConfigLocation
public void setConfigLocation(java.lang.String path)
-
setAaFetcher
public void setAaFetcher(uk.ac.warwick.sso.client.AttributeAuthorityResponseFetcher aaFetcher)
-
setConfig
public void setConfig(uk.ac.warwick.sso.client.SSOConfiguration _config)
-
-