Example usage for org.apache.shiro.web.filter.mgt FilterChainManager addFilter

List of usage examples for org.apache.shiro.web.filter.mgt FilterChainManager addFilter

Introduction

In this page you can find the example usage for org.apache.shiro.web.filter.mgt FilterChainManager addFilter.

Prototype

void addFilter(String name, Filter filter);

Source Link

Document

Adds a filter to the 'pool' of available filters that can be used when #addToChain(String,String,String) creating filter chains .

Usage

From source file:com.freedomotic.plugins.devices.restapiv3.auth.FDWebEnvironment.java

License:Open Source License

public FDWebEnvironment() {
    BasicHttpAuthenticationFilter authc = new CorsBasicHttpAuthenticationFilter();
    LogoutFilter logout = new LogoutFilter();
    logout.setRedirectUrl("http://www.freedomotic.com/");

    FilterChainManager fcMan = new DefaultFilterChainManager();
    fcMan.addFilter("authc", authc);
    fcMan.addFilter("logout", logout);
    fcMan.createChain("/auth/logout", "logout");
    fcMan.createChain("/v3/**", "authc");

    PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
    resolver.setFilterChainManager(fcMan);

    setFilterChainResolver(resolver);/*from   w  ww  . j a v a 2 s .co  m*/
    setWebSecurityManager(RestAPIv3.defaultWebSecurityManager);
}

From source file:myStuff.rest.shiro.ShiroHelper.java

License:Apache License

public static FilterChainResolver getFilterChainResolver() {
    if (filterChainResolver == null) {
        BasicHttpAuthenticationFilter authcBasic = new MyFilter();
        authcBasic.setEnabled(true);// www.java  2s.c o m

        FilterChainManager fcMan = new DefaultFilterChainManager();
        fcMan.addFilter("authcBasic[permissive]", authcBasic);
        fcMan.createChain("/**", "authcBasic[permissive]");

        PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
        resolver.setFilterChainManager(fcMan);
        filterChainResolver = resolver;
    }
    return filterChainResolver;
}