Search in sources :

Example 1 with RestfulFilter

use of com.moon.admin.common.filter.RestfulFilter in project moon by gentoo111.

the class ShiroConfig method shirFilter.

@Bean
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    // 拦截器.
    Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
    filterChainDefinitionMap.put("/css/**", "anon");
    filterChainDefinitionMap.put("/fonts/**", "anon");
    filterChainDefinitionMap.put("/img/**", "anon");
    filterChainDefinitionMap.put("/js/**", "anon");
    filterChainDefinitionMap.put("/sys/login/**", "anon");
    filterChainDefinitionMap.put("/files/*", "anon");
    filterChainDefinitionMap.put("/logout", "logout");
    filterChainDefinitionMap.put("/**", "authc");
    shiroFilterFactoryBean.setLoginUrl("/login.html");
    shiroFilterFactoryBean.setSuccessUrl("/index.html");
    LogoutFilter logoutFilter = new LogoutFilter();
    logoutFilter.setRedirectUrl("/login.html");
    RestfulFilter restfulFilter = new RestfulFilter();
    shiroFilterFactoryBean.getFilters().put("authc", restfulFilter);
    shiroFilterFactoryBean.getFilters().put("logout", logoutFilter);
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
    return shiroFilterFactoryBean;
}
Also used : ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) LogoutFilter(com.moon.admin.common.filter.LogoutFilter) LinkedHashMap(java.util.LinkedHashMap) RestfulFilter(com.moon.admin.common.filter.RestfulFilter) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

LogoutFilter (com.moon.admin.common.filter.LogoutFilter)1 RestfulFilter (com.moon.admin.common.filter.RestfulFilter)1 LinkedHashMap (java.util.LinkedHashMap)1 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1