SEC-405: Extract out target URL determination method.

This commit is contained in:
Ben Alex 2007-05-25 02:07:44 +00:00
parent 998fc938df
commit d0d645788a
1 changed files with 13 additions and 7 deletions

View File

@ -394,13 +394,8 @@ public abstract class AbstractProcessingFilter implements Filter, InitializingBe
logger.debug("Updated SecurityContextHolder to contain the following Authentication: '" + authResult + "'"); logger.debug("Updated SecurityContextHolder to contain the following Authentication: '" + authResult + "'");
} }
// Don't attempt to obtain the url from the saved request if alwaysUsedefaultTargetUrl is set String targetUrl = determineTargetUrl(request);
String targetUrl = alwaysUseDefaultTargetUrl ? null : obtainFullRequestUrl(request);
if (targetUrl == null) {
targetUrl = getDefaultTargetUrl();
}
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Redirecting to target URL from HTTP Session (or default): " + targetUrl); logger.debug("Redirecting to target URL from HTTP Session (or default): " + targetUrl);
} }
@ -416,6 +411,17 @@ public abstract class AbstractProcessingFilter implements Filter, InitializingBe
sendRedirect(request, response, targetUrl); sendRedirect(request, response, targetUrl);
} }
protected String determineTargetUrl(HttpServletRequest request) {
// Don't attempt to obtain the url from the saved request if alwaysUsedefaultTargetUrl is set
String targetUrl = alwaysUseDefaultTargetUrl ? null : obtainFullRequestUrl(request);
if (targetUrl == null) {
targetUrl = getDefaultTargetUrl();
}
return targetUrl;
}
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
AuthenticationException failed) throws IOException { AuthenticationException failed) throws IOException {