Java 类org.springframework.web.filter.DelegatingFilterProxy 实例源码

项目:yadaframework    文件:SecurityWebApplicationInitializer.java   
@Override
// Questo serve (anche) per consentire il file upload verso url protette:
//   The first option is to ensure that the MultipartFilter is specified before the Spring Security filter. 
//   Specifying the MultipartFilter before the Spring Security filter means that there is no authorization 
//   for invoking the MultipartFilter which means anyone can place temporary files on your server. 
//   However, only authorized users will be able to submit a File that is processed by your application. 
//   In general, this is the recommended approach because the temporary file upload should have a 
//   negligble impact on most servers.
   protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
    // Per aggiungere altri filtri basta metterli in fila, in ordine di esecuzione
       // insertFilters(servletContext, new YadaMultipartExceptionHandler(), new MultipartFilter());
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);
    // L'AuditFilter lo metto prima di tutto almeno viene eseguito prima dell'autorizzazione e riesco a capire il motivo di eventuali 403
    // For some reason the characterEncodingFilter can not be after the MultipartFilter otherwise encoding in forms doesn't work (for non-multipart forms).
       insertFilters(servletContext, new CheckSessionFilter(), characterEncodingFilter, new AuditFilter(), new MultipartFilter(), new DelegatingFilterProxy("yadaLocalePathVariableFilter"));
   }
项目:dss-demonstrations    文件:AppInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));

    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/*");

    CXFServlet cxf = new CXFServlet();
    BusFactory.setDefaultBus(cxf.getBus());
    ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
    cxfServlet.setLoadOnStartup(1);
    cxfServlet.addMapping("/services/*");

    servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
            "/*");

    servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
项目:autopivot    文件:AutoPivotWebAppInitializer.java   
/**
 * Configure the given {@link ServletContext} with any servlets, filters, listeners
 * context-params and attributes necessary for initializing this web application. See examples
 * {@linkplain WebApplicationInitializer above}.
 *
 * @param servletContext the {@code ServletContext} to initialize
 * @throws ServletException if any call against the given {@code ServletContext} throws a {@code ServletException}
 */
