final HttpServer server = (scheme.equalsIgnoreCase("http")) ? HttpServer.create(new InetSocketAddress(port), 0) : HttpsServer.create(new InetSocketAddress(port), 0);
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");
/** * 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); } } }
HttpsServer httpsServer = HttpsServer.create ( address, 0 ); SSLContext sslContext = SSLContext.getInstance ( "TLS" );
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);
this.server = HttpsServer.create(getAddress(), 0);
try { if (https) { server = addSSLContext(HttpsServer.create(new InetSocketAddress(serverPort), 0)); // 0 is the default 'backlog' } else { server = HttpServer.create(new InetSocketAddress(serverPort), 0); // 0 is the default 'backlog'
/** * 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; }
@Override public HttpServer createHttpServerInstance(int port) throws IOException { try { HttpsServer server = HttpsServer.create(new InetSocketAddress(port), 5); server.setHttpsConfigurator(new HttpsConfigurator(sslContext) { @Override public void configure(HttpsParameters params) { // get the remote address if needed InetSocketAddress remote = params.getClientAddress(); SSLContext c = getSSLContext(); // get the default parameters SSLParameters sslparams = c.getDefaultSSLParameters(); params.setSSLParameters(sslparams); params.setProtocols(SSLUtils.getRecommendedProtocols()); params.setCipherSuites(SSLUtils.getRecommendedCiphers()); // statement above could throw IAE if any params invalid. // eg. if app has a UI and parameters supplied by a user. } }); s_logger.info("create HTTPS server instance on port: " + port); return server; } catch (Exception ioe) { s_logger.error(ioe.toString(), ioe); } return null; }
private HttpServer createHttpsServer(InetSocketAddress pSocketAddress, JolokiaServerConfig pConfig) { // initialise the HTTPS server try { HttpsServer server = HttpsServer.create(pSocketAddress, pConfig.getBacklog()); SSLContext sslContext = SSLContext.getInstance(pConfig.getSecureSocketProtocol()); // initialise the keystore KeyStore ks = getKeyStore(pConfig); // setup the key manager factory KeyManagerFactory kmf = getKeyManagerFactory(pConfig); kmf.init(ks, pConfig.getKeystorePassword()); // setup the trust manager factory TrustManagerFactory tmf = getTrustManagerFactory(pConfig); tmf.init(ks); // setup the HTTPS context and parameters sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); // Update the config to filter out bad protocols or ciphers pConfig.updateHTTPSSettingsFromContext(sslContext); server.setHttpsConfigurator(new JolokiaHttpsConfigurator(sslContext, pConfig)); return server; } catch (GeneralSecurityException e) { throw new IllegalStateException("Cannot use keystore for https communication: " + e,e); } catch (IOException e) { throw new IllegalStateException("Cannot open keystore for https communication: " + e,e); } }
/** * creates a HttpsServer instance which is initially not bound to any local address/port. * The HttpsServer is acquired from the currently installed {@link HttpServerProvider} * The server must be bound using {@link #bind(InetSocketAddress,int)} before it can be used. * The server must also have a HttpsConfigurator established with {@link #setHttpsConfigurator(HttpsConfigurator)} * @throws IOException */ public static HttpsServer create () throws IOException { return create (null, 0); }
public static HttpsServer createHttps(InetSocketAddress addr, int backlog) throws IOException { HttpsServer httpsServer = HttpsServer.create(addr, backlog); return new DelegatingHttpsServer(httpsServer); }
final HttpServer server = (scheme.equalsIgnoreCase("http")) ? HttpServer.create(new InetSocketAddress(port), 0) : HttpsServer.create(new InetSocketAddress(port), 0);
final HttpServer server = (scheme.equalsIgnoreCase("http")) ? HttpServer.create(new InetSocketAddress(port), 0) : HttpsServer.create(new InetSocketAddress(port), 0);
private static HttpsServer createHttpsServer(int port) throws Exception { generateCertificate(); HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress(port), 0); SSLContext sslContext = getSslContext(); httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); return httpsServer; }
private HttpServer createHttpsServer(InetSocketAddress pSocketAddress, JolokiaServerConfig pConfig) { // initialise the HTTPS server try { HttpsServer server = HttpsServer.create(pSocketAddress, pConfig.getBacklog()); SSLContext sslContext = SSLContext.getInstance(pConfig.getSecureSocketProtocol()); // initialise the keystore KeyStore ks = getKeyStore(pConfig); // setup the key manager factory KeyManagerFactory kmf = getKeyManagerFactory(pConfig); kmf.init(ks, pConfig.getKeystorePassword()); // setup the trust manager factory TrustManagerFactory tmf = getTrustManagerFactory(pConfig); tmf.init(ks); // setup the HTTPS context and parameters sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); // Update the config to filter out bad protocols or ciphers pConfig.updateHTTPSSettingsFromContext(sslContext); server.setHttpsConfigurator(new JolokiaHttpsConfigurator(sslContext, pConfig)); return server; } catch (GeneralSecurityException e) { throw new IllegalStateException("Cannot use keystore for https communication: " + e,e); } catch (IOException e) { throw new IllegalStateException("Cannot open keystore for https communication: " + e,e); } }
httpServer = HttpsServer.create(socketAddress, 0); ((HttpsServer) httpServer).setHttpsConfigurator(httpsConfigurator); } else {
/** * 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); } } }
try { if (https) { server = addSSLContext(HttpsServer.create(new InetSocketAddress(serverPort), 0)); // 0 is the default 'backlog' } else { server = HttpServer.create(new InetSocketAddress(serverPort), 0); // 0 is the default 'backlog'