本文整理汇总了Java中org.eclipse.jetty.servlet.FilterHolder.setInitParameters方法的典型用法代码示例。如果您正苦于以下问题:Java FilterHolder.setInitParameters方法的具体用法?Java FilterHolder.setInitParameters怎么用?Java FilterHolder.setInitParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.FilterHolder
的用法示例。
在下文中一共展示了FilterHolder.setInitParameters方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFilters
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
private void setFilters(JettyHttpEndpoint endpoint, Server server, String connectorKey) {
ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
List<Filter> filters = endpoint.getFilters();
for (Filter filter : filters) {
FilterHolder filterHolder = new FilterHolder();
if (endpoint.getFilterInitParameters() != null) {
filterHolder.setInitParameters(endpoint.getFilterInitParameters());
}
filterHolder.setFilter(new CamelFilterWrapper(filter));
String pathSpec = endpoint.getPath();
if (pathSpec == null || "".equals(pathSpec)) {
pathSpec = "/";
}
if (endpoint.isMatchOnUriPrefix()) {
pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
}
addFilter(context, filterHolder, pathSpec);
}
}
示例2: createServletHandlerWithServlet
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
private ServletContextHandler createServletHandlerWithServlet() {
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
FilterHolder pushCacheFilter = context.addFilter(PushCacheFilter.class, "/*",
null);
Map<String, String> config = new HashMap<>();
config.put("maxAssociations", "32");
config.put("ports", Objects.toString(SSL_PORT));
pushCacheFilter.setInitParameters(config);
context.addServlet(NoopServlet.class, "/*");
context.setContextPath("/");
return context;
}
示例3: addFilters
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
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());
}
}
}
示例4: provideCrossOriginFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
@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));
}
};
}
示例5: defineFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
/**
* 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);
}
示例6: addFilters
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
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() );
}
}
示例7: hold
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public static FilterHolder hold(Class<? extends Filter> classOf, Map<String, String> params) {
FilterHolder holder = new FilterHolder(classOf);
{
holder.setInitParameters(params);
}
return holder;
}
示例8: addCSRFFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
static 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));
}
}
示例9: init
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public List<Stage.ConfigIssue> init(Stage.Context context) {
List<Stage.ConfigIssue> issues = new ArrayList<>();
try {
int maxThreads = getJettyServerMaxThreads();
int minThreads = getJettyServerMinThreads();
QueuedThreadPool threadPool =
new QueuedThreadPool(maxThreads, minThreads, 60000, new ArrayBlockingQueue<Runnable>(maxThreads));
threadPool.setName("http-receiver-server:" + context.getPipelineInfo().get(0).getInstanceName());
threadPool.setDaemon(true);
Server server = new Server(threadPool);
ServerConnector connector;
if (configs.isTlsEnabled()) {
LOG.debug("Configuring HTTPS");
HttpConfiguration httpsConf = new HttpConfiguration();
httpsConf.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = new SslContextFactory();
TlsConfigBean tlsConfig = configs.getTlsConfigBean();
sslContextFactory.setKeyStorePath(tlsConfig.keyStoreFilePath);
sslContextFactory.setKeyStoreType(tlsConfig.keyStoreType.getJavaValue());
sslContextFactory.setKeyStorePassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setKeyManagerPassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setIncludeProtocols(tlsConfig.getFinalProtocols());
sslContextFactory.setIncludeCipherSuites(tlsConfig.getFinalCipherSuites());
connector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConf)
);
} else {
LOG.debug("Configuring HTTP");
connector = new ServerConnector(server);
}
connector.setPort(configs.getPort());
server.setConnectors(new Connector[]{connector});
ServletContextHandler contextHandler = new ServletContextHandler();
// CORS Handling
FilterHolder crossOriginFilter = new FilterHolder(CrossOriginFilter.class);
Map<String, String> params = new HashMap<>();
params.put(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
params.put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*");
crossOriginFilter.setInitParameters(params);
contextHandler.addFilter(crossOriginFilter, "/*", EnumSet.of(DispatcherType.REQUEST));
addReceiverServlet(context, contextHandler);
contextHandler.setContextPath("/");
server.setHandler(contextHandler);
server.start();
LOG.debug("Running, port '{}', TLS '{}'", configs.getPort(), configs.isTlsEnabled());
httpServer = server;
} catch (Exception ex) {
issues.add(context.createConfigIssue("HTTP", "", HttpServerErrors.HTTP_SERVER_ORIG_20, ex.toString()));
}
return issues;
}
示例10: SentryWebServer
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
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);
}