public void onStartup(ServletContext servletContext) throws ServletException {
    // Spring Context Bootstrapping
    AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
    rootAppContext.register(AutoPivotConfig.class);
    servletContext.addListener(new ContextLoaderListener(rootAppContext));

    // Set the session cookie name. Must be done when there are several servers (AP,
    // Content server, ActiveMonitor) with the same URL but running on different ports.
    // Cookies ignore the port (See RFC 6265).
    CookieUtil.configure(servletContext.getSessionCookieConfig(), CookieUtil.COOKIE_NAME);

    // The main servlet/the central dispatcher
    final DispatcherServlet servlet = new DispatcherServlet(rootAppContext);
    servlet.setDispatchOptionsRequest(true);
    Dynamic dispatcher = servletContext.addServlet("springDispatcherServlet", servlet);
    dispatcher.addMapping("/*");
    dispatcher.setLoadOnStartup(1);

    // Spring Security Filter
    final FilterRegistration.Dynamic springSecurity = servletContext.addFilter(SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy());
    springSecurity.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

}
项目:hojeehdiaderua    文件:DiaDeRuaWebInitializer.java   
@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(AppConfig.class);

    sc.addListener(new ContextLoaderListener(context));
    sc.setInitParameter("defaultHtmlEscape", "true");

    ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcherServlet", new DispatcherServlet(context));

    dispatcher.setLoadOnStartup(1);
    dispatcher.setAsyncSupported(true);
    dispatcher.addMapping("/");

    FilterRegistration.Dynamic securityFilter = sc.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    securityFilter.addMappingForUrlPatterns(null, false, "/*");
    securityFilter.setAsyncSupported(true);
}
项目:java-platform    文件:CentralizeInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    Map<String, String> filterChainDefinitionMap = Application.getSecurityFilterChainDefinitionMap();
    filterChainDefinitionMap.put("/admin", DefaultFilter.authc.name());
    filterChainDefinitionMap.put("/admin/logout", DefaultFilter.logout.name());
    filterChainDefinitionMap.put("/admin/**", DefaultFilter.authc.name());

    List<Filter> filters = Application.getFilters();

    DelegatingFilterProxy shiroFilter = new DelegatingFilterProxy("shiroFilter");
    shiroFilter.setTargetFilterLifecycle(true);
    filters.add(shiroFilter);

    filters.add(new RequestContextFilter());
    filters.add(new CharacterEncodingFilter("UTF-8", true));
}
项目:cuba    文件:SingleAppWebContextLoader.java   
protected void registerRestApiServlet(ServletContext servletContext) {
    CubaRestApiServlet cubaRestApiServlet = new SingleAppRestApiServlet(dependencyJars);
    try {
        cubaRestApiServlet.init(new CubaServletConfig("rest_api", servletContext));
    } catch (ServletException e) {
        throw new RuntimeException("An error occurred while initializing dispatcher servlet", e);
    }
    ServletRegistration.Dynamic cubaRestApiServletReg = servletContext.addServlet("rest_api", cubaRestApiServlet);
    cubaRestApiServletReg.setLoadOnStartup(2);
    cubaRestApiServletReg.addMapping("/rest/*");

    DelegatingFilterProxy restSpringSecurityFilterChain = new DelegatingFilterProxy();
    restSpringSecurityFilterChain.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.rest_api");
    restSpringSecurityFilterChain.setTargetBeanName("springSecurityFilterChain");

    FilterRegistration.Dynamic restSpringSecurityFilterChainReg =
            servletContext.addFilter("restSpringSecurityFilterChain", restSpringSecurityFilterChain);
    restSpringSecurityFilterChainReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/rest/*");
}
项目:VaadinSpringShiroMongoDB    文件:CustomWebApplicationInitializer.java   
@Override
public void onStartup(ServletContext container) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext =
            new AnnotationConfigWebApplicationContext();
    rootContext.register(AppConfig.class);

    container.addListener(new ContextLoaderListener(rootContext));

    //container.addListener(EnvironmentLoaderListener.class);
    //container.setInitParameter("shiroEnvironmentClass","org.apache.shiro.web.env.DefaultWebEnvironment");


    container.addListener(SessionSupport.class);
    container.setInitParameter("org.atmosphere.cpr.sessionSupport","true");

    EnumSet<DispatcherType> d = EnumSet.of(DispatcherType.REQUEST
            ,DispatcherType.ASYNC
            ,DispatcherType.ERROR,DispatcherType.FORWARD,DispatcherType.INCLUDE);

    FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilter", DelegatingFilterProxy.class);
        shiroFilter.setInitParameter("targetFilterLifecycle","true");
        shiroFilter.addMappingForUrlPatterns(d, false, "/*");
        shiroFilter.setAsyncSupported(true);
}
项目:security-stateless-samples    文件:BootStrap.java   
protected void addFilter(final ServletContext ctx) {

        AccessFilter af= (AccessFilter) rootContext.getBean("accessFilter");
        CharacterEncodingFilter cef = (CharacterEncodingFilter) rootContext.getBean("characterEncodingFilter");

        DelegatingFilterProxy dfp = new DelegatingFilterProxy("springSecurityFilterChain");

        EnumSet<DispatcherType> dts=EnumSet.allOf(DispatcherType.class);

        // Access log filter
        ctx.addFilter("accessFilter",af).addMappingForUrlPatterns(dts,true,"/*");
        // Error wrapper filter
        // Character encoding filter
        ctx.addFilter("characterEncodingFilter", cef).addMappingForUrlPatterns(dts, true, "/*");
        // Spring security filter
        ctx.addFilter("spring-security", dfp).addMappingForUrlPatterns(dts, true, "/*");

    }
项目:bacoma    文件:WebInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    logger.info("*** entered #onStartup");
    WebApplicationContext context = getContext();

    // Manage the lifecycle of the application context and stop jetty, if the initialization of the context fails
    servletContext.addListener(new ContextListener(context));

    // add spring-security
    DelegatingFilterProxy securityFilter = new DelegatingFilterProxy("springSecurityFilterChain");
    securityFilter.setServletContext(servletContext);
    servletContext.addFilter("springSecurityFilterChain", securityFilter).addMappingForUrlPatterns(null, true, "/*");

    ServletRegistration.Dynamic fmConnector = servletContext.addServlet("fmConnectorServlet", new ConnectorServlet());
    fmConnector.setLoadOnStartup(10);
    fmConnector.addMapping("/filemanager/connectors/java/*");

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher-servlet", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(20);
    dispatcher.addMapping("/*");
}
项目:starter-kit-spring-maven    文件:ServletInitializer.java   
@Override
public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext context = new XmlWebApplicationContext();

    context.setConfigLocations(CONTEXT_CONFIG_LOCATIONS);

    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setPublishContext(true);

    FilterRegistration.Dynamic sessionFilter = container.addFilter("sessionFilter", new DelegatingFilterProxy("sessionFilter"));

    sessionFilter.addMappingForUrlPatterns(null, false, "*.jsp");

    this.servlets.stream().forEach( servlet -> {
        addServlet(container, sessionFilter, servlet);
    });
}
项目:wicket-spring-security-example    文件:AppInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    //Create webapp context
    AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); //part of spring-web
    root.register(SpringSecurityConfiguration.class); //register class by annotation. Here be all security rules.

    //Register DelegatingFilterProxy
    FilterRegistration.Dynamic springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    springSecurityFilterChainReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.ERROR, DispatcherType.REQUEST), false, "/*");

    servletContext.addListener(new ContextLoaderListener(root));

    //Register WicketFilter
    WicketFilter wicketFilter = new WicketFilter(new WicketApplication()) {
        @Override
        public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException {
            setFilterPath(""); //don't use web.xml. WicketApplication.init is a custom override for it.
            super.init(isServlet, filterConfig);
        }
    };
    FilterRegistration.Dynamic wicketFilterReg = servletContext.addFilter("wicketFilter", wicketFilter);
    wicketFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "*");
}
项目:ctm    文件:WebInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter()).addMappingForUrlPatterns(null, false, "/*");

    DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy();
    delegatingFilterProxy.setTargetFilterLifecycle(true);
    servletContext.addFilter("shiroFilter", delegatingFilterProxy).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addServlet("kaptcha", new KaptchaServlet()).addMapping("/kaptcha");

    super.onStartup(servletContext);
}
项目:jlubricant    文件:SpringSecurityFeature.java   
public void contextInitialized(ServletContextEvent sce) {
    ServletContext servletContext = sce.getServletContext();

    Object attribute = servletContext.getAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE );
    if(attribute == null){
        Enumeration<String> attributeNames = servletContext.getAttributeNames();
        throw new IllegalStateException( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + " not ready. Available attributes: " + EnumerationUtils.toList(attributeNames) );
    }

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST);
    boolean isMatchAfter = true;
    String urlPatterns = "/*";
    servletContext
        .addFilter("springSecurityFilterChain", DelegatingFilterProxy.class.getCanonicalName())
        .addMappingForUrlPatterns(dispatcherTypes, isMatchAfter, urlPatterns);
    ;
}
项目:sshw    文件:RootApplicationConfig.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(RootApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.setAsyncSupported(true);
    dispatcher.addMapping("/");

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    servletContext.addListener(new ContextLoaderListener(rootContext));
}
项目:springboot-shiro-cas-mybatis    文件:ShiroCasConfiguration.java   
/**
 * 注册DelegatingFilterProxy(Shiro)
 *
 * @return
 * @author SHANHY
 * @create  2016年1月13日
 */
@Bean
public FilterRegistrationBean delegatingFilterProxy() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //  该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*");
    return filterRegistration;
}
项目:springboot-shiro-cas-mybatis    文件:ShiroConfig.java   
/**
 * 注册shiroFilter
 */
