예제 #1
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;
  }