Class RetainAnchorFilter
- java.lang.Object
-
- org.springframework.web.filter.GenericFilterBean
-
- com.devonfw.module.security.common.impl.web.RetainAnchorFilter
-
- All Implemented Interfaces:
javax.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public class RetainAnchorFilter extends org.springframework.web.filter.GenericFilterBeanSpring Security filter that preserves the URL anchor if the authentication process contains redirects (e.g. if the login is performed via CAS or form login). With standard redirects (default Spring Security behavior), Internet Explorer (6.0 and 8.0) discard the anchor part of the URL such that e.g. bookmarking does not work properly. Firefox re-appends the anchor part. This filter replaces redirects to URLs that match a certain pattern (storeUrlPattern) with a Javascript page that stores the URL anchor in a cookie, and replaces redirects to URLs that match another pattern (restoreUrlPattern) with a Javascript page that restores the URL anchor from that cookie. The cookie name can be set via the attributecookieName.- See Also:
- Forum post of guidow08, Forum post of mpickell
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classRetainAnchorFilter.RedirectResponseWrapperHttpServletResponseWrapper that replaces the redirect by appropriate Javascript code.
-
Field Summary
Fields Modifier and Type Field Description private StringcookieNameprivate StringrestoreUrlPatternprivate StringstoreUrlPattern
-
Constructor Summary
Constructors Constructor Description RetainAnchorFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)voidsetCookieName(String cookieName)Sets the cookie name in which the anchor data should be saved.voidsetRestoreUrlPattern(String restoreUrlPattern)Sets the url pattern for restoring anchors.voidsetStoreUrlPattern(String storeUrlPattern)Sets the url pattern for storing anchors.
-
-
-
Method Detail
-
setStoreUrlPattern
public void setStoreUrlPattern(String storeUrlPattern)
Sets the url pattern for storing anchors.- Parameters:
storeUrlPattern- url regular expression
-
setRestoreUrlPattern
public void setRestoreUrlPattern(String restoreUrlPattern)
Sets the url pattern for restoring anchors.- Parameters:
restoreUrlPattern- url regular expression
-
setCookieName
public void setCookieName(String cookieName)
Sets the cookie name in which the anchor data should be saved.- Parameters:
cookieName- name of the cookie
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
-