shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fpa...@apache.org
Subject [shiro] branch 1.6.x updated: Add name to ShiroFilter's @ConditionalOnMissingBean
Date Thu, 03 Sep 2020 19:18:16 GMT
This is an automated email from the ASF dual-hosted git repository.

fpapon pushed a commit to branch 1.6.x
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/1.6.x by this push:
     new 886569d  Add name to ShiroFilter's @ConditionalOnMissingBean
     new ea680b4  Merge pull request #255 from ricardolsmendes/add-name-shirofilter-conditional
886569d is described below

commit 886569d38ba40ec8555b88084b4f2c4778ca7ab1
Author: Ricardo Mendes <ricardolsmendes@gmail.com>
AuthorDate: Wed Aug 26 15:46:56 2020 -0300

    Add name to ShiroFilter's @ConditionalOnMissingBean
    
    Closes [SHIRO-792]
---
 .../web/autoconfigure/ShiroWebFilterConfiguration.java       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/support/spring-boot/spring-boot-web-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.java
b/support/spring-boot/spring-boot-web-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.java
index 9a60a0c..81a11ec 100644
--- a/support/spring-boot/spring-boot-web-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.java
+++ b/support/spring-boot/spring-boot-web-starter/src/main/java/org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.java
@@ -37,6 +37,9 @@ import java.util.List;
 @ConditionalOnProperty(name = "shiro.web.enabled", matchIfMissing = true)
 public class ShiroWebFilterConfiguration extends AbstractShiroWebFilterConfiguration {
 
+    public static final String REGISTRATION_BEAN_NAME = "filterShiroFilterRegistrationBean";
+    public static final String FILTER_NAME = "shiroFilter";
+
     @Bean
     @ConditionalOnMissingBean
     @Override
@@ -44,13 +47,14 @@ public class ShiroWebFilterConfiguration extends AbstractShiroWebFilterConfigura
         return super.shiroFilterFactoryBean();
     }
 
-    @Bean(name = "filterShiroFilterRegistrationBean")
-    @ConditionalOnMissingBean
-    protected FilterRegistrationBean filterShiroFilterRegistrationBean() throws Exception
{
+    @Bean(name = REGISTRATION_BEAN_NAME)
+    @ConditionalOnMissingBean(name = REGISTRATION_BEAN_NAME)
+    protected FilterRegistrationBean<AbstractShiroFilter> filterShiroFilterRegistrationBean()
throws Exception {
 
-        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
+        FilterRegistrationBean<AbstractShiroFilter> filterRegistrationBean = new FilterRegistrationBean<>();
         filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD,
DispatcherType.INCLUDE, DispatcherType.ERROR);
         filterRegistrationBean.setFilter((AbstractShiroFilter) shiroFilterFactoryBean().getObject());
+        filterRegistrationBean.setName(FILTER_NAME);
         filterRegistrationBean.setOrder(1);
 
         return filterRegistrationBean;


Mime
View raw message