use of org.eclipse.jetty.server.SecureRequestCustomizer in project scheduling by ow2-proactive.
the class ErrorCases method startHttpsServer.
@BeforeClass
public static void startHttpsServer() throws Exception {
skipIfHeadlessEnvironment();
server = new Server();
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(ErrorCases.class.getResource("keystore").getPath());
sslContextFactory.setKeyStorePassword("activeeon");
HttpConfiguration httpConfig = new HttpConfiguration();
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ServerConnector sslConnector = new ServerConnector(server, new ConnectionFactory[] { new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig) });
server.addConnector(sslConnector);
server.start();
serverUrl = "https://localhost:" + sslConnector.getLocalPort() + "/rest";
}
use of org.eclipse.jetty.server.SecureRequestCustomizer in project pentaho-kettle by pentaho.
the class WebServer method getServerConnector.
private ServerConnector getServerConnector() {
ServerConnector serverConnector = null;
int jettyAcceptors = -1;
// Check if there's configuration for the number of acceptors to use
if (validProperty(Const.KETTLE_CARTE_JETTY_ACCEPTORS)) {
jettyAcceptors = Integer.parseInt(System.getProperty(Const.KETTLE_CARTE_JETTY_ACCEPTORS));
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.ConfigOptions", "acceptors", jettyAcceptors));
}
// Create the server with the configurated number of acceptors
if (sslConfig != null) {
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.SslModeUsing"));
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(sslConfig.getKeyStore());
sslContextFactory.setKeyStorePassword(sslConfig.getKeyStorePassword());
sslContextFactory.setKeyManagerPassword(sslConfig.getKeyPassword());
sslContextFactory.setKeyStoreType(sslConfig.getKeyStoreType());
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
serverConnector = new ServerConnector(server, jettyAcceptors, -1, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https));
} else {
serverConnector = new ServerConnector(server, jettyAcceptors, -1);
}
// Low resources options
if (validProperty(Const.KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE)) {
serverConnector.setAcceptQueueSize(Integer.parseInt(System.getProperty(Const.KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE)));
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.ConfigOptions", "acceptQueueSize", serverConnector.getAcceptQueueSize()));
}
if (validProperty(Const.KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME)) {
LowResourceMonitor lowResourceMonitor = new LowResourceMonitor(server);
lowResourceMonitor.setLowResourcesIdleTimeout(Integer.parseInt(System.getProperty(Const.KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME)));
server.addBean(lowResourceMonitor);
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.ConfigOptions", "lowResourcesMaxIdleTime", lowResourceMonitor.getLowResourcesIdleTimeout()));
}
return serverConnector;
}
use of org.eclipse.jetty.server.SecureRequestCustomizer in project jetty.project by eclipse.
the class DirectHTTP2OverTLSTest method startServer.
private void startServer(Handler handler) throws Exception {
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
server = new Server(serverThreads);
HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);
ConnectionFactory ssl = new SslConnectionFactory(newSslContextFactory(), h2.getProtocol());
connector = new ServerConnector(server, 1, 1, ssl, h2);
server.addConnector(connector);
server.setHandler(handler);
server.start();
}
use of org.eclipse.jetty.server.SecureRequestCustomizer in project Openfire by igniterealtime.
the class HttpBindManager method createSSLConnector.
private void createSSLConnector(int securePort) {
httpsConnector = null;
try {
final IdentityStore identityStore = XMPPServer.getInstance().getCertificateStoreManager().getIdentityStore(ConnectionType.BOSH_C2S);
if (securePort > 0 && identityStore.getStore().aliases().hasMoreElements()) {
if (!identityStore.containsDomainCertificate("RSA")) {
Log.warn("HTTP binding: Using RSA certificates but they are not valid for " + "the hosted domain");
}
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
final ConnectionConfiguration configuration = connectionManager.getListener(ConnectionType.BOSH_C2S, true).generateConnectionConfiguration();
final SslContextFactory sslContextFactory = new EncryptionArtifactFactory(configuration).getSslContextFactory();
final HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.setSecureScheme("https");
httpsConfig.setSecurePort(securePort);
configureProxiedConnector(httpsConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
final ServerConnector sslConnector;
if ("npn".equals(JiveGlobals.getXMLProperty("spdy.protocol", ""))) {
sslConnector = new HTTPSPDYServerConnector(httpBindServer, sslContextFactory);
} else {
sslConnector = new ServerConnector(httpBindServer, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
}
sslConnector.setHost(getBindInterface());
sslConnector.setPort(securePort);
httpsConnector = sslConnector;
}
} catch (Exception e) {
Log.error("Error creating SSL connector for Http bind", e);
}
}
use of org.eclipse.jetty.server.SecureRequestCustomizer in project jetty.project by eclipse.
the class Http2Server method main.
public static void main(String... args) throws Exception {
Server server = new Server();
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
context.setResourceBase("src/main/resources/docroot");
context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
// context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
context.addFilter(PushedTilesFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
context.addServlet(new ServletHolder(servlet), "/test/*");
context.addServlet(DefaultServlet.class, "/").setInitParameter("maxCacheSize", "81920");
server.setHandler(context);
// HTTP Configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setSendXPoweredBy(true);
http_config.setSendServerVersion(true);
// HTTP Connector
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config), new HTTP2CServerConnectionFactory(http_config));
http.setPort(8080);
server.addConnector(http);
// SSL Context Factory for HTTPS and HTTP/2
String jetty_distro = System.getProperty("jetty.distro", "../../jetty-distribution/target/distribution");
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(jetty_distro + "/demo-base/etc/keystore");
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
// HTTPS Configuration
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
// HTTP/2 Connection Factory
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(https_config);
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
alpn.setDefaultProtocol(http.getDefaultProtocol());
// SSL Connection Factory
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());
// HTTP/2 Connector
ServerConnector http2Connector = new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(https_config));
http2Connector.setPort(8443);
server.addConnector(http2Connector);
ALPN.debug = false;
server.start();
//server.dumpStdErr();
server.join();
}
Aggregations