Add RequestMatcher.matcher(HttpServletRequest)
Step 3 - Usage of RequestVariablesExtractor or types that are assigned to AntPathRequestMatcher should be replaced with the new method. [closes #7148]
This commit is contained in:
parent
496579dde2
commit
ddf68821cb
|
@ -33,7 +33,6 @@ import org.springframework.security.web.FilterInvocation;
|
||||||
import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource;
|
import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestVariablesExtractor;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,13 +91,8 @@ public final class ExpressionBasedFilterInvocationSecurityMetadataSource
|
||||||
return requestToExpressionAttributesMap;
|
return requestToExpressionAttributesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AbstractVariableEvaluationContextPostProcessor createPostProcessor(
|
private static AbstractVariableEvaluationContextPostProcessor createPostProcessor(RequestMatcher request) {
|
||||||
Object request) {
|
return new RequestVariablesExtractorEvaluationContextPostProcessor(request);
|
||||||
if (request instanceof RequestVariablesExtractor) {
|
|
||||||
return new RequestVariablesExtractorEvaluationContextPostProcessor(
|
|
||||||
(RequestVariablesExtractor) request);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AntPathMatcherEvaluationContextPostProcessor
|
static class AntPathMatcherEvaluationContextPostProcessor
|
||||||
|
@ -118,16 +112,16 @@ public final class ExpressionBasedFilterInvocationSecurityMetadataSource
|
||||||
|
|
||||||
static class RequestVariablesExtractorEvaluationContextPostProcessor
|
static class RequestVariablesExtractorEvaluationContextPostProcessor
|
||||||
extends AbstractVariableEvaluationContextPostProcessor {
|
extends AbstractVariableEvaluationContextPostProcessor {
|
||||||
private final RequestVariablesExtractor matcher;
|
private final RequestMatcher matcher;
|
||||||
|
|
||||||
public RequestVariablesExtractorEvaluationContextPostProcessor(
|
public RequestVariablesExtractorEvaluationContextPostProcessor(
|
||||||
RequestVariablesExtractor matcher) {
|
RequestMatcher matcher) {
|
||||||
this.matcher = matcher;
|
this.matcher = matcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Map<String, String> extractVariables(HttpServletRequest request) {
|
Map<String, String> extractVariables(HttpServletRequest request) {
|
||||||
return this.matcher.extractUriTemplateVariables(request);
|
return this.matcher.matcher(request).getVariables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
|
||||||
* extractUriTemplateVariables(javax.servlet.http.HttpServletRequest)
|
* extractUriTemplateVariables(javax.servlet.http.HttpServletRequest)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
||||||
return matcher(request).getVariables();
|
return matcher(request).getVariables();
|
||||||
}
|
}
|
||||||
|
@ -146,7 +147,7 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DefaultMatcher implements RequestMatcher, RequestVariablesExtractor {
|
private class DefaultMatcher implements RequestMatcher {
|
||||||
|
|
||||||
private final UrlPathHelper pathHelper = new UrlPathHelper();
|
private final UrlPathHelper pathHelper = new UrlPathHelper();
|
||||||
|
|
||||||
|
@ -162,12 +163,6 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
|
||||||
return this.pathMatcher.match(MvcRequestMatcher.this.pattern, lookupPath);
|
return this.pathMatcher.match(MvcRequestMatcher.this.pattern, lookupPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> extractUriTemplateVariables(
|
|
||||||
HttpServletRequest request) {
|
|
||||||
return matcher(request).getVariables();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MatchResult matcher(HttpServletRequest request) {
|
public MatchResult matcher(HttpServletRequest request) {
|
||||||
String lookupPath = this.pathHelper.getLookupPathForRequest(request);
|
String lookupPath = this.pathHelper.getLookupPathForRequest(request);
|
||||||
|
|
|
@ -182,6 +182,7 @@ public final class AntPathRequestMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
||||||
return matcher(request).getVariables();
|
return matcher(request).getVariables();
|
||||||
}
|
}
|
||||||
|
@ -264,7 +265,7 @@ public final class AntPathRequestMatcher
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static interface Matcher {
|
private interface Matcher {
|
||||||
boolean matches(String path);
|
boolean matches(String path);
|
||||||
|
|
||||||
Map<String, String> extractUriTemplateVariables(String path);
|
Map<String, String> extractUriTemplateVariables(String path);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
*
|
*
|
||||||
* @author Rob Winch
|
* @author Rob Winch
|
||||||
* @since 4.1.1
|
* @since 4.1.1
|
||||||
* @deprecated
|
* @deprecated use {@link RequestMatcher.MatchResult} from {@link RequestMatcher#matcher(HttpServletRequest)}
|
||||||
*/
|
*/
|
||||||
public interface RequestVariablesExtractor {
|
public interface RequestVariablesExtractor {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue