mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
SEC-1226: Renamed useRelativeContext to contextRelative to match corresponding flag name in Spring Framework.
This commit is contained in:
parent
9c7423599e
commit
593d2e227a
@ -13,24 +13,24 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class DefaultRedirectStrategy implements RedirectStrategy {
|
public class DefaultRedirectStrategy implements RedirectStrategy {
|
||||||
private boolean useRelativeContext;
|
private boolean contextRelative;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects the response to the supplied URL.
|
* Redirects the response to the supplied URL.
|
||||||
* <p>
|
* <p>
|
||||||
* If <tt>useRelativeContext</tt> is set, the redirect value will be the value after the request context path.
|
* If <tt>contextRelative</tt> is set, the redirect value will be the value after the request context path.
|
||||||
*/
|
*/
|
||||||
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
|
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
|
||||||
String finalUrl;
|
String finalUrl;
|
||||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||||
if (useRelativeContext) {
|
if (contextRelative) {
|
||||||
finalUrl = url;
|
finalUrl = url;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
finalUrl = request.getContextPath() + url;
|
finalUrl = request.getContextPath() + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (useRelativeContext) {
|
else if (contextRelative) {
|
||||||
// Calculate the relative URL from the fully qualifed URL, minus the protocol and base context.
|
// Calculate the relative URL from the fully qualifed URL, minus the protocol and base context.
|
||||||
int len = request.getContextPath().length();
|
int len = request.getContextPath().length();
|
||||||
int index = url.indexOf(request.getContextPath()) + len;
|
int index = url.indexOf(request.getContextPath()) + len;
|
||||||
@ -51,8 +51,8 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
|
|||||||
* If <tt>true</tt>, causes any redirection URLs to be calculated minus the protocol
|
* If <tt>true</tt>, causes any redirection URLs to be calculated minus the protocol
|
||||||
* and context path (defaults to <tt>false</tt>).
|
* and context path (defaults to <tt>false</tt>).
|
||||||
*/
|
*/
|
||||||
public void setUseRelativeContext(boolean useRelativeContext) {
|
public void setContextRelative(boolean useRelativeContext) {
|
||||||
this.useRelativeContext = useRelativeContext;
|
this.contextRelative = useRelativeContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user