server = isHttp ? HttpServer.create(new InetSocketAddress(port), 0) : HttpsServer.create(new InetSocketAddress(port), 0); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_CONTAINER_EXCEPTION_IO(), ioe); ((HttpsServer) server).setHttpsConfigurator(httpsConfigurator);
public static HttpsServer startHttpsServer(int port, File keystore, String keypass, HttpHandler handler) throws Exception { HttpsServer httpsServer = HttpsServer.create(address, 0); SSLContext sslContext = SSLContext.getInstance("TLS"); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext) { public void configure(HttpsParameters params) { try { httpsServer.createContext("/", handler); httpsServer.setExecutor(new ThreadPoolExecutor(1, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>())); httpsServer.start(); return httpsServer;
@Override public void stop(final int i) { handler.onServerStop(); delegate.stop(i); }
final HttpServer server = (scheme.equalsIgnoreCase("http")) ? HttpServer.create(new InetSocketAddress(port), 0) : HttpsServer.create(new InetSocketAddress(port), 0);
@Override public void setHttpsConfigurator(final HttpsConfigurator httpsConfigurator) { delegate.setHttpsConfigurator(httpsConfigurator); }
theTrustManagerFactory.init( theKeyStore ); theSSLContext.init( theKeyManagerFactory.getKeyManagers(), theTrustManagerFactory.getTrustManagers(), null ); HttpsServer theHttpsServer = HttpsServer.create( theAddress, aMaxConnections ); theHttpsServer.setHttpsConfigurator( new HttpsRestConfigurator( theSSLContext ) ); theHttpsServer.setExecutor( null ); // creates default executor open( theHttpsServer );
SSLContext ssl = SSLContext.getInstance("TLS"); KeyManagerFactory keyFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore store = KeyStore.getInstance("JKS"); store.load(new FileInputStream(keystoreFile),keyPass.toCharArray()); keyFactory.init(store, keyPass.toCharArray()); TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustFactory.init(store); ssl.init(keyFactory.getKeyManagers(), trustFactory.getTrustManagers(), new SecureRandom()); HttpsConfigurator configurator = new HttpsConfigurator(ssl); HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress(hostname, port), port); httpsServer.setHttpsConfigurator(configurator); HttpContext httpContext = httpsServer.createContext(uri); httpsServer.start(); endpoint.publish(httpContext);
@Override public HttpContext createContext(final String s, final HttpHandler httpHandler) { return delegate.createContext(s, httpHandler); }
@Override public void setExecutor(final Executor executor) { delegate.setExecutor(executor); }
protected HttpsServer createAndStartHttpsServer() throws Exception { HttpsServer httpsServer = ((LiveCasData) getTestData()).createSSLServer(); URL callbackUrl = new URL( GeoServerCasConstants.createProxyCallBackURl(proxyCallbackUrlPrefix.toString())); httpsServer.createContext(callbackUrl.getPath(), new HttpsProxyCallBackHandler()); httpsServer.createContext(createRequest("/j_spring_cas_security_check").getRequestURI(), new SingleSignOutHandler("/j_spring_cas_security_check")); httpsServer.createContext(createRequest("/wms").getRequestURI(), new SingleSignOutHandler( "/wms")); httpsServer.start(); return httpsServer; }
httpsServer.getAddress() ); return httpsServer.createContext( path, handler );
httpsServer.getAddress() ); httpsServer.start();
httpsServer.getAddress(), delay ); httpsServer.stop( delay );
@Override public void start() { delegate.start(); handler.onServerStart(); }
/** * If we have a separate liveness port, start a server on a separate thread pool whose only * job is to watch for when the CoreNLP server becomes ready. * This will also immediately signal liveness. * * @param live The boolean to track when CoreNLP has initialized and the server is ready * to serve requests. */ private void livenessServer(AtomicBoolean live) { if (this.serverPort != this.statusPort) { try { // Create the server if (this.ssl) { server = addSSLContext(HttpsServer.create(new InetSocketAddress(statusPort), 0)); // 0 is the default 'backlog' } else { server = HttpServer.create(new InetSocketAddress(statusPort), 0); // 0 is the default 'backlog' } // Add the two status endpoints withAuth(server.createContext("/live", new LiveHandler()), Optional.empty()); withAuth(server.createContext("/ready", new ReadyHandler(live)), Optional.empty()); // Start the server server.start(); // Server started log("Liveness server started at " + server.getAddress()); } catch (IOException e) { err("Could not start liveness server. This will probably result in very bad things happening soon.", e); } } }
server.setHttpsConfigurator(new HttpsConfigurator(sslContext) { @Override public void configure(HttpsParameters params) {
@Override public HttpContext createContext(final String s) { return delegate.createContext(s); }
@Override public void setExecutor(final Executor executor) { delegate.setExecutor(executor); }
@Override public void start() { delegate.start(); handler.onServerStart(); }
/** * Internal method which creates and starts the server. * * @param httpsMode True if the server to be started is HTTPS, false otherwise. * @return Started server. */ private static GridEmbeddedHttpServer createAndStart(boolean httpsMode) throws Exception { HttpServer httpSrv; InetSocketAddress addrToBind = new InetSocketAddress(HOSTNAME_TO_BIND_SRV, getAvailablePort()); if (httpsMode) { HttpsServer httpsSrv = HttpsServer.create(addrToBind, 0); httpsSrv.setHttpsConfigurator(new HttpsConfigurator(GridTestUtils.sslContext())); httpSrv = httpsSrv; } else httpSrv = HttpServer.create(addrToBind, 0); GridEmbeddedHttpServer embeddedHttpSrv = new GridEmbeddedHttpServer(); embeddedHttpSrv.proto = httpsMode ? "https" : "http"; embeddedHttpSrv.httpSrv = httpSrv; embeddedHttpSrv.httpSrv.start(); return embeddedHttpSrv; }