use of org.apache.shiro.web.filter.mgt.FilterChainResolver in project shiro by apache.
the class FilterChainResolverProviderTest method testGet.
@Test
public void testGet() throws Exception {
Injector injector = createMock(Injector.class);
PatternMatcher patternMatcher = createMock(PatternMatcher.class);
underTest.injector = injector;
underTest.setPatternMatcher(patternMatcher);
FilterChainResolver resolver = underTest.get();
Field chainsField = SimpleFilterChainResolver.class.getDeclaredField("chains");
chainsField.setAccessible(true);
Field injectorField = SimpleFilterChainResolver.class.getDeclaredField("injector");
injectorField.setAccessible(true);
Field patternMatcherField = SimpleFilterChainResolver.class.getDeclaredField("patternMatcher");
patternMatcherField.setAccessible(true);
assertSame(chains, chainsField.get(resolver));
assertSame(injector, injectorField.get(resolver));
assertSame(patternMatcher, patternMatcherField.get(resolver));
}
use of org.apache.shiro.web.filter.mgt.FilterChainResolver in project shiro by apache.
the class IniWebEnvironment method configure.
protected void configure() {
this.objects.clear();
WebSecurityManager securityManager = createWebSecurityManager();
setWebSecurityManager(securityManager);
FilterChainResolver resolver = createFilterChainResolver();
if (resolver != null) {
setFilterChainResolver(resolver);
}
}
use of org.apache.shiro.web.filter.mgt.FilterChainResolver in project shiro by apache.
the class IniWebEnvironment method createFilterChainResolver.
protected FilterChainResolver createFilterChainResolver() {
FilterChainResolver resolver = null;
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<FilterChainResolver> factory = (Factory<FilterChainResolver>) 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;
}
use of org.apache.shiro.web.filter.mgt.FilterChainResolver in project shiro by apache.
the class IniShiroFilter method applyFilterChainResolver.
protected void applyFilterChainResolver(Ini ini, Map<String, ?> defaults) {
if (ini == null || ini.isEmpty()) {
// always used).
return;
}
// 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 ((urls != null && !urls.isEmpty()) || (filters != null && !filters.isEmpty())) {
// either the urls section or the filters section was defined. Go ahead and create the resolver
// and set it:
IniFilterChainResolverFactory filterChainResolverFactory = new IniFilterChainResolverFactory(ini, defaults);
filterChainResolverFactory.setFilterConfig(getFilterConfig());
FilterChainResolver resolver = filterChainResolverFactory.getInstance();
setFilterChainResolver(resolver);
}
}
use of org.apache.shiro.web.filter.mgt.FilterChainResolver in project shiro by apache.
the class ShiroFilter method init.
/**
* Configures this instance based on the existing {@link org.apache.shiro.web.env.WebEnvironment} instance
* available to the currently accessible {@link #getServletContext() servletContext}.
*
* @see org.apache.shiro.web.env.EnvironmentLoaderListener
* @since 1.2
*/
@Override
public void init() throws Exception {
WebEnvironment env = WebUtils.getRequiredWebEnvironment(getServletContext());
setSecurityManager(env.getWebSecurityManager());
FilterChainResolver resolver = env.getFilterChainResolver();
if (resolver != null) {
setFilterChainResolver(resolver);
}
}
Aggregations