package examples.ssl;

import com.vtence.molecule.WebServer;

import java.io.IOException;
import java.security.GeneralSecurityException;

import static com.vtence.molecule.testing.ResourceLocator.locateOnClasspath;

public class SSLExample {

    public void run(WebServer server) throws IOException, GeneralSecurityException {
        // To generate a self-signed certificate using an 2048 bits RSA key pair, use the following command:
        // keytool -genkey -keyalg RSA -alias <key alias> -keystore <keystore file> -storepass <store password> -keysize 2048
        server.enableSSL(locateOnClasspath("ssl/keystore"), "password", "password")
              .start((request, response) -> response.done("You are on a secure channel"));
    }

    public static void main(String[] args) throws IOException, GeneralSecurityException {
        SSLExample example = new SSLExample();
        // Run the default web server on port 8443
        WebServer webServer = WebServer.create(8443);
        example.run(webServer);
        System.out.println("Access at " + webServer.uri());
    }
}
@@ -55,16 +55,37 @@
 erver;%0A%0A
+import java.io.File;%0A
 import j
@@ -234,130 +234,173 @@
 h;%0A%0A
-public class SSLExample %7B%0A%0A    public void run(WebServer server) throws IOException, GeneralSecurityException %7B%0A        //
+/**%0A * %3Cp%3E%0A * In this example we show how to create an start an HTTPS server. We use a JKS keystore that contains our self-signed%0A * certificate.%0A * %3C/p%3E%0A * %3Cp%3E%0A *  
  To 
@@ -408,17 +408,19 @@
 enerate 
-a
+the
  self-si
@@ -495,28 +495,31 @@
 command:
-%0A        // 
+ %3Cbr%3E%0A * %3Ccode%3E
 keytool 
@@ -546,16 +546,18 @@
 -alias %3C
+i%3E
 key alia
@@ -557,16 +557,19 @@
 ey alias
+%3C/i
 %3E -keyst
@@ -573,16 +573,18 @@
 ystore %3C
+i%3E
 keystore
@@ -588,17 +588,23 @@
 ore file
-%3E
+%3C/i%3E%0A *
  -storep
@@ -608,16 +608,18 @@
 repass %3C
+i%3E
 store pa
@@ -624,16 +624,19 @@
 password
+%3C/i
 %3E -keysi
@@ -646,92 +646,655 @@
 2048
-%0A        server.enableSSL(locateOnClasspath(%22ssl/keystore%22), %22password%22, %22password%22)
+%3C/code%3E%0A * %3C/p%3E%0A */%0Apublic class SSLExample %7B%0A%0A    public void run(WebServer server) throws IOException, GeneralSecurityException %7B%0A        // That's our JKS keystore containing our certificate%0A        File keyStore = locateOnClasspath(%22ssl/keystore%22);%0A        // The password to open the keystore%0A        String keyStorePassword = %22password%22;%0A        // The password to use the key%0A        String keyPassword = %22password%22;%0A%0A        // We enable TLS with our key store file and passwords%0A        server.enableSSL(keyStore, keyStorePassword, keyPassword)%0A              // We a render a simple text to let our user know he/she is on a secure channel
 %0A   
@@ -1729,8 +1729,9 @@
 %0A    %7D%0A%7D
+%0A

Add javadoc to the ssl example