Search in sources :

Example 1 with HandlerCollection

use of org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.HandlerCollection in project hbase by apache.

the class HttpServer method initializeWebServer.

private void initializeWebServer(String name, String hostName, Configuration conf, String[] pathSpecs, HttpServer.Builder b) throws FileNotFoundException, IOException {
    Preconditions.checkNotNull(webAppContext);
    HandlerCollection handlerCollection = new HandlerCollection();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    RequestLog requestLog = HttpRequestLog.getRequestLog(name);
    if (requestLog != null) {
        RequestLogHandler requestLogHandler = new RequestLogHandler();
        requestLogHandler.setRequestLog(requestLog);
        handlerCollection.addHandler(requestLogHandler);
    }
    final String appDir = getWebAppsPath(name);
    handlerCollection.addHandler(contexts);
    handlerCollection.addHandler(webAppContext);
    webServer.setHandler(handlerCollection);
    webAppContext.setAttribute(ADMINS_ACL, adminsAcl);
    // Default apps need to be set first, so that all filters are applied to them.
    // Because they're added to defaultContexts, we need them there before we start
    // adding filters
    addDefaultApps(contexts, appDir, conf);
    addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
    addGlobalFilter("clickjackingprevention", ClickjackingPreventionFilter.class.getName(), ClickjackingPreventionFilter.getDefaultParameters(conf));
    addGlobalFilter("securityheaders", SecurityHeadersFilter.class.getName(), SecurityHeadersFilter.getDefaultParameters(conf));
    // But security needs to be enabled prior to adding the other servlets
    if (authenticationEnabled) {
        initSpnego(conf, hostName, b.usernameConfKey, b.keytabConfKey, b.kerberosNameRulesKey, b.signatureSecretFileKey);
    }
    final FilterInitializer[] initializers = getFilterInitializers(conf);
    if (initializers != null) {
        conf = new Configuration(conf);
        conf.set(BIND_ADDRESS, hostName);
        for (FilterInitializer c : initializers) {
            c.initFilter(this, conf);
        }
    }
    addDefaultServlets(contexts, conf);
    if (pathSpecs != null) {
        for (String path : pathSpecs) {
            LOG.info("adding path spec: " + path);
            addFilterPathMapping(path, webAppContext);
        }
    }
}
Also used : RequestLog(org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog) HttpConfiguration(org.apache.hbase.thirdparty.org.eclipse.jetty.server.HttpConfiguration) Configuration(org.apache.hadoop.conf.Configuration) RequestLogHandler(org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.RequestLogHandler) ContextHandlerCollection(org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.HandlerCollection) ContextHandlerCollection(org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.ContextHandlerCollection)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 HttpConfiguration (org.apache.hbase.thirdparty.org.eclipse.jetty.server.HttpConfiguration)1 RequestLog (org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog)1 ContextHandlerCollection (org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.ContextHandlerCollection)1 HandlerCollection (org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.HandlerCollection)1 RequestLogHandler (org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.RequestLogHandler)1