Java Code Examples for org.eclipse.jetty.servlets.DoSFilter

Following code examples demonstrate how to use org.eclipse.jetty.servlets.DoSFilter from jetty. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.eclipse.jetty.servlets.DoSFilter and various code implementation of this class.
Example 1
Project : jetty Source File : Server.java View Source Code on GitHub

    public Server() throws IOException {
        super();
        
        ServerConfiguration config = JmeResourceWebsite.getInstance().getConfiguration().getServerConfig();
        System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");

        DispatcherServlet apiServlet = new DispatcherServlet();
        apiServlet.setContextConfigLocation("classpath:spring-api.xml");
        apiServlet.setThrowExceptionIfNoHandlerFound(true);

        DispatcherServlet htmlServlet = new DispatcherServlet();
        htmlServlet.setContextConfigLocation("classpath:spring-html.xml");
        htmlServlet.setThrowExceptionIfNoHandlerFound(true);

        WebAppContext contextHandler = new WebAppContext();
        this.setClassLoader(contextHandler);
        
        contextHandler.setAttribute("javax.servlet.context.tempdir", this.getScratchDir());
        contextHandler.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
        contextHandler.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
        contextHandler.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        contextHandler.addBean(new ServletContainerInitializersStarter(contextHandler), true);

        contextHandler.setContextPath(config.getBindPath().isEmpty() ? "/" : config.getBindPath());
        contextHandler.setResourceBase(new ClassPathResource("webapp").getURI().toString());
        contextHandler.addFilter(DoSFilter.class, "*", null);
        contextHandler.addFilter(CrossOriginFilter.class, "*", null);

        String[] mimetypes = {
                "text/html",
                "application/json",
                "text/plain",
                "text/css",
                "application/javascript"
        };

        GzipHandler gzipHandler = new GzipHandler();
        gzipHandler.setIncludedMethods("GET", "POST");
        gzipHandler.setIncludedMimeTypes(mimetypes);

        contextHandler.setGzipHandler(gzipHandler);

        this.setHandler(contextHandler);
        
        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setSendServerVersion(false);
        httpConfig.setSendXPoweredBy(false);
        
        HttpConnectionFactory http1 = new HttpConnectionFactory(httpConfig);

        ServerConnector httpConnector = new ServerConnector(this, http1);
        httpConnector.setPort(config.getBindPort());
        this.setConnectors(new Connector[] { httpConnector });
    }