SEC-699: Make TargetUrlResolverImpl parameter non-optional
http://jira.springframework.org/browse/SEC-699
This commit is contained in:
parent
c2147144ad
commit
6fcadb2022
|
@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.security.Authentication;
|
import org.springframework.security.Authentication;
|
||||||
import org.springframework.security.ui.savedrequest.SavedRequest;
|
import org.springframework.security.ui.savedrequest.SavedRequest;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,10 +38,10 @@ import org.springframework.util.StringUtils;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TargetUrlResolverImpl implements TargetUrlResolver {
|
public class TargetUrlResolverImpl implements TargetUrlResolver {
|
||||||
public static String DEFAULT_TARGET_PARAMETER = "redirect";
|
public static String DEFAULT_TARGET_PARAMETER = "spring-security-redirect";
|
||||||
|
|
||||||
/* SEC-213 */
|
/* SEC-213 */
|
||||||
private String targetUrlParameter;
|
private String targetUrlParameter = DEFAULT_TARGET_PARAMETER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If <code>true</code>, will only use <code>SavedRequest</code> to determine the target URL on successful
|
* If <code>true</code>, will only use <code>SavedRequest</code> to determine the target URL on successful
|
||||||
|
@ -57,17 +58,13 @@ public class TargetUrlResolverImpl implements TargetUrlResolver {
|
||||||
public String determineTargetUrl(SavedRequest savedRequest, HttpServletRequest currentRequest,
|
public String determineTargetUrl(SavedRequest savedRequest, HttpServletRequest currentRequest,
|
||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
|
|
||||||
String targetUrl = null;
|
String targetUrl = currentRequest.getParameter(targetUrlParameter);
|
||||||
|
|
||||||
if (targetUrlParameter != null) {
|
if (StringUtils.hasText(targetUrl)) {
|
||||||
targetUrl = currentRequest.getParameter(targetUrlParameter);
|
try {
|
||||||
|
return URLDecoder.decode(targetUrl, "UTF-8");
|
||||||
if (StringUtils.hasText(targetUrl)) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
try {
|
throw new IllegalStateException("UTF-8 not supported. Shouldn't be possible");
|
||||||
return URLDecoder.decode(targetUrl, "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new IllegalStateException("UTF-8 not supported. Shouldn't be possible");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +103,7 @@ public class TargetUrlResolverImpl implements TargetUrlResolver {
|
||||||
* to "redirect".
|
* to "redirect".
|
||||||
*/
|
*/
|
||||||
public void setTargetUrlParameter(String targetUrlParameter) {
|
public void setTargetUrlParameter(String targetUrlParameter) {
|
||||||
|
Assert.hasText("targetUrlParamete canot be null or empty");
|
||||||
this.targetUrlParameter = targetUrlParameter;
|
this.targetUrlParameter = targetUrlParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue