Class AbstractAuthenticationTargetUrlRequestHandler
- java.lang.Object
- 
- org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler
 
- 
- Direct Known Subclasses:
- SimpleUrlAuthenticationSuccessHandler,- SimpleUrlLogoutSuccessHandler
 
 public abstract class AbstractAuthenticationTargetUrlRequestHandler extends java.lang.ObjectBase class containing the logic used by strategies which handle redirection to a URL and are passed anAuthenticationobject as part of the contract. SeeAuthenticationSuccessHandlerandLogoutSuccessHandler, for example.Uses the following logic sequence to determine how it should handle the forward/redirect - If the alwaysUseDefaultTargetUrlproperty is set to true, thedefaultTargetUrlproperty will be used for the destination.
- If a parameter matching the value of targetUrlParameterhas been set on the request, the value will be used as the destination. If you are enabling this functionality, then you should ensure that the parameter cannot be used by an attacker to redirect the user to a malicious site (by clicking on a URL with the parameter included, for example). Typically it would be used when the parameter is included in the login form and submitted with the username and password.
- If the useRefererproperty is set, the "Referer" HTTP header value will be used, if present.
- As a fallback option, the defaultTargetUrlvalue will be used.
 - Since:
- 3.0
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected org.apache.commons.logging.Loglogger
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractAuthenticationTargetUrlRequestHandler()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringdetermineTargetUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Builds the target URL according to the logic defined in the main class Javadoc.protected java.lang.StringdetermineTargetUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication)Builds the target URL according to the logic defined in the main class Javadocprotected java.lang.StringgetDefaultTargetUrl()Supplies the default target Url that will be used if no saved request is found or thealwaysUseDefaultTargetUrlproperty is set to true.protected RedirectStrategygetRedirectStrategy()protected java.lang.StringgetTargetUrlParameter()protected voidhandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication)Invokes the configuredRedirectStrategywith the URL returned by thedetermineTargetUrlmethod.protected booleanisAlwaysUseDefaultTargetUrl()voidsetAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl)Iftrue, will always redirect to the value ofdefaultTargetUrl(defaults tofalse).voidsetDefaultTargetUrl(java.lang.String defaultTargetUrl)Supplies the default target Url that will be used if no saved request is found in the session, or thealwaysUseDefaultTargetUrlproperty is set to true.voidsetRedirectStrategy(RedirectStrategy redirectStrategy)Allows overriding of the behaviour when redirecting to a target URL.voidsetTargetUrlParameter(java.lang.String targetUrlParameter)If this property is set, the current request will be checked for this a parameter with this name and the value used as the target URL if present.voidsetUseReferer(boolean useReferer)If set totruetheRefererheader will be used (if available).
 
- 
- 
- 
Method Detail- 
handleprotected void handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication) throws java.io.IOException, javax.servlet.ServletExceptionInvokes the configuredRedirectStrategywith the URL returned by thedetermineTargetUrlmethod.The redirect will not be performed if the response has already been committed. - Throws:
- java.io.IOException
- javax.servlet.ServletException
 
 - 
determineTargetUrlprotected java.lang.String determineTargetUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Authentication authentication)Builds the target URL according to the logic defined in the main class Javadoc- Since:
- 5.2
 
 - 
determineTargetUrlprotected java.lang.String determineTargetUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Builds the target URL according to the logic defined in the main class Javadoc.
 - 
getDefaultTargetUrlprotected final java.lang.String getDefaultTargetUrl() Supplies the default target Url that will be used if no saved request is found or thealwaysUseDefaultTargetUrlproperty is set to true. If not set, defaults to/.- Returns:
- the defaultTargetUrl property
 
 - 
setDefaultTargetUrlpublic void setDefaultTargetUrl(java.lang.String defaultTargetUrl) Supplies the default target Url that will be used if no saved request is found in the session, or thealwaysUseDefaultTargetUrlproperty is set to true. If not set, defaults to/. It will be treated as relative to the web-app's context path, and should include the leading/. Alternatively, inclusion of a scheme name (such as "http://" or "https://") as the prefix will denote a fully-qualified URL and this is also supported.- Parameters:
- defaultTargetUrl-
 
 - 
setAlwaysUseDefaultTargetUrlpublic void setAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl) Iftrue, will always redirect to the value ofdefaultTargetUrl(defaults tofalse).
 - 
isAlwaysUseDefaultTargetUrlprotected boolean isAlwaysUseDefaultTargetUrl() 
 - 
setTargetUrlParameterpublic void setTargetUrlParameter(java.lang.String targetUrlParameter) If this property is set, the current request will be checked for this a parameter with this name and the value used as the target URL if present.- Parameters:
- targetUrlParameter- the name of the parameter containing the encoded target URL. Defaults to null.
 
 - 
getTargetUrlParameterprotected java.lang.String getTargetUrlParameter() 
 - 
setRedirectStrategypublic void setRedirectStrategy(RedirectStrategy redirectStrategy) Allows overriding of the behaviour when redirecting to a target URL.
 - 
getRedirectStrategyprotected RedirectStrategy getRedirectStrategy() 
 - 
setUseRefererpublic void setUseReferer(boolean useReferer) If set totruetheRefererheader will be used (if available). Defaults tofalse.
 
- 
 
-