title: using grizzly with tls in java
body: <p>i want to use a communication over tls. the tls handshake works, after that, the server side should start a http server and communicate with the http client. 
  im using the grizzly webserver, but i have no idea how to use the tls secured connection i build up. with the GrizzlyServerFactory i can create a HTTP Server with a given SSLEngineConfigurator, but how to use that the SSLSocket of my tls connection? or is there another webserver, which is easier to use that socket?(i neeed the http server for rest services)</p>
  
  <p>any ideas?
  thanks in advance!</p>
  
  <p>Serverside:</p>
  
  <pre><code>public class SSLServerThread extends Thread implements HandshakeCompletedListener {
      private int portNumber; 
      private SSLServerSocket server;
      private SSLSocket client;
  
      public SSLServerThread(int portNumber) {
          this.portNumber = portNumber;
      }   
      public void run() {
          try {
              server = getServer(); // returns the SSLServerSocket
  
              while(true) {
  
                  client = (SSLSocket) server.accept();
                  client.addHandshakeCompletedListener(this);
                  client.startHandshake();
              }
            } catch(Exception e) {
                e.printStackTrace();
            } 
      }
  
      private SSLServerSocket getServer() {
      [..]
      }
  
      public void handshakeCompleted(HandshakeCompletedEvent arg0) {
      }
  }
  </code></pre>
  
  <p>Clientside: </p>
  
  <pre><code>public class SSLClientThread extends Thread implements HandshakeCompletedListener {
      protected int portNumber;   
      protected SSLSocket client;
  
      public SSLClientThread(int portNumber) {
          this.portNumber = portNumber;
      }
  
      public void run() { 
          try {
              client = getSocket();           
              client.addHandshakeCompletedListener(this);
              client.startHandshake();
  
          } catch (Exception e) {
              e.printStackTrace();
          } 
      }
  
      private SSLSocket getSocket() {
          ...
      }
  
      public void handshakeCompleted(HandshakeCompletedEvent event) {
  
       //start http webserver over this tls secured connection
  
      }
  }
  </code></pre>