1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
6 import org.ibex.mail.target.*;
7 import org.ibex.mail.protocol.*;
8 import org.ibex.util.*;
9 import org.ibex.jinetd.*;
10 import org.ibex.jetty.*;
15 import org.ibex.crypto.*;
16 import org.ibex.jetty.*;
18 public class Main implements Listener {
20 public boolean accept(Connection conn) {
22 if (conn.getLocalPort() == 143) new IMAP.Listener(auth).handleRequest(conn);
23 else if (conn.getLocalPort() == 25) new SMTP.Server().handleRequest(conn);
24 else if (conn.getLocalPort() == 8080) new SMTP.Server().handleRequest(conn);
25 else if (conn.getLocalPort() == 119) new NNTP.Listener(auth).handleRequest(conn);
26 //else if (conn.getLocalPort() == 110) new POP3.Listener(auth).handleRequest(conn);
27 //else if (conn.getLocalPort() == 8099) GMail.handleRequest(conn);
35 private static final Auth auth = new Auth();
36 private static class Auth implements Login {
37 public Account anonymous() {
39 FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT + "/user", true).slash("anonymous", false);
40 if (root==null) return null;
41 return new Account("anonymous", null, root.slash("anonymous", true)){
42 public Mailbox getMailbox(Class protocol) {
43 return super.getMailbox(protocol);
47 public Object login(String user, String pass, Class protocol) { return login(user, pass); }
48 public Account login(String user, String pass) {
49 if (!EtcPasswd.verify(user, pass)) return null;
51 FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT + "/user", true);
52 return new Account(user, null, root.slash(user, true)){
53 public Mailbox getMailbox(Class protocol) {
54 return super.getMailbox(protocol);