diff --git a/web/src/main/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcher.java b/web/src/main/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcher.java index 51e36d28a89..a67b047b7ec 100644 --- a/web/src/main/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcher.java +++ b/web/src/main/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcher.java @@ -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 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 @@ * @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 boolean matches(HttpServletRequest request) { return matchResult != null; } - @Override - @Deprecated - public Map extractUriTemplateVariables(HttpServletRequest request) { - return matcher(request).getVariables(); - } - @Override public MatchResult matcher(HttpServletRequest request) { if (notMatchMethodOrServletPath(request)) { diff --git a/web/src/main/java/org/springframework/security/web/util/matcher/AntPathRequestMatcher.java b/web/src/main/java/org/springframework/security/web/util/matcher/AntPathRequestMatcher.java index 0df94264f67..72219de0a13 100644 --- a/web/src/main/java/org/springframework/security/web/util/matcher/AntPathRequestMatcher.java +++ b/web/src/main/java/org/springframework/security/web/util/matcher/AntPathRequestMatcher.java @@ -57,7 +57,7 @@ * @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 boolean matches(HttpServletRequest request) { return this.matcher.matches(url); } - @Override - @Deprecated - public Map extractUriTemplateVariables(HttpServletRequest request) { - return matcher(request).getVariables(); - } - @Override public MatchResult matcher(HttpServletRequest request) { if (!matches(request)) { diff --git a/web/src/main/java/org/springframework/security/web/util/matcher/RequestVariablesExtractor.java b/web/src/main/java/org/springframework/security/web/util/matcher/RequestVariablesExtractor.java deleted file mode 100644 index 309c6ddd082..00000000000 --- a/web/src/main/java/org/springframework/security/web/util/matcher/RequestVariablesExtractor.java +++ /dev/null @@ -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 extractUriTemplateVariables(HttpServletRequest request); - -} diff --git a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java index 047f42604ca..9de763e9da4 100644 --- a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java @@ -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 void setup() { 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.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); diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/AndRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/AndRequestMatcherTests.java index 62b3781790e..f8ce2ee32d6 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/AndRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/AndRequestMatcherTests.java @@ -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.