+ } catch (Exception e) { Log.error(Main.class, e); }
+ }
+ }
+
+ public void accept(Connection conn) {
+ try {
+ if (conn.getLocalPort() == 143) new IMAP.Listener(auth).handleRequest(conn);
+ else if (conn.getLocalPort() == 993) new IMAP.Listener(auth).handleRequest(conn);
+ else if (conn.getLocalPort() == 119) new NNTP.Listener(auth).handleRequest(conn);
+ else if (conn.getLocalPort() == 563) new NNTP.Listener(auth).handleRequest(conn);
+ else if (conn.getLocalPort() == 25) new SMTP.Server().handleRequest(conn);
+ else if (conn.getLocalPort() == 8025) SMTP.whitelist.handleRequest(conn);
+ //else if (conn.getLocalPort() == 110) new POP3.Listener(auth).handleRequest(conn);
+ //else if (conn.getLocalPort() == 995) new POP3.Listener(auth).handleRequest(conn);
+ //else if (conn.getLocalPort() == 8099) GMail.handleRequest(conn);
+ } catch (Stream.Closed c) {
+ Log.error(this, "connection abruptly closed by client");
+ } catch (IOException e) {
+ Log.error(this, e);
+ } finally {
+ conn.close();
+ }
+ }
+
+ private static final Auth auth = new Auth();
+ private static class Auth implements Login {
+ private KerberosAuth ka = new KerberosAuth("MEGACZ.COM", "godel.megacz.com");
+ public Account anonymous() {
+ try {
+ final Mailbox root =
+ FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT + "/list", false);
+ if (root==null) return null;
+ return new Account("anonymous", null, root){
+ public Mailbox getMailbox(Class protocol) {
+ return super.getMailbox(protocol);
+ }
+ };
+ } catch (Exception e) { throw new RuntimeException(e); }
+ }
+ public Object login(String user, String pass, Class protocol) { return login(user, pass); }
+ public Account login(String user, String pass) {
+ if (!EtcPasswd.verify(user, pass)) return null;
+
+ // currently broken, but should be used
+ //if (!ka.auth(user, pass)) return null;
+
+ final Mailbox root =
+ FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT + "/user", true);
+ return new Account(user, null, root.slash(user, true)){
+ public Mailbox getMailbox(Class protocol) {
+ return super.getMailbox(protocol);
+ }
+ };