Great. That was the hint I needed. For posterity, here's some working code:

public class ServletInitializer implements ServletContextListener
{
        public void contextInitialized(ServletContextEvent sce)
        {               
                ServletContext context = sce.getServletContext()
                WebEnvironment we = WebUtils.getWebEnvironment(context)
                PathMatchingFilterChainResolver filterChainResolver =
we.getFilterChainResolver()
                
                // Had to do this bc if there isn't a '[urls]' section in
the ini, the filter chain
                // resolver won't be created and thus will be null
                if (filterChainResolver == null) {
                        filterChainResolver = new 
PathMatchingFilterChainResolver()
                        
((MutableWebEnvironment)we).setFilterChainResolver(filterChainResolver)
                }
                
                FilterChainManager filterChainManager =
filterChainResolver.getFilterChainManager()
                
                assert filterChainManager != null
                
                filterChainManager.addToChain('/login', 'ssl', '8443')
                filterChainManager.addToChain('/login', 'authc')
                
                filterChainManager.addToChain('/logout', 'logout')
                
                def filters = filterChainManager.getFilters()
                
                FormAuthenticationFilter authc = filters['authc']
                
                authc.setLoginUrl('/login')
                
        }
}



--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/Define-filters-at-runtime-tp7578618p7578637.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to