syed commented on a change in pull request #2204: [CLOUDSTACK-10025] Adding 
Support for NoVNC Console for KVM
URL: https://github.com/apache/cloudstack/pull/2204#discussion_r131290155
 
 

 ##########
 File path: 
services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxySecureServerFactoryImpl.java
 ##########
 @@ -76,34 +86,83 @@ public void init(byte[] ksBits, String ksPassword) {
     }
 
     @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;
+    public Server createHttpServerInstance(int port) throws IOException {
+        Server server = getServerWithContext(port);
+
+        /**
+         * add all context here
+         **/
+
+        // HTTP Configuration
+        HttpConfiguration http = new HttpConfiguration();
+        http.addCustomizer(new SecureRequestCustomizer());
+
+        // Configuration for HTTPS redirect
+        http.setSecurePort(port);
+        http.setSecureScheme("https");
+        ServerConnector connector = new ServerConnector(server);
+        connector.addConnectionFactory(new HttpConnectionFactory(http));
+        // Setting HTTP port
+        connector.setPort(80);
+
+        // HTTPS configuration
+        HttpConfiguration https = new HttpConfiguration();
+        https.addCustomizer(new SecureRequestCustomizer());
+
+        // Configuring the connector
+        ServerConnector sslConnector = new ServerConnector(server,
+                new SslConnectionFactory(sslContextFactory, "http/1.1"), new 
HttpConnectionFactory(https));
+        sslConnector.setPort(port);
+
+        // Setting HTTP and HTTPS connectors
+        server.setConnectors(new Connector[]{connector, sslConnector});
+        return server;
+    }
+
+    private Server getServerWithContext(int port) {
 
 Review comment:
   Same here, the context will be set in `startHttpMain` for both HTTP and SSL 
connections
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to