SK.gnome.dwarf.mail
Class MailHost

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.mail.MailHost
All Implemented Interfaces:
SK.gnome.dwarf.Reportable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service
Direct Known Subclasses:
SMTPHost

public class MailHost
extends SK.gnome.dwarf.GenericServer

Provides a generic mail host.

MailHost may represent a single host name or a subdomain. It provides some necessary features as mail, user data and ACL storage, as well as user authentication, shared by all recipients belonging to the same internet domain.

There are two types of mail hosts - default and virtual. Default mail host is required for each mail server instance. It is always the very first MailHost service added to the server. In addition, one or more virtual hosts may be added to the server to represent other internet domains for which the server will be able to handle mail locally.

Each mail host must have assigned its host identification via setHostId(String) method. It may be either a full host name, a domain name or an IP address, or even a mixed list of these values.

The mapVirtualUser(String) method may be used to map the virtual user name to a name by which the given user is known to the local authentication facility as well as the storage services. It may be overriden to implement a custom mapping mechanism, like a relocation table, for example.


Field Summary
protected  ACLStore aclStore
          The ACL store associated with this host.
protected  java.lang.String hostId
          The host identification.
protected  MailStore mailStore
          The mail store associated with this host.
protected  boolean stripDomain
          Determines the mode of mapping a virtual user to local one.
protected  UserStore userStore
          The user store associated with this host.
 
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
MailHost(java.lang.String name)
          Creates a new MailHost.
 
Method Summary
 void addService(SK.gnome.dwarf.Service service)
          Adds the given service to the server.
 ACLStore getACLStore()
          Returns the ACL store associated with this host.
 java.lang.String getHostId()
          Returns the host identification.
 MailStore getMailStore()
          Returns the mail store associated with this host.
 UserStore getUserStore()
          Returns the user store associated with this host.
 void init(SK.gnome.dwarf.Server parent)
          Initializes the service.
 java.lang.String mapVirtualUser(java.lang.String user)
          Maps the virtual user name to a local user name.
 void setHostId(java.lang.String hostname)
          Sets the host identification.
 void setStripDomain(boolean enable)
          Sets the mode of mapping a virtual user to local one.
static java.lang.String stripDomain(java.lang.String user)
          Strips the user name of the domain part.
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, report, shutdown, start, stop
 
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

hostId

protected java.lang.String hostId
The host identification.

It may be either a hostname, an IP address or a domain name. If a comma-separated list of values is specified, the host will be identified by all of the given strings. An example list of host identification strings may be "host.domain.com, domain.com, 192.168.0.1".

See Also:
getHostId()

stripDomain

protected boolean stripDomain
Determines the mode of mapping a virtual user to local one.

Determines the mode in which the mapVirtualUser(String) method will operate. Default value: true


mailStore

protected MailStore mailStore
The mail store associated with this host.

See Also:
getMailStore()

userStore

protected UserStore userStore
The user store associated with this host.

See Also:
getUserStore()

aclStore

protected ACLStore aclStore
The ACL store associated with this host.

See Also:
getACLStore()
Constructor Detail

MailHost

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

Method Detail

setHostId

public void setHostId(java.lang.String hostname)
Sets the host identification.

It may be either a hostname, an IP address or a domain name. If a comma-separated list of values is specified, the host will be identified by all of the given strings. An example list of host identification string may be "host.domain.com, domain.com, 192.168.0.1".

Parameters:
hostname - host identification string
See Also:
hostId

setStripDomain

public void setStripDomain(boolean enable)
Sets the mode of mapping a virtual user to local one.

Determines the mode in which the mapVirtualUser(String) method will operate.

Parameters:
enable - true to enable stripping the virtual user name of its domain part, false otherwise
See Also:
stripDomain

getHostId

public java.lang.String getHostId()
Returns the host identification.

If the host is identified by more than one string, the whole comma-separated list of identification strings will be returned.

Returns:
the host identification
See Also:
hostId

getMailStore

public MailStore getMailStore()
Returns the mail store associated with this host.

Returns:
the mail store
See Also:
mailStore

getUserStore

public UserStore getUserStore()
Returns the user store associated with this host.

Returns:
the user store
See Also:
userStore

getACLStore

public ACLStore getACLStore()
Returns the ACL store associated with this host.

Returns:
the ACL store
See Also:
aclStore

addService

public void addService(SK.gnome.dwarf.Service service)
                throws SK.gnome.dwarf.ServiceException
Adds the given service to the server.

It initializes also the mailStore, userStore and aclStore member variables to the actual service instances being added to the server.

Throws:
SK.gnome.dwarf.ServiceException

init

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

If the parent server is not an instance of the MailServer class, the IllegalServiceClassException is thrown.

Throws:
SK.gnome.dwarf.ServiceException

mapVirtualUser

public java.lang.String mapVirtualUser(java.lang.String user)
                                throws MailException
Maps the virtual user name to a local user name.

This method maps the virtual user name to a name by which it is known to the local authentication facility as well as the storage services. It returns the user argument stripped of an eventual domain part, if the stripDomain field is set to true. Otherwise, it returns the argument value unchanged.

You may override this method to provide a custom mapping mechanism, like a relocation table, for example.

Parameters:
user - the user identification
Returns:
the mapped user identification
Throws:
MailException - if an error occured

stripDomain

public static java.lang.String stripDomain(java.lang.String user)
Strips the user name of the domain part.

Parameters:
user - the string
Returns:
the string without the domain part


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