X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fmail%2FMain.java;h=f3465c80940a7a5405bc4c2a65f9b8493f166fe3;hb=38923f6a8a15d65c022589bd7faf1298c8c387af;hp=6a44fc6a7ce1f439c5ac62c64eee6711f473eaa3;hpb=bbceec5af4b7e228380ca1b574077f5dc88ca3a3;p=org.ibex.mail.git diff --git a/src/org/ibex/mail/Main.java b/src/org/ibex/mail/Main.java index 6a44fc6..f3465c8 100644 --- a/src/org/ibex/mail/Main.java +++ b/src/org/ibex/mail/Main.java @@ -1,8 +1,13 @@ +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + package org.ibex.mail; import org.ibex.mail.target.*; import org.ibex.mail.protocol.*; import org.ibex.util.*; import org.ibex.jinetd.*; +import org.ibex.jetty.*; import org.ibex.io.*; import java.io.*; import java.net.*; @@ -12,12 +17,51 @@ import org.ibex.crypto.*; public class Main implements Listener { public void accept(Connection conn) { - Log.error(this, "connection port is " + conn.getLocalPort()); - if (conn.getLocalPort() == 25) { new SMTP.Server().handleRequest(conn); - } else if (conn.getLocalPort() == 143) { new IMAP.Listener().handleRequest(conn); - } else if (conn.getLocalPort() == 119) { new NNTP.Listener().handleRequest(conn); + try { + if (conn.getLocalPort() == 143) new IMAP.Listener(auth).handleRequest(conn); + else if (conn.getLocalPort() == 25) new SMTP.Server().handleRequest(conn); + else if (conn.getLocalPort() == 119) new NNTP.Listener(auth).handleRequest(conn); + else if (conn.getLocalPort() == 8099) GMail.handleRequest(conn); + else if (conn.getLocalPort() == 8080) Jetty.instance().accept(conn); + else if (conn.getLocalPort() == 80) Jetty.instance().accept(conn); + } finally { + conn.close(); + } + } + + private static final Auth auth = new Auth(); + private static class Auth implements Login { + public Account anonymous() { return null; } + public Object login(String user, String pass, Class protocol) { + //if (protocol == IMAP.class && user.endsWith("@gmail.com")) return GMail.getGMail(user, pass).getIMAP(); + return login(user, pass); + } + public Account login(String user, String pass) { + //if (user.indexOf("@gmail.com") != -1) return GMail.getGMail(user, pass); + if (!EtcPasswd.verify(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) { + /* + if (protocol == NNTP.class) { + final Mailbox arch = new MailmanArchives(); + return new Mailbox.Default() { + public void add(Message m) { throw new RuntimeException("not supported"); } + public void add(Message m, int i) { throw new RuntimeException("not supported"); } + public int uidValidity() { return 1; } + public Mailbox.Iterator iterator() { return null; } + public int uidNext() { return 0; } + public String[] children() { return new String[] { "us" }; } + public Mailbox slash(String name, boolean create) { return arch; } + }; + } else { + */ + return super.getMailbox(protocol); + //} + } + }; } - conn.close(); } }