NNTP support
[org.ibex.mail.git] / src / org / ibex / mail / Main.java
1 package org.ibex.mail;
2 import org.ibex.mail.target.*;
3 import org.ibex.mail.protocol.*;
4 import org.ibex.util.*;
5 import org.ibex.jinetd.*;
6 import org.ibex.io.*;
7 import java.io.*;
8 import java.net.*;
9 import java.util.*;
10
11 public class Main implements Listener {
12
13     public void accept(Connection conn) {
14         Log.error(this, "connection port is " + conn.getLocalPort());
15         if (conn.getLocalPort() == 25) {         new SMTP.Server().handleRequest(conn);
16         } else if (conn.getLocalPort() == 143) { new IMAP.Listener().handleRequest(conn);
17         } else if (conn.getLocalPort() == 119) { new NNTP.Listener().handleRequest(conn);
18         }
19         conn.close();
20     }
21
22     public static class BogusAuthenticator implements IMAP.Server.Authenticator {
23         final Mailbox root =
24             FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true).slash("user", true).slash("megacz", true);
25         public Mailbox authenticate(String u, String p) {
26             if (u.equals("megacz") && p.equals("pass")) return root;
27             return null;
28         }
29     }
30
31 }