List of usage examples for javax.servlet ServletContext addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass);
From source file:io.github.microcks.config.WebConfiguration.java
/** */ private void initCORSFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) { FilterRegistration.Dynamic corsFilter = servletContext.addFilter("corsFilter", new CorsFilter()); corsFilter.addMappingForUrlPatterns(disps, true, "/api/*"); corsFilter.setAsyncSupported(true);/*w w w . ja v a 2 s. c o m*/ }
From source file:net.orpiske.tcs.service.config.WebAppInitializer.java
private void configureSpringSecurity(ServletContext servletContext, WebApplicationContext rootContext) { FilterRegistration.Dynamic springSecurity = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain", rootContext)); springSecurity.addMappingForUrlPatterns(null, true, "/*"); }
From source file:com.sky.HibakeSeoBootApplication.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { log.info(" prerenderFilter "); //servletContext.addFilter("prerenderFilter", PrerenderFilter.class); servletContext.addFilter("seoFilter", CustomSEOFilter.class); WebApplicationContext rootAppContext = createRootApplicationContext(servletContext); if (rootAppContext != null) { servletContext.addListener(new ContextLoaderListener(rootAppContext) { @Override// w ww .j av a 2s .com public void contextInitialized(ServletContextEvent event) { // no-op because the application context is already initialized } }); } else { this.logger.debug("No ContextLoaderListener registered, as " + "createRootApplicationContext() did not " + "return an application context"); } }
From source file:com.dm.estore.config.WebAppInitializer.java
private void registerFilters(ServletContext servletContext) { FilterRegistration.Dynamic securityFilter = servletContext.addFilter(SECURITY_FILTER_NAME, new DelegatingFilterProxy()); securityFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, REST_SERVLET_MAPPING); securityFilter.setAsyncSupported(true); FilterRegistration.Dynamic applicationFilter = servletContext.addFilter(APP_FILTER_NAME, new ApplicationFilter()); applicationFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, APP_FILTER_MAPPING);/*from w w w .j av a 2 s . c om*/ applicationFilter.setAsyncSupported(true); }
From source file:com.kabiliravi.kaman.web.KamanApplicationInitializer.java
private void registerSpringSecurityFilterChain(ServletContext servletContext) { FilterRegistration.Dynamic springSecurityFilterChain = servletContext .addFilter(BeanIds.SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy()); springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*"); }
From source file:com.tcloud.bee.key.server.jetty.config.WebAppInitializer.java
/** * Register JerseyServlet Config//from w w w.j a v a 2s .co m * * @param servletContext */ private void configurationJersey(ServletContext servletContext) { FilterRegistration.Dynamic filterDinamic = servletContext.addFilter("jersey", new org.glassfish.jersey.servlet.ServletContainer()); filterDinamic.setInitParameter("javax.ws.rs.Application", "org.apache.hadoop.io.crypto.bee.key.server.jetty.config.JerseyApplicationConfig"); filterDinamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/api/*"); }
From source file:info.gehrels.voting.web.SpringConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { CharacterEncodingFilter filter = new CharacterEncodingFilter(); filter.setEncoding("UTF-8"); servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(EnumSet.of(REQUEST), false, "/*"); }
From source file:br.com.joaops.awc.AwcApplicationInitializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { WebApplicationContext context = getContext(); sc.addListener(new ContextLoaderListener(context)); sc.addFilter("CharacterEncodingFilter", getCharacterEncodingFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL);/*from www. j a va 2s. c o m*/ sc.addFilter("RequestContextFilter", getRequestContextFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL); sc.addFilter("OpenEntityManagerInViewFilter", getOpenEntityManagerInViewFilter()) .addMappingForUrlPatterns(null, true, MAPPING_URL); //sc.addFilter("securityFilter", getDelegatingFilterProxy()).addMappingForUrlPatterns(null, true, MAPPING_URL); ServletRegistration.Dynamic dispatcher = sc.addServlet("LoversBookServlet", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1); dispatcher.setAsyncSupported(Boolean.TRUE); dispatcher.addMapping(MAPPING_URL); }
From source file:br.com.joaops.smt.SmtApplicationInitializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { WebApplicationContext context = getContext(); sc.addListener(new ContextLoaderListener(context)); sc.addFilter("CharacterEncodingFilter", getCharacterEncodingFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL);//from ww w .ja v a 2s. c o m sc.addFilter("RequestContextFilter", getRequestContextFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL); sc.addFilter("OpenEntityManagerInViewFilter", getOpenEntityManagerInViewFilter()) .addMappingForUrlPatterns(null, true, MAPPING_URL); sc.addFilter("securityFilter", getDelegatingFilterProxy()).addMappingForUrlPatterns(null, false, MAPPING_URL); //Deixar como false, para que no d erro no multi tenant! Onde o mtodo SecurityContextHolder.getContext().getAuthentication() sempre retornava nulo depois do login ServletRegistration.Dynamic dispatcher = sc.addServlet("LoversBookServlet", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1); dispatcher.setAsyncSupported(Boolean.TRUE); dispatcher.addMapping(MAPPING_URL); }
From source file:io.github.microcks.config.WebConfiguration.java
/** */ private void initStaticResourcesFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Registering static resources production Filter"); FilterRegistration.Dynamic resFilter = servletContext.addFilter("staticResourcesFilter", new StaticResourcesFilter()); resFilter.addMappingForUrlPatterns(disps, true, "/"); resFilter.addMappingForUrlPatterns(disps, true, "/index.html"); resFilter.addMappingForUrlPatterns(disps, true, "/scripts/*"); resFilter.addMappingForUrlPatterns(disps, true, "/images/*"); resFilter.addMappingForUrlPatterns(disps, true, "/styles/*"); resFilter.addMappingForUrlPatterns(disps, true, "/views/*"); resFilter.addMappingForUrlPatterns(disps, true, "/bower_components/*"); resFilter.setAsyncSupported(true);// w ww. j a v a 2s . c o m }