code: public static SSLEngine createEngine(final boolean clientMode) {
          if (context == null) {
              context = createContext();
          }
          SSLEngine engine = context.createSSLEngine();
          engine.setUseClientMode(clientMode);
          return engine;
      }
docs: Creates a new engine for TLS communication in client or server mode.
  
  @param clientMode if <code>true</code> a client engine is created, if <code>false</code> a server engine.
  @return The new engine