コード例 #1
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());
   }
 }
コード例 #2
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;
  }