public Pop3Connection(Pop3Handler handler, Socket socket) throws IOException { configureSocket(socket); configureStreams(); this.handler = handler; }
@Override public void execute(Pop3Connection conn, Pop3State state, String cmd) { conn.println("+OK noop rimes with poop"); } }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }
@Override 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) { } finally { try { socket.close(); } catch (IOException ioe) { } } }
@Override public void execute(Pop3Connection conn, Pop3State state, String cmd) { try { String[] args = cmd.split(" "); if (args.length < 2) { conn.println("-ERR Required syntax: USER <username>"); return; } String username = args[1]; state.setUser(state.getUser(username)); conn.println("+OK"); } catch (UserException nsue) { conn.println("-ERR " + nsue); } } }
@Override public void execute(Pop3Connection conn, Pop3State state, String cmd) { try { MailFolder folder = state.getFolder(); if (folder != null) { folder.expunge(); } conn.println("+OK bye see you soon"); conn.quit(); } catch (FolderException me) { conn.println("+OK Signing off, but message deletion failed"); conn.quit(); } } }
@Override public void execute(Pop3Connection conn, Pop3State state, String cmd) { try { MailFolder inbox = state.getFolder(); List<StoredMessage> messages = inbox.getNonDeletedMessages(); long size = sumMessageSizes(messages); conn.println("+OK " + messages.size() + " " + size); } catch (Exception me) { conn.println("-ERR " + me); } }
public void quit() { handler.close(); }
@Override public boolean isValidForState(Pop3State state) { return !state.isAuthenticated(); }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }
@Override public void execute(Pop3Connection conn, Pop3State state, String cmd) { conn.println("-ERR APOP not supported"); /* try { String[] arguments = cmd.split(" "); String username = arguments[1]; state.setUser(state.getUser(username)); conn.send("+OK"); } catch (MailboxException me) { getLogger().warn("APOP exception", me); conn.send("-ERR " + me); } catch (UserException nsue) { getLogger().warn("APOP exception", nsue); conn.send("-ERR " + nsue); } */ } }
@Override public boolean isValidForState(Pop3State state) { return !state.isAuthenticated(); }
void copyLines(BufferedReader in, Pop3Connection conn, int numLines) throws IOException { int count = 0; String line; while ((line = in.readLine()) != null && count < numLines) { conn.println(line); count++; } } }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }
void sendGreetings() { conn.println("+OK POP3 GreenMail Server v" + BuildInfo.INSTANCE.getProjectVersion() + " ready"); }
@Override public boolean isValidForState(Pop3State state) { return !state.isAuthenticated(); }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }
@Override public boolean isValidForState(Pop3State state) { return state.isAuthenticated(); }