use of org.eclipse.jetty.server.HttpConfiguration 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.HttpConfiguration in project killbill by killbill.
the class HttpServer method configure.
public void configure(final HttpServerConfig config, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders) {
server.setStopAtShutdown(true);
// Setup JMX
configureJMX(ManagementFactory.getPlatformMBeanServer());
// HTTP Configuration
final HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSecurePort(config.getServerSslPort());
// Configure main connector
final ServerConnector http = configureMainConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerHost(), config.getServerPort());
// Configure SSL, if enabled
final ServerConnector https;
if (config.isSSLEnabled()) {
https = configureSslConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerSslPort(), config.getSSLkeystoreLocation(), config.getSSLkeystorePassword());
server.setConnectors(new Connector[] { http, https });
} else {
server.setConnectors(new Connector[] { http });
}
// Configure the thread pool
configureThreadPool(config);
// Configure handlers
final HandlerCollection handlers = new HandlerCollection();
final ServletContextHandler servletContextHandler = createServletContextHandler(config.getResourceBase(), eventListeners, filterHolders);
handlers.addHandler(servletContextHandler);
final RequestLogHandler logHandler = createLogHandler(config);
handlers.addHandler(logHandler);
final HandlerList rootHandlers = new HandlerList();
rootHandlers.addHandler(handlers);
server.setHandler(rootHandlers);
}
use of org.eclipse.jetty.server.HttpConfiguration in project rest.li by linkedin.
the class HttpJettyServer method getConnectors.
protected Connector[] getConnectors(Server server) {
HttpConfiguration configuration = new HttpConfiguration();
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616));
connector.setPort(_port);
return new Connector[] { connector };
}
use of org.eclipse.jetty.server.HttpConfiguration in project camel by apache.
the class CxfPayloadRouterContentLengthTest method setUp.
@Before
public void setUp() throws Exception {
/*
* We start a Jetty for the service in order to have better control over
* the response The response must contain only a Content-Type and a
* Content-Length but no other header
*/
log.info("Starting jetty server at port {}", JETTY_PORT);
server = new Server();
// Do not send a Server header
HttpConfiguration httpconf = new HttpConfiguration();
httpconf.setSendServerVersion(false);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpconf));
http.setPort(JETTY_PORT);
server.addConnector(http);
server.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/xml");
// the Content-Length is correct for this response message
response.setContentLength(RESPONSE_MESSAGE.length());
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
PrintWriter pw = response.getWriter();
pw.write(RESPONSE_MESSAGE);
pw.close();
}
});
server.start();
// Load the CXF endpoints for the route
log.info("Start Routing Scenario at port {}", CXFTestSupport.getPort1());
applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfPayloadRouterContentLengthBeans.xml");
super.setUp();
assertNotNull("Should have created a valid spring context", applicationContext);
}
use of org.eclipse.jetty.server.HttpConfiguration in project sonarqube by SonarSource.
the class SSLTest method startSSLTransparentReverseProxy.
public static void startSSLTransparentReverseProxy(boolean requireClientAuth) throws Exception {
int httpPort = NetworkUtils.getNextAvailablePort();
httpsPort = NetworkUtils.getNextAvailablePort();
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
server = new Server(threadPool);
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(httpsPort);
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// Handler Structure
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { proxyHandler(), new DefaultHandler() });
server.setHandler(handlers);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(httpPort);
server.addConnector(http);
Path serverKeyStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/serverkeystore.jks").toURI()).toAbsolutePath();
String keyStorePassword = "serverkeystorepwd";
String serverKeyPassword = "serverp12pwd";
Path serverTrustStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/servertruststore.jks").toURI()).toAbsolutePath();
String trustStorePassword = "servertruststorepwd";
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(serverKeyStore.toString());
sslContextFactory.setKeyStorePassword(keyStorePassword);
sslContextFactory.setKeyManagerPassword(serverKeyPassword);
sslContextFactory.setTrustStorePath(serverTrustStore.toString());
sslContextFactory.setTrustStorePassword(trustStorePassword);
sslContextFactory.setNeedClientAuth(requireClientAuth);
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
// SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);
server.start();
}
Aggregations