use of org.eclipse.jetty.server.HttpConfiguration 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.HttpConfiguration in project jetty.project by eclipse.
the class ConstraintSecurityHandler method checkUserDataPermissions.
@Override
protected boolean checkUserDataPermissions(String pathInContext, Request request, Response response, RoleInfo roleInfo) throws IOException {
if (roleInfo == null)
return true;
if (roleInfo.isForbidden())
return false;
UserDataConstraint dataConstraint = roleInfo.getUserDataConstraint();
if (dataConstraint == null || dataConstraint == UserDataConstraint.None)
return true;
HttpConfiguration httpConfig = Request.getBaseRequest(request).getHttpChannel().getHttpConfiguration();
if (dataConstraint == UserDataConstraint.Confidential || dataConstraint == UserDataConstraint.Integral) {
if (request.isSecure())
return true;
if (httpConfig.getSecurePort() > 0) {
String scheme = httpConfig.getSecureScheme();
int port = httpConfig.getSecurePort();
String url = URIUtil.newURI(scheme, request.getServerName(), port, request.getRequestURI(), request.getQueryString());
response.setContentLength(0);
response.sendRedirect(url);
} else
response.sendError(HttpStatus.FORBIDDEN_403, "!Secure");
request.setHandled(true);
return false;
} else {
throw new IllegalArgumentException("Invalid dataConstraint value: " + dataConstraint);
}
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class ProxyServletLoadTest method startProxy.
private void startProxy() throws Exception {
QueuedThreadPool proxyPool = new QueuedThreadPool();
proxyPool.setName("proxy");
proxy = new Server(proxyPool);
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class ReverseProxyTest method startProxy.
private void startProxy(Map<String, String> params) throws Exception {
proxy = new Server();
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(new AsyncMiddleManServlet() {
@Override
protected String rewriteTarget(HttpServletRequest clientRequest) {
StringBuilder builder = new StringBuilder();
builder.append(clientRequest.getScheme()).append("://127.0.0.1:");
builder.append(serverConnector.getLocalPort());
builder.append(clientRequest.getRequestURI());
String query = clientRequest.getQueryString();
if (query != null)
builder.append("?").append(query);
return builder.toString();
}
});
if (params != null)
proxyServletHolder.setInitParameters(params);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
use of org.eclipse.jetty.server.HttpConfiguration in project jetty.project by eclipse.
the class AbstractTest method start.
protected void start(ServerSessionListener listener) throws Exception {
prepareServer(new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener));
server.start();
prepareClient();
client.start();
}
Aggregations