当前位置: 首页>>代码示例>>Java>>正文


Java AbstractShiroFilter类代码示例

本文整理汇总了Java中org.apache.shiro.web.servlet.AbstractShiroFilter的典型用法代码示例。如果您正苦于以下问题:Java AbstractShiroFilter类的具体用法?Java AbstractShiroFilter怎么用?Java AbstractShiroFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractShiroFilter类属于org.apache.shiro.web.servlet包,在下文中一共展示了AbstractShiroFilter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInstance

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
@Override
protected AbstractShiroFilter createInstance() throws Exception {
	SecurityManager securityManager = getSecurityManager();
	if (securityManager == null){
		throw new BeanInitializationException("SecurityManager property must be set.");
	}

	if (!(securityManager instanceof WebSecurityManager)){
		throw new BeanInitializationException("The security manager does not implement the WebSecurityManager interface.");
	}

	PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
	FilterChainManager chainManager = createFilterChainManager();
	chainResolver.setFilterChainManager(chainManager);
	return new MySpringShiroFilter((WebSecurityManager)securityManager, chainResolver);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:MyShiroFilterFactoryBean.java

示例2: setUp

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
@Before
public void setUp() throws ServletException {
    TokenFilter tokenFilter = (TokenFilter) wac.getBean("tokenFilter");
    mockMvc = MockMvcBuilders.webAppContextSetup(wac).alwaysDo(print()) // 默认每次执行请求后都做的动作
            // 这里不加shiro过滤器的话testAuth最后获取用户信息不会被过滤,尽管配置文件中有配置
            // 但是如果是添加
            // AbstractShiroFilter shiroFilter = (AbstractShiroFilter)
            // wac.getBean("shiroFilter");这个过滤器的话
            // 控制器里的@RequiresPermissions注解要去掉,否则抛异常.貌似ShiroTestUtils没起作用,运行过程中的DelegatingSubject和模拟的不是一个
            // http://stackoverflow.com/questions/22152530/spring-end-to-end-test-including-filters-and-controller-method-using-mockhttpser
            .addFilter(tokenFilter, "/users/1").build();
    User user = new User();
    user.setUsername("root");
    user.setLocked(false);
    ShiroTestUtils.mockCurrentUser(user, true);

    // 没有没有下面这几句,tokenfilter也不会工作
    AbstractShiroFilter shiroFilter = (AbstractShiroFilter) wac.getBean("shiroFilter");
    FilterConfig mockFilterConfig = mock(FilterConfig.class);
    shiroFilter.init(mockFilterConfig);
}
 
开发者ID:howiefh,项目名称:jee-restful-web,代码行数:22,代码来源:OAuthTest.java

示例3: createFilter

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:silb,项目名称:dropwizard-shiro,代码行数:23,代码来源:ShiroBundle.java

示例4: testFilter

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的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);
}
 
开发者ID:howiefh,项目名称:jee-restful-web,代码行数:14,代码来源:OAuthTest.java

示例5: disableRegistrationShiroFilter

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
/**
 * 取消 Shiro Filter 的/*自动注册行为
 * @param filter
 * @return
 */
@Bean
public FilterRegistrationBean disableRegistrationShiroFilter(AbstractShiroFilter filter) {
	FilterRegistrationBean registration = new FilterRegistrationBean(filter);
	registration.setEnabled(false);
	return registration;
}
 
开发者ID:ushelp,项目名称:EasyEE,代码行数:12,代码来源:ShiroConfiguration.java

示例6: createDelegateFilter

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
protected Filter createDelegateFilter() {
	return (Filter) applicationContext.getBean(AbstractShiroFilter.class);
}
 
开发者ID:penggle,项目名称:xproject,代码行数:4,代码来源:DynamicUrlPermissionsShiroFilter.java

示例7: setUp

import org.apache.shiro.web.servlet.AbstractShiroFilter; //导入依赖的package包/类
@Before
public void setUp() throws ServletException {
    AbstractShiroFilter shiroFilter = (AbstractShiroFilter) wac.getBean("shiroFilter");
    mockMvc = MockMvcBuilders.webAppContextSetup(wac).alwaysDo(print()) // 默认每次执行请求后都做的动作
            .addFilter(shiroFilter, "/*").build();
}
 
开发者ID:howiefh,项目名称:jee-restful-web,代码行数:7,代码来源:SignupControllerTest.java


注:本文中的org.apache.shiro.web.servlet.AbstractShiroFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。