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


Java FilterChainResolver类代码示例

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


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

示例1: createChainResolver

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的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;
}
 
开发者ID:bootique,项目名称:bootique-shiro,代码行数:18,代码来源:MappedShiroFilterFactory.java

示例2: getExecutionChain

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
/**
 * Returns the {@code FilterChain} to execute for the given request.
 * <p/>
 * The {@code origChain} argument is the
 * original {@code FilterChain} supplied by the Servlet Container, but it may be modified to provide
 * more behavior by pre-pending further chains according to the Shiro configuration.
 * <p/>
 * This implementation returns the chain that will actually be executed by acquiring the chain from a
 * {@link #getFilterChainResolver() filterChainResolver}.  The resolver determines exactly which chain to
 * execute, typically based on URL configuration.  If no chain is returned from the resolver call
 * (returns {@code null}), then the {@code origChain} will be returned by default.
 *
 * @param request   the incoming ServletRequest
 * @param response  the outgoing ServletResponse
 * @param origChain the original {@code FilterChain} provided by the Servlet Container
 * @return the {@link FilterChain} to execute for the given request
 * @since 1.0
 */
protected FilterChain getExecutionChain(ServletRequest request, ServletResponse response, FilterChain origChain) {
    FilterChain chain = origChain;

    FilterChainResolver resolver = getFilterChainResolver();
    if (resolver == null) {
        log.debug("No FilterChainResolver configured.  Returning original FilterChain.");
        return origChain;
    }

    FilterChain resolved = resolver.getChain(request, response, origChain);
    if (resolved != null) {
        log.trace("Resolved a configured FilterChain for the current request.");
        chain = resolved;
    } else {
        log.trace("No FilterChain configured for the current request.  Using the default.");
    }

    return chain;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:38,代码来源:AbstractShiroFilter.java

示例3: applyFilterChainResolver

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
protected void applyFilterChainResolver(Ini ini, Map<String, ?> defaults) {
    if (ini == null || ini.isEmpty()) {
        //nothing to use to create the resolver, just return
        //(the AbstractShiroFilter allows a null resolver, in which case the original FilterChain is
        // always used).
        return;
    }

    //only create a resolver if the 'filters' or 'urls' sections are defined:
    Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
    Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS);
    if ((urls != null && !urls.isEmpty()) || (filters != null && !filters.isEmpty())) {
        //either the urls section or the filters section was defined.  Go ahead and create the resolver
        //and set it:
        IniFilterChainResolverFactory filterChainResolverFactory = new IniFilterChainResolverFactory(ini, defaults);
        filterChainResolverFactory.setFilterConfig(getFilterConfig());
        FilterChainResolver resolver = filterChainResolverFactory.getInstance();
        setFilterChainResolver(resolver);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:IniShiroFilter.java

示例4: createFilterChainResolver

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
protected FilterChainResolver createFilterChainResolver() {

        FilterChainResolver resolver = null;

        Ini ini = getIni();

        if (!CollectionUtils.isEmpty(ini)) {
            //only create a resolver if the 'filters' or 'urls' sections are defined:
            Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
            Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS);
            if (!CollectionUtils.isEmpty(urls) || !CollectionUtils.isEmpty(filters)) {
                //either the urls section or the filters section was defined.  Go ahead and create the resolver:
                IniFilterChainResolverFactory factory = new IniFilterChainResolverFactory(ini, this.objects);
                resolver = factory.getInstance();
            }
        }

        return resolver;
    }
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:IniWebEnvironment.java

示例5: configureShiroWeb

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
@Override
protected void configureShiroWeb() {
  bindRealm().to(EmptyRealm.class); // not used in practice, just here to keep Shiro module happy

  bindSingleton(SessionFactory.class, NexusSessionFactory.class);
  bindSingleton(SessionStorageEvaluator.class, NexusSessionStorageEvaluator.class);
  bindSingleton(SubjectDAO.class, NexusSubjectDAO.class);

  // configure our preferred security components
  bindSingleton(SessionDAO.class, NexusSessionDAO.class);
  bindSingleton(Authenticator.class, FirstSuccessfulModularRealmAuthenticator.class);
  bindSingleton(Authorizer.class, ExceptionCatchingModularRealmAuthorizer.class);
  bindSingleton(FilterChainManager.class, DynamicFilterChainManager.class);

  // path matching resolver has several constructors so we need to point Guice to the appropriate one
  bind(FilterChainResolver.class).toConstructor(ctor(PathMatchingFilterChainResolver.class)).asEagerSingleton();

  // bindings used by external modules
  expose(FilterChainResolver.class);
  expose(FilterChainManager.class);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:WebSecurityModule.java

示例6: init

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
@Override
public void init() throws Exception {

    setSecurityManager(env.getWebSecurityManager());

    FilterChainResolver resolver = env.getFilterChainResolver();
    if (resolver != null) {
        setFilterChainResolver(resolver);
    }

    errorHandler.setExceptionHandler(AuthenticationException.class, (exception, ctx) -> {
        ctx.setLocal("message", exception.getMessage());
        errorHandler.handle(401, ctx);
    });

    errorHandler.setExceptionHandler(AuthorizationException.class, (exception, ctx) -> {
        ctx.setLocal("message", exception.getMessage());
        errorHandler.handle(403, ctx);
    });
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:21,代码来源:ShiroFilter.java

示例7: getFilterChainResolver

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的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;
}
 
开发者ID:arthurgregorio,项目名称:exemplos,代码行数:27,代码来源:ShiroConfiguration.java

示例8: configureShiroWeb

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
@Override
  protected void configureShiroWeb() {
      logger.entry();
      //if you would like to expose the CredentialsMatcher listed here, uncomment the following line.
      //expose(CredentialsMatcher.class);
      expose(WebSecurityManager.class);
      expose(FilterChainResolver.class);

      //avoid 4 times instantiation
      //bindRealm().to(IniRealm.class);

/*addFilterChain("/logout", LOGOUT);
addFilterChain("/rest/**",NO_SESSION_CREATION, AUTHC_BASIC);
addFilterChain("/**", AUTHC_BASIC);*/
      logger.exit();
  }
 
开发者ID:pabiagioli,项目名称:webshooters,代码行数:17,代码来源:BaseShiroModule.java

示例9: configureShiroWeb

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void configureShiroWeb() {
	logger.entry();
	//if you would like to expose the CredentialsMatcher listed here, uncomment the following line.
	//expose(CredentialsMatcher.class);
	expose(WebSecurityManager.class);
	expose(FilterChainResolver.class);
       
	//avoid 4 times instantiation
	bindRealm().to(IniRealm.class);
	
	addFilterChain("/logout", LOGOUT);
	//addFilterChain("/rest/public/**",ANON);
	addFilterChain("/rest/**",NO_SESSION_CREATION, AUTHC_BASIC);
	addFilterChain("/**", AUTHC_BASIC);
       logger.exit();
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:19,代码来源:BootstrapShiroModule.java

示例10: createShiroFilter

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
public MappedFilter<ShiroFilter> createShiroFilter(
        Injector injector,
        WebSecurityManager securityManager,
        Map<String, Filter> chainFilters) {

    FilterChainResolver chainResolver = createChainResolver(chainFilters);
    ShiroFilter shiroFilter = createShiroFilter(securityManager, chainResolver);
    return createMappedShiroFilter(shiroFilter);
}
 
开发者ID:bootique,项目名称:bootique-shiro,代码行数:10,代码来源:MappedShiroFilterFactory.java

示例11: getFilterChainResolver

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的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;
}
 
开发者ID:nebrass,项目名称:pairing-shiro-javaee7,代码行数:29,代码来源:ShiroConfiguration.java

示例12: SpringShiroFilter

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
protected SpringShiroFilter(WebSecurityManager webSecurityManager, FilterChainResolver resolver) {
    super();
    if (webSecurityManager == null) {
        throw new IllegalArgumentException("WebSecurityManager property cannot be null.");
    }
    setSecurityManager(webSecurityManager);
    if (resolver != null) {
        setFilterChainResolver(resolver);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:11,代码来源:ShiroFilterFactoryBean.java

示例13: init

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
/**
 * Configures this instance based on the existing {@link org.apache.shiro.web.env.WebEnvironment} instance
 * available to the currently accessible {@link #getServletContext() servletContext}.
 *
 * @see org.apache.shiro.web.env.EnvironmentLoaderListener
 * @since 1.2
 */
@Override
public void init() throws Exception {
    WebEnvironment env = WebUtils.getRequiredWebEnvironment(getServletContext());

    setSecurityManager(env.getWebSecurityManager());

    FilterChainResolver resolver = env.getFilterChainResolver();
    if (resolver != null) {
        setFilterChainResolver(resolver);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:19,代码来源:ShiroFilter.java

示例14: configure

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
protected void configure() {

        this.objects.clear();

        WebSecurityManager securityManager = createWebSecurityManager();
        setWebSecurityManager(securityManager);

        FilterChainResolver resolver = createFilterChainResolver();
        if (resolver != null) {
            setFilterChainResolver(resolver);
        }
    }
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:13,代码来源:IniWebEnvironment.java

示例15: createInstance

import org.apache.shiro.web.filter.mgt.FilterChainResolver; //导入依赖的package包/类
protected FilterChainResolver createInstance(Ini ini) {
    FilterChainResolver filterChainResolver = createDefaultInstance();
    if (filterChainResolver instanceof PathMatchingFilterChainResolver) {
        PathMatchingFilterChainResolver resolver = (PathMatchingFilterChainResolver) filterChainResolver;
        FilterChainManager manager = resolver.getFilterChainManager();
        buildChains(manager, ini);
    }
    return filterChainResolver;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:10,代码来源:IniFilterChainResolverFactory.java


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