Java Code Examples for org.eclipse.jetty.servlet.FilterHolder#setInitParameters()
The following examples show how to use
org.eclipse.jetty.servlet.FilterHolder#setInitParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Poseidon.java From Poseidon with Apache License 2.0 | 6 votes |
private void addFilters(ServletContextHandler servletContextHandler) { // RequestContext is required in other filters, hence set it up first servletContextHandler.addFilter(new FilterHolder(new HystrixContextFilter(configuration)), "/*", EnumSet.of(REQUEST)); // Set up distributed tracing filter ServletTraceFilter servletTraceFilter = ServletTraceFilterBuilder.build(configuration); if (servletTraceFilter != null) { servletContextHandler.addFilter(new FilterHolder(servletTraceFilter), "/*", EnumSet.of(REQUEST)); } servletContextHandler.addFilter(new FilterHolder(new RequestGzipFilter()), "/*", EnumSet.of(REQUEST)); List<JettyFilterConfiguration> jettyFilterConfigurations = Optional.ofNullable(configuration.getJettyConfiguration()).map(JettyConfiguration::getJettyFilterConfigurations).orElse(new ArrayList<>()); for (JettyFilterConfiguration filterConfig : jettyFilterConfigurations) { FilterHolder filterHolder = new FilterHolder(filterConfig.getFilter()); filterHolder.setInitParameters(filterConfig.getInitParameters()); for (String mapping : filterConfig.getMappings()) { servletContextHandler.addFilter(filterHolder, mapping, filterConfig.getDispatcherTypes()); } } }
Example 2
Source File: WebServerModule.java From datacollector with Apache License 2.0 | 6 votes |
@Provides(type = Type.SET) ContextConfigurator provideCrossOriginFilter(final Configuration conf) { return new ContextConfigurator() { @Override public void init(ServletContextHandler context) { FilterHolder crossOriginFilter = new FilterHolder(CrossOriginFilter.class); Map<String, String> params = new HashMap<>(); params.put(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN, CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN_DEFAULT)); params.put(CrossOriginFilter.ALLOWED_METHODS_PARAM, conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS, CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS_DEFAULT)); params.put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS, CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS_DEFAULT)); crossOriginFilter.setInitParameters(params); context.addFilter(crossOriginFilter, "/*", EnumSet.of(DispatcherType.REQUEST)); } }; }
Example 3
Source File: HttpServer2.java From hadoop-ozone with Apache License 2.0 | 5 votes |
private static FilterHolder getFilterHolder(String name, String classname, Map<String, String> parameters) { FilterHolder holder = new FilterHolder(); holder.setName(name); holder.setClassName(classname); if (parameters != null) { holder.setInitParameters(parameters); } return holder; }
Example 4
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 5 votes |
private static FilterHolder getFilterHolder(String name, String classname, Map<String, String> parameters) { FilterHolder holder = new FilterHolder(); holder.setName(name); holder.setClassName(classname); if (parameters != null) { holder.setInitParameters(parameters); } return holder; }
Example 5
Source File: JettyConfigurationHelper.java From attic-polygene-java with Apache License 2.0 | 5 votes |
static void addFilters( ServletContextHandler root, Iterable<ServiceReference<Filter>> filters ) { // Iterate the available filters and add them to the server for( ServiceReference<Filter> filter : filters ) { FilterInfo filterInfo = filter.metaInfo( FilterInfo.class ); String filterPath = filterInfo.getPath(); Filter filterInstance = filter.get(); FilterHolder holder = new FilterHolder( filterInstance ); holder.setInitParameters( filterInfo.initParameters() ); root.addFilter( holder, filterPath, filterInfo.dispatchers() ); } }
Example 6
Source File: RESTServer.java From hbase with Apache License 2.0 | 5 votes |
void addCSRFFilter(ServletContextHandler ctxHandler, Configuration conf) { restCSRFEnabled = conf.getBoolean(REST_CSRF_ENABLED_KEY, REST_CSRF_ENABLED_DEFAULT); if (restCSRFEnabled) { Map<String, String> restCsrfParams = RestCsrfPreventionFilter .getFilterParams(conf, "hbase.rest-csrf."); FilterHolder holder = new FilterHolder(); holder.setName("csrf"); holder.setClassName(RestCsrfPreventionFilter.class.getName()); holder.setInitParameters(restCsrfParams); ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class)); } }
Example 7
Source File: RESTServer.java From hbase with Apache License 2.0 | 5 votes |
private void addClickjackingPreventionFilter(ServletContextHandler ctxHandler, Configuration conf) { FilterHolder holder = new FilterHolder(); holder.setName("clickjackingprevention"); holder.setClassName(ClickjackingPreventionFilter.class.getName()); holder.setInitParameters(ClickjackingPreventionFilter.getDefaultParameters(conf)); ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class)); }
Example 8
Source File: RESTServer.java From hbase with Apache License 2.0 | 5 votes |
private void addSecurityHeadersFilter(ServletContextHandler ctxHandler, Configuration conf) { FilterHolder holder = new FilterHolder(); holder.setName("securityheaders"); holder.setClassName(SecurityHeadersFilter.class.getName()); holder.setInitParameters(SecurityHeadersFilter.getDefaultParameters(conf)); ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class)); }
Example 9
Source File: HttpServer.java From hbase with Apache License 2.0 | 5 votes |
/** * Define a filter for a context and set up default url mappings. */ public static void defineFilter(ServletContextHandler handler, String name, String classname, Map<String,String> parameters, String[] urls) { FilterHolder holder = new FilterHolder(); holder.setName(name); holder.setClassName(classname); if (parameters != null) { holder.setInitParameters(parameters); } FilterMapping fmap = new FilterMapping(); fmap.setPathSpecs(urls); fmap.setDispatches(FilterMapping.ALL); fmap.setFilterName(name); handler.getServletHandler().addFilter(holder, fmap); }
Example 10
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
private static FilterHolder getFilterHolder(String name, String classname, Map<String, String> parameters) { FilterHolder holder = new FilterHolder(); holder.setName(name); holder.setClassName(classname); if (parameters != null) { holder.setInitParameters(parameters); } return holder; }
Example 11
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
private static FilterHolder getFilterHolder(String name, String classname, Map<String, String> parameters) { FilterHolder holder = new FilterHolder(); holder.setName(name); holder.setClassName(classname); if (parameters != null) { holder.setInitParameters(parameters); } return holder; }
Example 12
Source File: SentryWebServer.java From incubator-sentry with Apache License 2.0 | 4 votes |
public SentryWebServer(List<EventListener> listeners, int port, Configuration conf) { this.port = port; server = new Server(port); ServletContextHandler servletContextHandler = new ServletContextHandler(); ServletHolder servletHolder = new ServletHolder(AdminServlet.class); servletContextHandler.addServlet(servletHolder, "/*"); for(EventListener listener:listeners) { servletContextHandler.addEventListener(listener); } ServletHolder confServletHolder = new ServletHolder(ConfServlet.class); servletContextHandler.addServlet(confServletHolder, "/conf"); servletContextHandler.getServletContext() .setAttribute(ConfServlet.CONF_CONTEXT_ATTRIBUTE, conf); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); URL url = this.getClass().getResource(RESOURCE_DIR); try { resourceHandler.setBaseResource(Resource.newResource(url.toString())); } catch (IOException e) { LOGGER.error("Got exception while setBaseResource for Sentry Service web UI", e); } resourceHandler.setWelcomeFiles(new String[]{WELCOME_PAGE}); ContextHandler contextHandler= new ContextHandler(); contextHandler.setHandler(resourceHandler); ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection(); contextHandlerCollection.setHandlers(new Handler[]{contextHandler, servletContextHandler}); String authMethod = conf.get(ServerConfig.SENTRY_WEB_SECURITY_TYPE); if (!ServerConfig.SENTRY_WEB_SECURITY_TYPE_NONE.equals(authMethod)) { /** * SentryAuthFilter is a subclass of AuthenticationFilter and * AuthenticationFilter tagged as private and unstable interface: * While there are not guarantees that this interface will not change, * it is fairly stable and used by other projects (ie - Oozie) */ FilterHolder filterHolder = servletContextHandler.addFilter(SentryAuthFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); filterHolder.setInitParameters(loadWebAuthenticationConf(conf)); } server.setHandler(contextHandlerCollection); }