use of org.eclipse.jetty.server.handler.ContextHandler in project dropwizard by dropwizard.
the class RoutingHandlerTest method withSessionHandler.
@Test
void withSessionHandler() throws Exception {
final ContextHandler handler1 = new ContextHandler();
final ServletContextHandler handler2 = new ServletContextHandler();
final SessionHandler childHandler1 = new SessionHandler();
handler2.setSessionHandler(childHandler1);
final RoutingHandler handler = new RoutingHandler(Maps.of(connector1, handler1, connector2, handler2));
new Server().setHandler(handler);
handler.start();
try {
assertThat(getSessionHandlers(handler)).containsOnly(childHandler1);
} finally {
handler.stop();
}
}
use of org.eclipse.jetty.server.handler.ContextHandler in project gerrit by GerritCodeReview.
the class JettyServer method makeContext.
private Handler makeContext(JettyEnv env, Config cfg, SessionHandler sessionHandler) {
final Set<String> paths = new HashSet<>();
for (URI u : listenURLs(cfg)) {
String p = u.getPath();
if (p == null || p.isEmpty()) {
p = "/";
}
while (1 < p.length() && p.endsWith("/")) {
p = p.substring(0, p.length() - 1);
}
paths.add(p);
}
final List<ContextHandler> all = new ArrayList<>();
for (String path : paths) {
all.add(makeContext(path, env, cfg, sessionHandler));
}
if (all.size() == 1) {
//
return all.get(0);
}
// We have more than one path served out of this container so
// combine them in a handler which supports dispatching to the
// individual contexts.
//
final ContextHandlerCollection r = new ContextHandlerCollection();
r.setHandlers(all.toArray(new Handler[0]));
return r;
}
use of org.eclipse.jetty.server.handler.ContextHandler in project gocd by gocd.
the class Jetty9ServerTest method shouldAddRootRequestHandler.
@Test
public void shouldAddRootRequestHandler() throws Exception {
jetty9Server.configure();
jetty9Server.startHandlers();
ContextHandler rootRequestHandler = getLoadedHandlers().get(GoServerLoadingIndicationHandler.class);
assertThat(rootRequestHandler.getContextPath(), is("/"));
}
use of org.eclipse.jetty.server.handler.ContextHandler in project rabbitmq-java-client by rabbitmq.
the class OAuth2ClientCredentialsGrantCredentialsProviderTest method startHttpsServer.
KeyStore startHttpsServer(int port, Handler handler) throws Exception {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
String keyStorePassword = "password";
keyStore.load(null, keyStorePassword.toCharArray());
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair kp = kpg.generateKeyPair();
JcaX509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(new X500NameBuilder().addRDN(BCStyle.CN, "localhost").build(), BigInteger.valueOf(new SecureRandom().nextInt()), Date.from(Instant.now().minus(10, ChronoUnit.DAYS)), Date.from(Instant.now().plus(10, ChronoUnit.DAYS)), new X500NameBuilder().addRDN(BCStyle.CN, "localhost").build(), kp.getPublic());
X509CertificateHolder certificateHolder = certificateBuilder.build(new JcaContentSignerBuilder("SHA256WithRSAEncryption").build(kp.getPrivate()));
X509Certificate certificate = new JcaX509CertificateConverter().getCertificate(certificateHolder);
keyStore.setKeyEntry("default", kp.getPrivate(), keyStorePassword.toCharArray(), new Certificate[] { certificate });
server = new Server();
SslContextFactory sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStore(keyStore);
sslContextFactory.setKeyStorePassword(keyStorePassword);
HttpConfiguration httpsConfiguration = new HttpConfiguration();
httpsConfiguration.setSecureScheme("https");
httpsConfiguration.setSecurePort(port);
httpsConfiguration.setOutputBufferSize(32768);
SecureRequestCustomizer src = new SecureRequestCustomizer();
src.setStsMaxAge(2000);
src.setStsIncludeSubDomains(true);
httpsConfiguration.addCustomizer(src);
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfiguration));
https.setPort(port);
https.setIdleTimeout(500000);
server.setConnectors(new Connector[] { https });
ContextHandler context = new ContextHandler();
context.setContextPath("/uaa/oauth/token");
context.setHandler(handler);
server.setHandler(context);
server.start();
return keyStore;
}
use of org.eclipse.jetty.server.handler.ContextHandler in project cxf by apache.
the class Jetty9WebSocketDestination method getServer.
Server getServer(ServletConfig config, ServletContext context) {
ContextHandler.Context c = (ContextHandler.Context) context;
ContextHandler h = c.getContextHandler();
return h.getServer();
}
Aggregations