Пример #1
0
  void handleCommand() throws IOException {
    _currentLine = _conn.readLine();

    if (_currentLine == null) {
      quit();

      return;
    }

    String commandName = new StringTokenizer(_currentLine, " ").nextToken().toUpperCase();

    Pop3Command command = _registry.getCommand(commandName);

    if (command == null) {
      _conn.println("-ERR Command not recognized");

      return;
    }

    if (!command.isValidForState(_state)) {
      _conn.println("-ERR Command not valid for this state");

      return;
    }

    command.execute(_conn, _state, _currentLine);
  }
Пример #2
0
  public void run() {
    try {
      _conn = new Pop3Connection(this, _socket);
      _state = new Pop3State(_manager);

      _quitting = false;

      sendGreetings();

      while (!_quitting) {
        handleCommand();
      }

      _conn.close();
    } catch (SocketTimeoutException ste) {
      _conn.println("421 Service shutting down and closing transmission channel");

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        _socket.close();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
  }
Пример #3
0
 void sendGreetings() {
   _conn.println("+OK POP3 GreenMail Server ready");
 }