Search in sources :

Example 1 with ContentServlet

use of org.apache.qpid.server.management.plugin.servlet.ContentServlet in project qpid-broker-j by apache.

the class HttpManagement method addFiltersAndServletsForRest.

private void addFiltersAndServletsForRest(final ServletContextHandler root) {
    FilterHolder loggingFilter = new FilterHolder(new LoggingFilter());
    root.addFilter(loggingFilter, "/api/*", EnumSet.of(DispatcherType.REQUEST));
    root.addFilter(loggingFilter, "/service/*", EnumSet.of(DispatcherType.REQUEST));
    FilterHolder restAuthorizationFilter = new FilterHolder(new AuthenticationCheckFilter());
    restAuthorizationFilter.setInitParameter(AuthenticationCheckFilter.INIT_PARAM_ALLOWED, "/service/sasl");
    root.addFilter(restAuthorizationFilter, "/api/*", EnumSet.of(DispatcherType.REQUEST));
    root.addFilter(restAuthorizationFilter, "/service/*", EnumSet.of(DispatcherType.REQUEST));
    addRestServlet(root);
    ServletHolder queryServlet = new ServletHolder(new BrokerQueryServlet());
    root.addServlet(queryServlet, "/api/latest/querybroker/*");
    root.addServlet(queryServlet, "/api/v" + BrokerModel.MODEL_VERSION + "/querybroker/*");
    ServletHolder vhQueryServlet = new ServletHolder(new VirtualHostQueryServlet());
    root.addServlet(vhQueryServlet, "/api/latest/queryvhost/*");
    root.addServlet(vhQueryServlet, "/api/v" + BrokerModel.MODEL_VERSION + "/queryvhost/*");
    root.addServlet(new ServletHolder(new StructureServlet()), "/service/structure");
    root.addServlet(new ServletHolder(new QueueReportServlet()), "/service/queuereport/*");
    root.addServlet(new ServletHolder(new MetaDataServlet()), "/service/metadata");
    root.addServlet(new ServletHolder(new TimeZoneServlet()), "/service/timezones");
    final Iterable<ContentFactory> contentFactories = new QpidServiceLoader().instancesOf(ContentFactory.class);
    contentFactories.forEach(f -> {
        ServletHolder metricsServlet = new ServletHolder(new ContentServlet(f));
        String path = f.getType().toLowerCase();
        root.addServlet(metricsServlet, "/" + path);
        root.addServlet(metricsServlet, "/" + path + "/*");
        if (getContextValue(Boolean.class, HTTP_MANAGEMENT_ENABLE_CONTENT_AUTHENTICATION)) {
            root.addFilter(restAuthorizationFilter, "/" + path, EnumSet.of(DispatcherType.REQUEST));
            root.addFilter(restAuthorizationFilter, "/" + path + "/*", EnumSet.of(DispatcherType.REQUEST));
        }
    });
}
Also used : FilterHolder(org.eclipse.jetty.servlet.FilterHolder) MetaDataServlet(org.apache.qpid.server.management.plugin.servlet.rest.MetaDataServlet) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) LoggingFilter(org.apache.qpid.server.management.plugin.filter.LoggingFilter) AuthenticationCheckFilter(org.apache.qpid.server.management.plugin.filter.AuthenticationCheckFilter) ContentFactory(org.apache.qpid.server.plugin.ContentFactory) BrokerQueryServlet(org.apache.qpid.server.management.plugin.servlet.rest.BrokerQueryServlet) QueueReportServlet(org.apache.qpid.server.management.plugin.servlet.rest.QueueReportServlet) VirtualHostQueryServlet(org.apache.qpid.server.management.plugin.servlet.rest.VirtualHostQueryServlet) ContentServlet(org.apache.qpid.server.management.plugin.servlet.ContentServlet) StructureServlet(org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet) TimeZoneServlet(org.apache.qpid.server.management.plugin.servlet.rest.TimeZoneServlet)

Aggregations

AuthenticationCheckFilter (org.apache.qpid.server.management.plugin.filter.AuthenticationCheckFilter)1 LoggingFilter (org.apache.qpid.server.management.plugin.filter.LoggingFilter)1 ContentServlet (org.apache.qpid.server.management.plugin.servlet.ContentServlet)1 BrokerQueryServlet (org.apache.qpid.server.management.plugin.servlet.rest.BrokerQueryServlet)1 MetaDataServlet (org.apache.qpid.server.management.plugin.servlet.rest.MetaDataServlet)1 QueueReportServlet (org.apache.qpid.server.management.plugin.servlet.rest.QueueReportServlet)1 StructureServlet (org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet)1 TimeZoneServlet (org.apache.qpid.server.management.plugin.servlet.rest.TimeZoneServlet)1 VirtualHostQueryServlet (org.apache.qpid.server.management.plugin.servlet.rest.VirtualHostQueryServlet)1 ContentFactory (org.apache.qpid.server.plugin.ContentFactory)1 QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)1 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1