use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class DataConstraintsTest method startServer.
@Before
public void startServer() {
_server = new Server();
HttpConnectionFactory http = new HttpConnectionFactory();
http.getHttpConfiguration().setSecurePort(9999);
http.getHttpConfiguration().setSecureScheme("BWTP");
_connector = new LocalConnector(_server, http);
_connector.setIdleTimeout(300000);
HttpConnectionFactory https = new HttpConnectionFactory();
https.getHttpConfiguration().addCustomizer(new HttpConfiguration.Customizer() {
@Override
public void customize(Connector connector, HttpConfiguration channelConfig, Request request) {
request.setScheme(HttpScheme.HTTPS.asString());
request.setSecure(true);
}
});
_connectorS = new LocalConnector(_server, https);
_server.setConnectors(new Connector[] { _connector, _connectorS });
ContextHandler _context = new ContextHandler();
_session = new SessionHandler();
_context.setContextPath("/ctx");
_server.setHandler(_context);
_context.setHandler(_session);
_security = new ConstraintSecurityHandler();
_session.setHandler(_security);
_security.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
baseRequest.setHandled(true);
response.sendError(404);
}
});
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class SpecExampleConstraintTest method startServer.
@BeforeClass
public static void startServer() {
_server = new Server();
_connector = new LocalConnector(_server);
_server.setConnectors(new Connector[] { _connector });
ContextHandler _context = new ContextHandler();
_session = new SessionHandler();
TestLoginService _loginService = new TestLoginService(TEST_REALM);
_loginService.putUser("fred", new Password("password"), IdentityService.NO_ROLES);
_loginService.putUser("harry", new Password("password"), new String[] { "HOMEOWNER" });
_loginService.putUser("chris", new Password("password"), new String[] { "CONTRACTOR" });
_loginService.putUser("steven", new Password("password"), new String[] { "SALESCLERK" });
_context.setContextPath("/ctx");
_server.setHandler(_context);
_context.setHandler(_session);
_server.addBean(_loginService);
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class ComplianceViolations2616Test method startServer.
@BeforeClass
public static void startServer() throws Exception {
server = new Server();
HttpConfiguration config = new HttpConfiguration();
config.setSendServerVersion(false);
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config, HttpCompliance.RFC2616);
httpConnectionFactory.setRecordHttpComplianceViolations(true);
connector = new LocalConnector(server, null, null, null, -1, httpConnectionFactory);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
context.setWelcomeFiles(new String[] { "index.html", "index.jsp", "index.htm" });
context.addServlet(DumpRequestHeadersServlet.class, "/dump/*");
context.addFilter(ReportViolationsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
server.setHandler(context);
server.addConnector(connector);
server.start();
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class DispatcherForwardTest method prepare.
public void prepare() throws Exception {
server = new Server();
connector = new LocalConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(server, "/");
context.addServlet(new ServletHolder(servlet1), "/one");
context.addServlet(new ServletHolder(servlet2), "/two");
server.start();
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class ErrorPageTest method init.
@Before
public void init() throws Exception {
_server = new Server();
_connector = new LocalConnector(_server);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
_server.addConnector(_connector);
_server.setHandler(context);
context.setContextPath("/");
context.addServlet(DefaultServlet.class, "/");
context.addServlet(FailServlet.class, "/fail/*");
context.addServlet(ErrorServlet.class, "/error/*");
ErrorPageErrorHandler error = new ErrorPageErrorHandler();
context.setErrorHandler(error);
error.addErrorPage(599, "/error/599");
error.addErrorPage(IllegalStateException.class.getCanonicalName(), "/error/TestException");
error.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE, "/error/GlobalErrorPage");
_server.start();
_stackless = new StacklessLogging(ServletHandler.class);
}
Aggregations