Search in sources :

Example 1 with LogoutFilter

use of org.apache.shiro.web.filter.authc.LogoutFilter in project nutzboot by nutzam.

the class NbResourceBasedWebEnvironment method configure.

protected void configure() {
    this.objects.clear();
    WebSecurityManager securityManager = createWebSecurityManager();
    setWebSecurityManager(securityManager);
    String loginUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGIN, "/user/login");
    String unauthorizedUrl = conf.get(ShiroEnvStarter.PROP_URL_UNAUTH, "/user/login");
    String logoutUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGOUT_REDIRECT, "/");
    for (Map.Entry<String, Filter> en : DefaultFilter.createInstanceMap(null).entrySet()) {
        Filter filter = en.getValue();
        if (filter instanceof LogoutFilter) {
            ((LogoutFilter) filter).setRedirectUrl(logoutUrl);
        } else if (filter instanceof AuthenticatingFilter) {
            ((AuthenticatingFilter) filter).setLoginUrl(loginUrl);
        } else if (filter instanceof AccessControlFilter) {
            ((AccessControlFilter) filter).setLoginUrl(unauthorizedUrl);
        }
        objects.put(en.getKey(), en.getValue());
    }
    for (String objectName : Strings.splitIgnoreBlank(conf.get("shiro.objects", ""))) {
        objects.put(objectName, ioc.get(null, objectName));
    }
    FilterChainResolver resolver = createFilterChainResolver();
    if (resolver != null) {
        setFilterChainResolver(resolver);
    }
    NutShiro.DefaultLoginURL = loginUrl;
    NutShiro.DefaultNoAuthURL = unauthorizedUrl;
}
Also used : WebSecurityManager(org.apache.shiro.web.mgt.WebSecurityManager) AuthenticatingFilter(org.apache.shiro.web.filter.authc.AuthenticatingFilter) AccessControlFilter(org.apache.shiro.web.filter.AccessControlFilter) AccessControlFilter(org.apache.shiro.web.filter.AccessControlFilter) DefaultFilter(org.apache.shiro.web.filter.mgt.DefaultFilter) Filter(javax.servlet.Filter) LogoutFilter(org.apache.shiro.web.filter.authc.LogoutFilter) AuthenticatingFilter(org.apache.shiro.web.filter.authc.AuthenticatingFilter) FilterChainResolver(org.apache.shiro.web.filter.mgt.FilterChainResolver) LogoutFilter(org.apache.shiro.web.filter.authc.LogoutFilter) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 Filter (javax.servlet.Filter)1 AccessControlFilter (org.apache.shiro.web.filter.AccessControlFilter)1 AuthenticatingFilter (org.apache.shiro.web.filter.authc.AuthenticatingFilter)1 LogoutFilter (org.apache.shiro.web.filter.authc.LogoutFilter)1 DefaultFilter (org.apache.shiro.web.filter.mgt.DefaultFilter)1 FilterChainResolver (org.apache.shiro.web.filter.mgt.FilterChainResolver)1 WebSecurityManager (org.apache.shiro.web.mgt.WebSecurityManager)1