Rework determineTargetUrl for Readability
Closes gh-12344
This commit is contained in:
parent
58e948a781
commit
6b8a778da8
|
@ -107,31 +107,25 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
|
||||||
if (isAlwaysUseDefaultTargetUrl()) {
|
if (isAlwaysUseDefaultTargetUrl()) {
|
||||||
return this.defaultTargetUrl;
|
return this.defaultTargetUrl;
|
||||||
}
|
}
|
||||||
// Check for the parameter and use that if available
|
// with or without value the targetUrlParameter take precedence
|
||||||
String targetUrl = null;
|
if (StringUtils.hasText(this.targetUrlParameter)
|
||||||
if (this.targetUrlParameter != null) {
|
&& StringUtils.hasText(request.getParameter(this.targetUrlParameter))) {
|
||||||
targetUrl = request.getParameter(this.targetUrlParameter);
|
trace("Using url %s from request parameter %s", request.getParameter(this.targetUrlParameter),
|
||||||
if (StringUtils.hasText(targetUrl)) {
|
this.targetUrlParameter);
|
||||||
|
return request.getParameter(this.targetUrlParameter);
|
||||||
|
}
|
||||||
|
if (this.targetUrlParameter == null && this.useReferer) {
|
||||||
|
trace("Using url %s from Referer header", request.getHeader("Referer"));
|
||||||
|
return request.getHeader("Referer");
|
||||||
|
}
|
||||||
|
trace("Using default url %s", this.defaultTargetUrl);
|
||||||
|
return this.defaultTargetUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void trace(String msg, String... msgParts) {
|
||||||
if (this.logger.isTraceEnabled()) {
|
if (this.logger.isTraceEnabled()) {
|
||||||
this.logger.trace(LogMessage.format("Using url %s from request parameter %s", targetUrl,
|
this.logger.trace(LogMessage.format(msg, msgParts));
|
||||||
this.targetUrlParameter));
|
|
||||||
}
|
}
|
||||||
return targetUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.useReferer && !StringUtils.hasLength(targetUrl)) {
|
|
||||||
targetUrl = request.getHeader("Referer");
|
|
||||||
if (this.logger.isTraceEnabled()) {
|
|
||||||
this.logger.trace(LogMessage.format("Using url %s from Referer header", targetUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!StringUtils.hasText(targetUrl)) {
|
|
||||||
targetUrl = this.defaultTargetUrl;
|
|
||||||
if (this.logger.isTraceEnabled()) {
|
|
||||||
this.logger.trace(LogMessage.format("Using default url %s", targetUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return targetUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue