Beispiel #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);
  }
Beispiel #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();
      }
    }
  }
 public void println(String line) {
   if (log.isDebugEnabled()) {
     log.debug("S: " + line);
   }
   _out.print(line);
   println();
 }
Beispiel #4
0
 void sendGreetings() {
   _conn.println("+OK POP3 GreenMail Server ready");
 }