This is an automated email from the ASF dual-hosted git repository. lprimak pushed a commit to branch 3.x in repository https://gitbox.apache.org/repos/asf/shiro.git
commit 5154d35f61ed174a9846484c7d39755d44c3a9ab Author: lprimak <[email protected]> AuthorDate: Sat Feb 7 14:23:31 2026 -0600 enh: removed unnecessary ShiroUrlPathHelper class --- .../autoconfigure/ShiroWebAutoConfiguration.java | 8 ---- .../shiro/spring/web/ShiroUrlPathHelper.java | 42 -------------------- .../web/config/AbstractShiroWebConfiguration.java | 5 --- .../spring/web/config/ShiroWebConfiguration.java | 7 ---- .../shiro/spring/web/ShiroUrlPathHelperTest.groovy | 46 ---------------------- 5 files changed, 108 deletions(-) diff --git a/support/spring-boot/spring-boot-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebAutoConfiguration.java b/support/spring-boot/spring-boot-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebAutoConfiguration.java index 49732ae2f..84877a495 100644 --- a/support/spring-boot/spring-boot-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebAutoConfiguration.java +++ b/support/spring-boot/spring-boot-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebAutoConfiguration.java @@ -33,7 +33,6 @@ import org.apache.shiro.session.mgt.SessionFactory; import org.apache.shiro.session.mgt.SessionManager; import org.apache.shiro.session.mgt.eis.SessionDAO; import org.apache.shiro.spring.boot.autoconfigure.ShiroAutoConfiguration; -import org.apache.shiro.spring.web.ShiroUrlPathHelper; import org.apache.shiro.spring.web.config.AbstractShiroWebConfiguration; import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; import org.apache.shiro.web.servlet.Cookie; @@ -152,11 +151,4 @@ public class ShiroWebAutoConfiguration extends AbstractShiroWebConfiguration { protected ShiroFilterChainDefinition shiroFilterChainDefinition() { return super.shiroFilterChainDefinition(); } - - @Bean - @ConditionalOnMissingBean - @Override - protected ShiroUrlPathHelper shiroUrlPathHelper() { - return super.shiroUrlPathHelper(); - } } diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java b/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java deleted file mode 100644 index ecce70f7d..000000000 --- a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * http://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.apache.shiro.spring.web; - -import org.apache.shiro.web.util.WebUtils; -import org.springframework.web.util.UrlPathHelper; - -import jakarta.servlet.http.HttpServletRequest; - -/** - * A Spring UrlPathHelper that uses Shiro's path resolution logic. - * - * @since 1.7.0 - */ -public class ShiroUrlPathHelper extends UrlPathHelper { - - @Override - public String getPathWithinApplication(HttpServletRequest request) { - return WebUtils.getPathWithinApplication(request); - } - - @Override - public String getPathWithinServletMapping(HttpServletRequest request) { - return WebUtils.getPathWithinApplication(request); - } -} diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebConfiguration.java b/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebConfiguration.java index 2defde5d2..8e29dea6e 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebConfiguration.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebConfiguration.java @@ -24,7 +24,6 @@ import org.apache.shiro.mgt.SessionsSecurityManager; import org.apache.shiro.mgt.SubjectFactory; import org.apache.shiro.session.mgt.SessionManager; import org.apache.shiro.spring.config.AbstractShiroConfiguration; -import org.apache.shiro.spring.web.ShiroUrlPathHelper; import org.apache.shiro.web.mgt.CookieRememberMeManager; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.apache.shiro.web.mgt.DefaultWebSessionStorageEvaluator; @@ -186,8 +185,4 @@ public class AbstractShiroWebConfiguration extends AbstractShiroConfiguration { chainDefinition.addPathDefinition("/**", "authc"); return chainDefinition; } - - protected ShiroUrlPathHelper shiroUrlPathHelper() { - return new ShiroUrlPathHelper(); - } } diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebConfiguration.java b/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebConfiguration.java index f86f1779f..51763317b 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebConfiguration.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebConfiguration.java @@ -30,7 +30,6 @@ import org.apache.shiro.realm.Realm; import org.apache.shiro.session.mgt.SessionFactory; import org.apache.shiro.session.mgt.SessionManager; import org.apache.shiro.session.mgt.eis.SessionDAO; -import org.apache.shiro.spring.web.ShiroUrlPathHelper; import org.apache.shiro.web.servlet.Cookie; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -126,10 +125,4 @@ public class ShiroWebConfiguration extends AbstractShiroWebConfiguration { protected ShiroFilterChainDefinition shiroFilterChainDefinition() { return super.shiroFilterChainDefinition(); } - - @Bean - @Override - protected ShiroUrlPathHelper shiroUrlPathHelper() { - return super.shiroUrlPathHelper(); - } } diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy deleted file mode 100644 index eb092bed5..000000000 --- a/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * http://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.apache.shiro.spring.web - -import org.junit.jupiter.api.Test -import org.springframework.mock.web.MockHttpServletRequest -import org.springframework.web.util.UrlPathHelper - -import static org.hamcrest.MatcherAssert.assertThat -import static org.hamcrest.Matchers.equalTo - -/** - * Tests a couple known differences between the stock and the ShiroUrlPathHelper - */ -class ShiroUrlPathHelperTest { - - @Test - void testGetPathWithinApplication() { - MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/%2e%2e") - assertThat new UrlPathHelper().getPathWithinApplication(request), equalTo("/foo/..") - assertThat new ShiroUrlPathHelper().getPathWithinApplication(request), equalTo("/") - } - - @Test - void testGetPathWithinServletMapping() { - MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/%2e%2e") - assertThat new UrlPathHelper().getPathWithinServletMapping(request), equalTo("/foo/..") - assertThat new ShiroUrlPathHelper().getPathWithinServletMapping(request), equalTo("/") - } -}
