use of org.eclipse.jetty.server.ssl.SslSelectChannelConnector in project coprhd-controller by CoprHD.
the class StorageApiWebServer method initServer.
private void initServer() {
server = new Server();
// Warn if there are any Ciphers that are not supported
try {
List<String> supportedCipherSuites = Lists.newArrayList(SSLContext.getDefault().getSocketFactory().getSupportedCipherSuites());
for (String chosenCipher : ciphers) {
if (!supportedCipherSuites.contains(chosenCipher)) {
LOG.warn("Cipher Suite Not Supported:" + chosenCipher);
}
}
} catch (NoSuchAlgorithmException e) {
LOG.error("Error checking Cipher Suites", e);
}
SslContextFactory sslFac = new SslContextFactory();
sslFac.setIncludeCipherSuites(ciphers);
sslFac.setKeyStorePath(SystemProperties.resolve(KEYSTORE_PATH));
sslFac.setKeyStorePassword(keystoreKey);
SslSelectChannelConnector connector = new SslSelectChannelConnector(sslFac);
connector.setPort(serviceInfo.getEndpoint().getPort());
server.addConnector(connector);
server.setSendServerVersion(false);
WebAppContext context = new WebAppContext();
context.setContextPath("/api");
context.setWar(SystemProperties.resolve(WAR_PATH));
server.setHandler(context);
}
use of org.eclipse.jetty.server.ssl.SslSelectChannelConnector in project platformlayer by platformlayer.
the class StandaloneXaasWebserver method start.
public boolean start() throws Exception {
LogbackHook.attachToRootLogger();
this.server = new Server();
{
SslContextFactory sslContextFactory = new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH);
{
CertificateAndKey certificateAndKey = encryptionStore.getCertificateAndKey("https");
String secret = KeyStoreUtils.DEFAULT_KEYSTORE_SECRET;
KeyStore keystore = KeyStoreUtils.createEmpty(secret);
String alias = "https";
KeyStoreUtils.put(keystore, alias, certificateAndKey, secret);
sslContextFactory.setKeyStore(keystore);
sslContextFactory.setKeyStorePassword(secret);
sslContextFactory.setCertAlias(alias);
}
// TODO: Preconfigure a better SSLContext??
SSLContext sslContext = SSLContext.getDefault();
sslContextFactory.setIncludeCipherSuites(SslPolicy.DEFAULT.getEngineConfig(sslContext).getEnabledCipherSuites());
sslContextFactory.setIncludeProtocols(SslPolicy.DEFAULT.getEngineConfig(sslContext).getEnabledProtocols());
SslSelectChannelConnector connector = new SslSelectChannelConnector(sslContextFactory);
connector.setPort(PORT);
String host = configuration.lookup("http.host", null);
if (host != null) {
connector.setHost(host);
}
server.setConnectors(new Connector[] { connector });
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
{
ServletContextHandler context = new ServletContextHandler(contexts, "/api");
// context.setContextPath("/");
context.addEventListener(guiceServletConfig);
// Must add DefaultServlet for embedded Jetty
// Failing to do this will cause 404 errors.
context.addServlet(DefaultServlet.class, "/");
FilterHolder filterHolder = new FilterHolder(GuiceFilter.class);
context.addFilter(filterHolder, "*", EnumSet.of(DispatcherType.REQUEST));
context.setClassLoader(Thread.currentThread().getContextClassLoader());
}
for (Entry<String, File> entry : wars.entrySet()) {
String contextPath = entry.getKey();
File war = entry.getValue();
WebAppContext context = new WebAppContext();
context.setWar(war.getAbsolutePath());
context.setContextPath(contextPath);
context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
context.addFilter(GwtCacheHeaderFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
contexts.addHandler(context);
}
server.setHandler(contexts);
server.addLifeCycleListener(new CloseOnFailLifecycleListener());
server.start();
if (!server.isStarted()) {
return false;
}
if (configuration.lookup("jobrunner.enabled", true)) {
scheduler.start();
jobPoller.start();
}
return true;
}
Aggregations