Merge 68b0822f15
into 725745defd
This commit is contained in:
commit
78801f19a6
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||
import org.springframework.security.web.util.matcher.RequestVariablesExtractor;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
||||
|
@ -49,7 +48,7 @@ import org.springframework.web.util.UrlPathHelper;
|
|||
* @deprecated Please use {@link PathPatternRequestMatcher} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtractor {
|
||||
public class MvcRequestMatcher implements RequestMatcher {
|
||||
|
||||
private final DefaultMatcher defaultMatcher = new DefaultMatcher();
|
||||
|
||||
|
@ -79,12 +78,6 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
|
|||
return matchResult != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
||||
return matcher(request).getVariables();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchResult matcher(HttpServletRequest request) {
|
||||
if (notMatchMethodOrServletPath(request)) {
|
||||
|
|
|
@ -57,7 +57,7 @@ import org.springframework.web.util.UrlPathHelper;
|
|||
* @deprecated please use {@link PathPatternRequestMatcher} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final class AntPathRequestMatcher implements RequestMatcher, RequestVariablesExtractor {
|
||||
public final class AntPathRequestMatcher implements RequestMatcher {
|
||||
|
||||
private static final String MATCH_ALL = "/**";
|
||||
|
||||
|
@ -194,12 +194,6 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
|
|||
return this.matcher.matches(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
||||
return matcher(request).getVariables();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchResult matcher(HttpServletRequest request) {
|
||||
if (!matches(request)) {
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.security.web.util.matcher;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* An interface for extracting URI variables from the {@link HttpServletRequest}.
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 4.1.1
|
||||
* @deprecated use {@link RequestMatcher.MatchResult} from
|
||||
* {@link RequestMatcher#matcher(HttpServletRequest)}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RequestVariablesExtractor {
|
||||
|
||||
/**
|
||||
* Extract URL template variables from the request.
|
||||
* @param request the HttpServletRequest to obtain a URL to extract the variables from
|
||||
* @return the URL variables or empty if no variables are found
|
||||
*/
|
||||
Map<String, String> extractUriTemplateVariables(HttpServletRequest request);
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.security.web.servlet.util.matcher;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -71,39 +69,6 @@ public class MvcRequestMatcherTests {
|
|||
this.matcher = new MvcRequestMatcher(this.introspector, "/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractUriTemplateVariablesSuccess() throws Exception {
|
||||
this.matcher = new MvcRequestMatcher(this.introspector, "/{p}");
|
||||
given(this.introspector.getMatchableHandlerMapping(this.request)).willReturn(null);
|
||||
assertThat(this.matcher.extractUriTemplateVariables(this.request)).containsEntry("p", "path");
|
||||
assertThat(this.matcher.matcher(this.request).getVariables()).containsEntry("p", "path");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractUriTemplateVariablesFail() throws Exception {
|
||||
given(this.result.extractUriTemplateVariables()).willReturn(Collections.<String, String>emptyMap());
|
||||
given(this.introspector.getMatchableHandlerMapping(this.request)).willReturn(this.mapping);
|
||||
given(this.mapping.match(eq(this.request), this.pattern.capture())).willReturn(this.result);
|
||||
assertThat(this.matcher.extractUriTemplateVariables(this.request)).isEmpty();
|
||||
assertThat(this.matcher.matcher(this.request).getVariables()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractUriTemplateVariablesDefaultSuccess() throws Exception {
|
||||
this.matcher = new MvcRequestMatcher(this.introspector, "/{p}");
|
||||
given(this.introspector.getMatchableHandlerMapping(this.request)).willReturn(null);
|
||||
assertThat(this.matcher.extractUriTemplateVariables(this.request)).containsEntry("p", "path");
|
||||
assertThat(this.matcher.matcher(this.request).getVariables()).containsEntry("p", "path");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractUriTemplateVariablesDefaultFail() throws Exception {
|
||||
this.matcher = new MvcRequestMatcher(this.introspector, "/nomatch/{p}");
|
||||
given(this.introspector.getMatchableHandlerMapping(this.request)).willReturn(null);
|
||||
assertThat(this.matcher.extractUriTemplateVariables(this.request)).isEmpty();
|
||||
assertThat(this.matcher.matcher(this.request).getVariables()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesServletPathTrue() throws Exception {
|
||||
given(this.introspector.getMatchableHandlerMapping(this.request)).willReturn(this.mapping);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
Loading…
Reference in New Issue