@Bean
public FilterRegistrationBean filterRegistrationBean(){
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    // 该值缺省为false,表示生命周期有SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*"); 
    return filterRegistration;
}
项目:springboot-shiro-cas-mybatis    文件:ShiroCasConfig.java   
/**
 * 注册shiroFilter
 */
@Bean
public FilterRegistrationBean filterRegistrationBean(){
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    // 该值缺省为false,表示生命周期有SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*"); 
    return filterRegistration;
}
项目:devops-cstack    文件:ApplicationConfig.java   
@Override
public void onStartup(ServletContext servletContext)
    throws ServletException {

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(CloudUnitApplicationContext.class);

    ServletRegistration.Dynamic dispatcher =
        servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
    dispatcher.setAsyncSupported(true);

    FilterRegistration.Dynamic security =
        servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    EnumSet<DispatcherType> securityDispatcherTypes =
        EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);

    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/user/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/file/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/logs/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/messages/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/application/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/server/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/snapshot/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/module/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/admin/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/image/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/scripting/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/gitlab/*");

    security.setAsyncSupported(true);

    servletContext.addListener(new ContextLoaderListener(rootContext));

}
项目:renren-fast    文件:FilterConfig.java   
@Bean
public FilterRegistrationBean shiroFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    registration.addInitParameter("targetFilterLifecycle", "true");
    registration.setEnabled(true);
    registration.setOrder(Integer.MAX_VALUE - 1);
    registration.addUrlPatterns("/*");
    return registration;
}
项目:gamesboard    文件:ExampleApplicationConfig.java   
@Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        //If you want to use the XML configuration, comment the following two lines out.
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);
//        rootContext.scan("com.pigdroid.social.config");

        //If you want to use the XML configuration, uncomment the following lines.
        //XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
        //rootContext.setConfigLocation("classpath:exampleApplicationContext.xml");

        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);

        EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);

        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);

        FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
        characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

        FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
        security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

        FilterRegistration.Dynamic sitemesh = servletContext.addFilter("sitemesh", new ConfigurableSiteMeshFilter());
        sitemesh.addMappingForUrlPatterns(dispatcherTypes, true, "*.jsp");

        servletContext.addListener(new ContextLoaderListener(rootContext));
    }
项目:istio-by-example-java    文件:ApplicationConfig.java   
@Bean
@Order(value = 0)
FilterRegistrationBean sessionRepositoryFilterRegistration(
    SessionRepositoryFilter filter) {
  FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
      new DelegatingFilterProxy(filter));
  filterRegistrationBean.setUrlPatterns(Arrays.asList("/*"));

  return filterRegistrationBean;
}
项目:easyweb    文件:ShiroConfiguration.java   
@Bean
public FilterRegistrationBean delegatingFilterProxy(){
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    DelegatingFilterProxy proxy = new DelegatingFilterProxy();
    proxy.setTargetFilterLifecycle(true);
    proxy.setTargetBeanName("shiroFilter");
    filterRegistrationBean.setFilter(proxy);
    return filterRegistrationBean;
}
项目:pds    文件:FilterConfig.java   
@Bean
public FilterRegistrationBean shiroFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    registration.addInitParameter("targetFilterLifecycle", "true");
    registration.setEnabled(true);
    registration.setOrder(Integer.MAX_VALUE - 1);
    registration.addUrlPatterns("/*");
    return registration;
}
项目:springsecuritystudy    文件:WebAppInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain"))
    .addMappingForUrlPatterns(null, false, "/api/*");

    // 静态资源映射
    servletContext.getServletRegistration("default").addMapping("/static/*", "*.html", "*.ico");

    servletContext.addListener(HttpSessionEventPublisher.class);
    super.onStartup(servletContext);
}
项目:my-spring-boot-project    文件:FilterConfig.java   
@Bean
public FilterRegistrationBean shiroFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    registration.addInitParameter("targetFilterLifecycle", "true");
    registration.setEnabled(true);
    registration.setOrder(Integer.MAX_VALUE - 1);
    registration.addUrlPatterns("/*");
    return registration;
}
项目:ElementVueSpringbootCodeTemplate    文件:UserFilter.java   
@SneakyThrows
private void printAllFilters(FilterChain chain) {
    ApplicationFilterChain filterChain = (ApplicationFilterChain) chain;

    // 读取私有变量 filters
    ApplicationFilterConfig[] filterConfigs = (ApplicationFilterConfig[]) readField(filterChain, "filters");
    int filterSize = (int) readField(filterChain, "n");

    System.out.println("\n\nprintAllFilters(), size=" + filterSize);

    for (int i = 0; i < filterSize; i++) {
        System.out.println(filterConfigs[i].getFilterName() + ", " + filterConfigs[i].getFilterClass());

        Filter filter = (Filter) invokeMethod(filterConfigs[i], "getFilter");

        // spring 的 filter 代理类
        if (filter instanceof DelegatingFilterProxy) {
            DelegatingFilterProxy filterProxy = (DelegatingFilterProxy) filter;

            FilterChainProxy springFilter = (FilterChainProxy) readField(DelegatingFilterProxy.class, filterProxy,
                    "delegate");

            System.out.println(springFilter.getFilterChains());
            // List<Filter> springAdditionalFilters = (List<Filter>) readField(
            // springFilter, "additionalFilters");
            //
            // for (Filter f : springAdditionalFilters) {
            // System.out.print("\t\t");
            // System.out.println(f.getClass());
            // }
        }
    }

    System.out.println("\n\n");
}
项目:NGB-master    文件:AppMVCConfiguration.java   
@Bean
public FilterRegistrationBean springSecurityFilterChain() {
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    DelegatingFilterProxy securityFilter = new DelegatingFilterProxy();
    registrationBean.setFilter(securityFilter);
    registrationBean.setAsyncSupported(true);
    registrationBean.addUrlPatterns("/*");
    return registrationBean;
}
项目:steve-plugsurfing    文件:SteveAppContext.java   
private void addSecurityFilter(WebAppContext ctx) {
    // The bean name is not arbitrary, but is as expected by Spring
    Filter f = new DelegatingFilterProxy(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME);

    ctx.addFilter(
            new FilterHolder(f),
            CONFIG.getSpringManagerMapping(),
            EnumSet.allOf(DispatcherType.class)
    );
}
项目:spring4-understanding    文件:AnnotationConfigDispatcherServletInitializerTests.java   
@Override
protected Filter[] getServletFilters() {
    return new Filter[] {
            new HiddenHttpMethodFilter(),
            new DelegatingFilterProxy("a"),
            new DelegatingFilterProxy("b"),
            new DelegatingFilterProxy("c")
    };
}
项目:interview-preparation    文件:WebSecurityConfig.java   
@Bean()
FilterRegistrationBean FilterRegistrationBean() {
    final FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(new DelegatingFilterProxy("springSecurityFilterChain"));
    filterRegistrationBean.setName("springSecurityFilterChain");
    filterRegistrationBean.addUrlPatterns("/api/*");
    return filterRegistrationBean;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DelegatingFilterProxyRegistrationBean.java   
@Override
public Filter getFilter() {
    return new DelegatingFilterProxy(this.targetBeanName,
            getWebApplicationContext()) {

        @Override
        protected void initFilterBean() throws ServletException {
            // Don't initialize filter bean on init()
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DelegatingFilterProxyRegistrationBeanTests.java   
@Test
public void getFilterUsesDelegatingFilterProxy() throws Exception {
    AbstractFilterRegistrationBean registrationBean = createFilterRegistrationBean();
    Filter filter = registrationBean.getFilter();
    assertThat(filter).isInstanceOf(DelegatingFilterProxy.class);
    assertThat(ReflectionTestUtils.getField(filter, "webApplicationContext"))
            .isEqualTo(this.applicationContext);
    assertThat(ReflectionTestUtils.getField(filter, "targetBeanName"))
            .isEqualTo("mockFilter");
}
项目:kekoa    文件:ShiroConfiguration.java   
/**
 * 注册DelegatingFilterProxy(Shiro)
 *
 * @param dispatcherServlet
 * @return
 * @author SHANHY
 * @create  2016年1月13日
 */
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //  该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理  
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*");
    return filterRegistration;
}
项目:kekoa    文件:KekoaShiroConfiguration.java   
/**
 * 注册DelegatingFilterProxy(Shiro)
 *
 * @param dispatcherServlet
 * @return
 * @author SHANHY
 * @create 2016年1月13日
 */
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    // 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    // filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*");
    return filterRegistration;
}
项目:Audit4j-Hibernate    文件:WebInitializer.java   
public void onStartup(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setConfigLocation("org.audt4j.demo.hibernate.config");
    servletContext.addListener(new ContextLoaderListener(ctx));
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    servlet.addMapping("/*");
    servlet.setLoadOnStartup(1);
    FilterRegistration.Dynamic springSecurityFilterChain = servletContext
            .addFilter("springSecurityFilterChain",
                    new DelegatingFilterProxy());
    springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");
    springSecurityFilterChain.setAsyncSupported(true);
}
项目:flowable-engine    文件:WebConfigurer.java   
/**
 * Initializes Spring Security.
 */
