Issue #4236 - move redirect code to utility method
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
4f6585562f
commit
4e43258785
|
@ -251,8 +251,7 @@ public class OpenIdAuthenticator extends LoginAuthenticator
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Session ID should be cookie for OpenID authentication to work");
|
LOG.debug("Session ID should be cookie for OpenID authentication to work");
|
||||||
|
|
||||||
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
|
baseResponse.sendRedirect(getRedirectCode(baseRequest.getHttpVersion()), URIUtil.addPaths(request.getContextPath(), _errorPage));
|
||||||
baseResponse.sendRedirect(redirectCode, URIUtil.addPaths(request.getContextPath(), _errorPage));
|
|
||||||
return Authentication.SEND_FAILURE;
|
return Authentication.SEND_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +296,7 @@ public class OpenIdAuthenticator extends LoginAuthenticator
|
||||||
LOG.debug("authenticated {}->{}", openIdAuth, nuri);
|
LOG.debug("authenticated {}->{}", openIdAuth, nuri);
|
||||||
|
|
||||||
response.setContentLength(0);
|
response.setContentLength(0);
|
||||||
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
|
baseResponse.sendRedirect(getRedirectCode(baseRequest.getHttpVersion()), nuri);
|
||||||
baseResponse.sendRedirect(redirectCode, nuri);
|
|
||||||
return openIdAuth;
|
return openIdAuth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,8 +315,7 @@ public class OpenIdAuthenticator extends LoginAuthenticator
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("auth failed {}", _errorPage);
|
LOG.debug("auth failed {}", _errorPage);
|
||||||
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
|
baseResponse.sendRedirect(getRedirectCode(baseRequest.getHttpVersion()), URIUtil.addPaths(request.getContextPath(), _errorPage));
|
||||||
baseResponse.sendRedirect(redirectCode, URIUtil.addPaths(request.getContextPath(), _errorPage));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Authentication.SEND_FAILURE;
|
return Authentication.SEND_FAILURE;
|
||||||
|
@ -408,8 +405,7 @@ public class OpenIdAuthenticator extends LoginAuthenticator
|
||||||
String challengeUri = getChallengeUri(request);
|
String challengeUri = getChallengeUri(request);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("challenge {}->{}", session.getId(), challengeUri);
|
LOG.debug("challenge {}->{}", session.getId(), challengeUri);
|
||||||
int redirectCode = (baseRequest.getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion() ? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
|
baseResponse.sendRedirect(getRedirectCode(baseRequest.getHttpVersion()), challengeUri);
|
||||||
baseResponse.sendRedirect(redirectCode, challengeUri);
|
|
||||||
|
|
||||||
return Authentication.SEND_CONTINUE;
|
return Authentication.SEND_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -437,6 +433,12 @@ public class OpenIdAuthenticator extends LoginAuthenticator
|
||||||
return pathInContext != null && (pathInContext.equals(_errorPath));
|
return pathInContext != null && (pathInContext.equals(_errorPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getRedirectCode(HttpVersion httpVersion)
|
||||||
|
{
|
||||||
|
return (httpVersion.getVersion() < HttpVersion.HTTP_1_1.getVersion()
|
||||||
|
? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER);
|
||||||
|
}
|
||||||
|
|
||||||
private String getRedirectUri(HttpServletRequest request)
|
private String getRedirectUri(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
final StringBuffer redirectUri = new StringBuffer(128);
|
final StringBuffer redirectUri = new StringBuffer(128);
|
||||||
|
|
Loading…
Reference in New Issue