本文整理汇总了Java中org.apache.shiro.web.filter.mgt.DefaultFilterChainManager类的典型用法代码示例。如果您正苦于以下问题:Java DefaultFilterChainManager类的具体用法?Java DefaultFilterChainManager怎么用?Java DefaultFilterChainManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultFilterChainManager类属于org.apache.shiro.web.filter.mgt包,在下文中一共展示了DefaultFilterChainManager类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChainResolver
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
protected FilterChainResolver createChainResolver(Map<String, Filter> chainFilters) {
DefaultFilterChainManager chainManager = new DefaultFilterChainManager();
// load filters
chainFilters.forEach((name, filter) -> chainManager.addFilter(name, filter));
if (urls != null) {
urls.forEach((url, value) -> {
LOGGER.info("Loading url chain {} -> {}", url, value);
chainManager.createChain(url, value);
});
}
PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
resolver.setFilterChainManager(chainManager);
return resolver;
}
示例2: getFilterChainResolver
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
/**
* @return the default filter chain resolver for this application
*/
@Produces
public FilterChainResolver getFilterChainResolver() {
if (this.filterChainResolver == null) {
final FilterChainManager chainManager = new DefaultFilterChainManager();
chainManager.addFilter("anon", new AnonymousFilter());
chainManager.addFilter("authc", this.configureFormAuthentication());
chainManager.addFilter("perms", new PermissionsAuthorizationFilter());
final PathMatchingFilterChainResolver resolver
= new PathMatchingFilterChainResolver();
chainManager.createChain("/secured/**", "authc");
chainManager.createChain("/index.xhtml", "anon");
resolver.setFilterChainManager(chainManager);
this.filterChainResolver = resolver;
}
return this.filterChainResolver;
}
示例3: createFilterChainManager
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
protected FilterChainManager createFilterChainManager() {
final DefaultFilterChainManager manager = new DefaultFilterChainManager();
Map<String, Filter> defaultFilters = manager.getFilters();
//apply global settings if necessary:
for (Filter filter : defaultFilters.values()) {
applyGlobalPropertiesIfNecessary(filter);
}
if (shiroConfig != null && !shiroConfig.isEmpty()) {
for (Object urlKey : shiroConfig.keySet()) {
String url = String.valueOf(urlKey);
if (org.apache.commons.lang3.StringUtils.equals("login.url", url)
|| org.apache.commons.lang3.StringUtils.equals("success.url", url)
|| org.apache.commons.lang3.StringUtils.equals("unauthorized.url", url)
|| org.apache.commons.lang3.StringUtils.equals("session.expired", url)
) {
continue;
}
// { "authc", "roles[admin,user]", "perms[file:edit]" }
manager.createChain(url, MoreObjects.firstNonNull(shiroConfig.getProperty(url), "anon"));
}
}
return manager;
}
示例4: FDWebEnvironment
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
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);
setWebSecurityManager(RestAPIv3.defaultWebSecurityManager);
}
示例5: getFilterChainResolver
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
@Produces
public FilterChainResolver getFilterChainResolver() {
FilterChainResolver filterChainResolver = null;
if (filterChainResolver == null) {
FormAuthenticationFilter authc = new FormAuthenticationFilter();
AnonymousFilter anon = new AnonymousFilter();
UserFilter user = new UserFilter();
authc.setLoginUrl(WebPages.LOGIN_URL);
user.setLoginUrl(WebPages.LOGIN_URL);
FilterChainManager fcMan = new DefaultFilterChainManager();
fcMan.addFilter("authc", authc);
fcMan.addFilter("anon", anon);
fcMan.addFilter("user", user);
fcMan.createChain("/index.html", "anon");
fcMan.createChain("/css/**", "anon");
fcMan.createChain("/api/**", "anon");
fcMan.createChain(WebPages.LOGIN_URL, "authc");
fcMan.createChain("/**", "user");
PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
resolver.setFilterChainManager(fcMan);
filterChainResolver = resolver;
}
return filterChainResolver;
}
示例6: testFilter
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
@Test
public void testFilter() {
AbstractShiroFilter shiroFilter = (AbstractShiroFilter) wac.getBean("shiroFilter");
PathMatchingFilterChainResolver resolver = (PathMatchingFilterChainResolver) shiroFilter
.getFilterChainResolver();
DefaultFilterChainManager fcManager = (DefaultFilterChainManager) resolver.getFilterChainManager();
NamedFilterList chain = fcManager.getChain("/users/**");
assertNotNull(chain);
assertEquals(chain.size(), 2);
Filter[] filters = new Filter[chain.size()];
filters = chain.toArray(filters);
assertTrue(filters[1] instanceof TokenFilter);
}
示例7: getFilterChainResolver
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; //导入依赖的package包/类
/**
* @return the default filter chain resolver for this application
*/
@Produces
public FilterChainResolver getFilterChainResolver() {
if (this.filterChainResolver == null) {
final FilterChainManager chainManager = new DefaultFilterChainManager();
chainManager.addFilter("anon", new AnonymousFilter());
chainManager.addFilter("authc", this.configureFormAuthentication());
chainManager.addFilter("perms", new PermissionsAuthorizationFilter());
final PathMatchingFilterChainResolver resolver
= new PathMatchingFilterChainResolver();
chainManager.createChain("/index.xhtml", "anon");
chainManager.createChain("/secured/car/**", "perms[car:access]");
chainManager.createChain("/secured/owner/**", "perms[owner:access]");
chainManager.createChain("/secured/**", "authc");
chainManager.createChain("/api/**", "authcBasic");
resolver.setFilterChainManager(chainManager);
this.filterChainResolver = resolver;
}
return this.filterChainResolver;
}