Search in sources :

Example 1 with WebSecurityManager

use of org.apache.shiro.web.mgt.WebSecurityManager in project dropwizard-shiro by silb.

the class ShiroBundle method createFilter.

/**
     * Create the Shiro filter. Overriding this method allows for complete customization of how Shiro is initialized.
     */
protected Filter createFilter(final T configuration) {
    ShiroConfiguration shiroConfig = narrow(configuration);
    final IniWebEnvironment shiroEnv = new IniWebEnvironment();
    shiroEnv.setConfigLocations(shiroConfig.iniConfigs());
    shiroEnv.init();
    AbstractShiroFilter shiroFilter = new AbstractShiroFilter() {

        @Override
        public void init() throws Exception {
            Collection<Realm> realms = createRealms(configuration);
            WebSecurityManager securityManager = realms.isEmpty() ? shiroEnv.getWebSecurityManager() : new DefaultWebSecurityManager(realms);
            setSecurityManager(securityManager);
            setFilterChainResolver(shiroEnv.getFilterChainResolver());
        }
    };
    return shiroFilter;
}
Also used : WebSecurityManager(org.apache.shiro.web.mgt.WebSecurityManager) DefaultWebSecurityManager(org.apache.shiro.web.mgt.DefaultWebSecurityManager) DefaultWebSecurityManager(org.apache.shiro.web.mgt.DefaultWebSecurityManager) AbstractShiroFilter(org.apache.shiro.web.servlet.AbstractShiroFilter) IniWebEnvironment(org.apache.shiro.web.env.IniWebEnvironment) Realm(org.apache.shiro.realm.Realm)

Aggregations

Realm (org.apache.shiro.realm.Realm)1 IniWebEnvironment (org.apache.shiro.web.env.IniWebEnvironment)1 DefaultWebSecurityManager (org.apache.shiro.web.mgt.DefaultWebSecurityManager)1 WebSecurityManager (org.apache.shiro.web.mgt.WebSecurityManager)1 AbstractShiroFilter (org.apache.shiro.web.servlet.AbstractShiroFilter)1