SK.gnome.dwarf.mail
Class MailServer

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.thread.ThreadServer
              extended bySK.gnome.dwarf.thread.MultiThreadServer
                  extended bySK.gnome.dwarf.tcpip.TCPIPServer
                      extended bySK.gnome.dwarf.mail.MailServer
All Implemented Interfaces:
SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service
Direct Known Subclasses:
IMAPServer, POPServer, SMTPServer

public abstract class MailServer
extends SK.gnome.dwarf.tcpip.TCPIPServer

Provides a generic mail server.

This is a base class for all mail servers. It extends the generic multithreaded TCP/IP server and provides a container for MailHost objects. Each server must contain at least one mail host, which is regarded as default. It may also contain one or more additional virtual mail hosts for each internet domain it will handle mail for.

The getMailHostByUser(String) method may be used to obtain the correct MailHost object for the particular user. A user is identified by its name with optional domain part after the '@' character. Such user name with the domain part present may refer to a particular virtual host rather than the default mail host. User names without the domain part are always served by the default MailHost.

The getMailStore(String), getUserStore(String) and getACLStore(String) utility methods may be used to obtain the desired storage service for the particular user name by the same process as above.


Field Summary
protected  java.util.Map hosts
          Mapping between host identification strings and MailHost objects.
 
Fields inherited from class SK.gnome.dwarf.tcpip.TCPIPServer
sslContext
 
Fields inherited from class SK.gnome.dwarf.thread.MultiThreadServer
counter
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadServer
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
MailServer(java.lang.String name)
          Creates a new MailServer.
 
Method Summary
 void addService(SK.gnome.dwarf.Service service)
           
 ACLStore getACLStore(java.lang.String user)
          Returns the ACL store for the given user.
 MailHost getMailHost(java.lang.String id)
          Returns the MailHost object referenced by the given identification string.
 MailHost getMailHostByUser(java.lang.String user)
          Returns a MailHost object for the given user.
 MailStore getMailStore(java.lang.String user)
          Returns the mail store for the given user.
 UserStore getUserStore(java.lang.String user)
          Returns the user store for the given user.
 void init(SK.gnome.dwarf.Server parent)
          Initializes the service.
 
Methods inherited from class SK.gnome.dwarf.tcpip.TCPIPServer
createSSLServerSocket, createSSLServerSocket, createSSLSocket, enqueue, finish, getRequestReadTimeout, getTCPRequest, isBlocking, isSSLConfigured, loop, report, setKeyPwd, setKeyStorePwd, setKeyStoreURL, setRegistrationQueueSize, setRequestClass, setSSLProtocol, shutdown, start
 
Methods inherited from class SK.gnome.dwarf.thread.MultiThreadServer
dequeue, enableThread, getHandlerTimeout, setHandlerClass, setHandlerTimeout, setMaxHandlers, setMinHandlers, setQueueSize, setSingleRequest, wakeUpHandlers
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadServer
finish, run, setDaemon, stop
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Field Detail

hosts

protected java.util.Map hosts
Mapping between host identification strings and MailHost objects. The identification strings may be either hostnames, domain names or IP addresses. A single MailHost instance may be even mapped by more then one key if its getHostId() method returns a comma-separated list of identification strings instead of a single value.

Constructor Detail

MailServer

public MailServer(java.lang.String name)
Creates a new MailServer.

Method Detail

addService

public void addService(SK.gnome.dwarf.Service service)
                throws SK.gnome.dwarf.ServiceException
Throws:
SK.gnome.dwarf.ServiceException

init

public void init(SK.gnome.dwarf.Server parent)
          throws SK.gnome.dwarf.ServiceException
Initializes the service.

It throws a ServiceException if no default MailHost instance is found or no mail store service is provided by it.

Throws:
SK.gnome.dwarf.ServiceException

getMailHost

public MailHost getMailHost(java.lang.String id)
Returns the MailHost object referenced by the given identification string.

The host identification string can be either a hostname, domain name or an IP address. If no MailHost instance can be found for the given id, a null value is returned.

Parameters:
id - the host identification string
Returns:
the MailHost instance or null if not found

getMailHostByUser

public MailHost getMailHostByUser(java.lang.String user)
                           throws MailException
Returns a MailHost object for the given user.

If the user argument contains the '@' character with a domain part after it, this method returns a MailHost instance for the given domain, otherwise it returns the default mail host instance. A MailException is thrown when no mail host can be found in either case.

Parameters:
user - the user identification
Returns:
the mail host instance
Throws:
MailException - if a mail host could not be found for the given user

getMailStore

public MailStore getMailStore(java.lang.String user)
                       throws MailException
Returns the mail store for the given user.

It returns a MailStore object associated either with the MailHost obtained from getMailHostByUser(String) method, or with the default mail host.

Parameters:
user - the user identiciation
Returns:
the mail store for the given host or null if not available
Throws:
MailException

getUserStore

public UserStore getUserStore(java.lang.String user)
                       throws MailException
Returns the user store for the given user.

It returns a UserStore object associated either with the MailHost obtained from getMailHostByUser(String) method, or with the default mail host.

Parameters:
user - the user identiciation
Returns:
the user store for the given host or null if not available
Throws:
MailException

getACLStore

public ACLStore getACLStore(java.lang.String user)
                     throws MailException
Returns the ACL store for the given user.

It returns an ACLStore object associated either with the MailHost obtained from getMailHostByUser(String) method, or with the default mail host.

Parameters:
user - the user identiciation
Returns:
the ACL store for the given host or null if not available
Throws:
MailException


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.