private void initSpringSecurity(ServletContext servletContext, EnumSet<DispatcherType> disps) {
    LOGGER.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());

    springSecurityFilter.addMappingForUrlPatterns(disps, false, "/*");
}
项目:flowable-engine    文件:WebConfigurer.java   
/**
 * Initializes Spring Security.
 */
private void initSpringSecurity(ServletContext servletContext, EnumSet<DispatcherType> disps) {
    LOGGER.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());

    springSecurityFilter.addMappingForUrlPatterns(disps, false, "/*");
}
项目:flowable-engine    文件:WebConfigurer.java   
/**
 * Initializes Spring Security.
 */
private void initSpringSecurity(ServletContext servletContext, EnumSet<DispatcherType> disps) {
    LOGGER.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());

    springSecurityFilter.addMappingForUrlPatterns(disps, false, "/*");
    springSecurityFilter.setAsyncSupported(true);
}
项目:flowable-engine    文件:WebConfigurer.java   
/**
 * Initializes Spring Security.
 */
private void initSpringSecurity(ServletContext servletContext, EnumSet<DispatcherType> disps) {
    LOGGER.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());

    springSecurityFilter.addMappingForUrlPatterns(disps, false, "/*");
    springSecurityFilter.setAsyncSupported(true);
}
项目:flowable-engine    文件:WebConfigurer.java   
/**
 * Initializes Spring Security.
 */
private void initSpringSecurity(ServletContext servletContext, EnumSet<DispatcherType> disps) {
    LOGGER.debug("Registering Spring Security Filter");
    FilterRegistration.Dynamic springSecurityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());

    springSecurityFilter.addMappingForUrlPatterns(disps, false, "/*");
    springSecurityFilter.setAsyncSupported(true);
}