From bffaa33c9ec23188526d9078e3d5659ccd553a75 Mon Sep 17 00:00:00 2001 From: Telmo Brugnara Date: Fri, 19 Jun 2020 11:20:48 -0300 Subject: [PATCH] [SHIRO-610] Allways create resolver for non-empty IniWebEnvironment --- .../apache/shiro/env/DefaultEnvironment.java | 2 +- .../shiro/web/env/IniWebEnvironment.java | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java b/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java index 43523a0d37..160e58f40b 100644 --- a/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java +++ b/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java @@ -146,7 +146,7 @@ public T getObject(String name, Class requiredType) throws RequiredTypeEx return null; } if (!requiredType.isInstance(o)) { - String msg = "Object named '" + name + "' is not of required type [" + requiredType.getName() + "]."; + String msg = "Object named '" + name + "' (of type [" + o.getClass().getName() + "]) is not of required type [" + requiredType.getName() + "]."; throw new RequiredTypeException(msg); } return (T)o; diff --git a/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java b/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java index 9d6219e660..81e9f11c0c 100644 --- a/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java +++ b/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java @@ -263,20 +263,13 @@ protected FilterChainResolver createFilterChainResolver() { Ini ini = getIni(); if (!CollectionUtils.isEmpty(ini)) { - //only create a resolver if the 'filters' or 'urls' sections are defined: - Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS); - Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS); - if (!CollectionUtils.isEmpty(urls) || !CollectionUtils.isEmpty(filters)) { - //either the urls section or the filters section was defined. Go ahead and create the resolver: - - Factory factory = (Factory) this.objects.get(FILTER_CHAIN_RESOLVER_NAME); - if (factory instanceof IniFactorySupport) { - IniFactorySupport iniFactory = (IniFactorySupport) factory; - iniFactory.setIni(ini); - iniFactory.setDefaults(this.objects); - } - resolver = factory.getInstance(); + Factory factory = (Factory) this.objects.get(FILTER_CHAIN_RESOLVER_NAME); + if (factory instanceof IniFactorySupport) { + IniFactorySupport iniFactory = (IniFactorySupport) factory; + iniFactory.setIni(ini); + iniFactory.setDefaults(this.objects); } + resolver = factory.getInstance(); } return resolver;