示例#1
0
  public void run() {
    CConn cc = null;
    Socket sock = null;
    if (listenMode.getValue()) {
      int port = 5500;
      ServerSocket listener = null;
      if (vncServerName.getValue() != null && Character.isDigit(vncServerName.getValue().charAt(0)))
        port = Integer.parseInt(vncServerName.getValue());

      try {
        listener = new ServerSocket(port);
      } catch (IOException e) {
        System.out.println("Could not listen on port: " + port);
        System.exit(-1);
      }

      vlog.info("Listening on port " + port);

      try {
        sock = listener.accept();
        listener.close();
      } catch (IOException e) {
        System.out.println("Accept failed: " + port);
        System.exit(-1);
      }
    }
    try {
      cc = new CConn(this, sock, vncServerName.getValue(), false);
      while (true) cc.processMsg();
    } catch (EndOfStream e) {
      vlog.info(e.toString());
    } catch (java.lang.Exception e) {
      if (cc != null) cc.deleteWindow();
      if (cc == null || !cc.shuttingDown) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(
            null, e.toString(), "VNC Viewer : Error", JOptionPane.ERROR_MESSAGE);
      }
    }
    if (cc != null) cc.deleteWindow();
    nViewers--;
    if (!applet && nViewers == 0) {
      System.exit(0);
    }
  }
示例#2
0
 public void checkServerTrusted(X509Certificate[] chain, String authType)
     throws CertificateException {
   try {
     tm.checkServerTrusted(chain, authType);
   } catch (CertificateException e) {
     Object[] answer = {"Proceed", "Exit"};
     int ret =
         JOptionPane.showOptionDialog(
             null,
             e.getCause().getLocalizedMessage() + "\n" + "Continue connecting to this host?",
             "Confirm certificate exception?",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             answer,
             answer[0]);
     if (ret == JOptionPane.NO_OPTION) System.exit(1);
   } catch (java.lang.Exception e) {
     throw new Exception(e.toString());
   }
 }
示例#3
0
  public boolean processMsg(CConnection cc) {
    is = (FdInStream) cc.getInStream();
    os = (FdOutStream) cc.getOutStream();
    client = cc;

    initGlobal();

    if (session == null) {
      if (!is.checkNoWait(1)) return false;

      if (is.readU8() == 0) {
        int result = is.readU32();
        String reason;
        if (result == Security.secResultFailed || result == Security.secResultTooMany)
          reason = is.readString();
        else reason = new String("Authentication failure (protocol error)");
        throw new AuthFailureException(reason);
      }

      setParam();
    }

    try {
      manager = new SSLEngineManager(engine, is, os);
    } catch (java.lang.Exception e) {
      throw new Exception(e.toString());
    }

    try {
      manager.doHandshake();
    } catch (java.lang.Exception e) {
      throw new Exception(e.toString());
    }

    // checkSession();

    cc.setStreams(new TLSInStream(is, manager), new TLSOutStream(os, manager));
    return true;
  }