org.apache.james.impl.vut
Class AbstractVirtualUserTable

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.impl.vut.AbstractVirtualUserTable
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, DomainList, VirtualUserTableManagement, VirtualUserTable
Direct Known Subclasses:
JDBCVirtualUserTable, XMLVirtualUserTable

public abstract class AbstractVirtualUserTable
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements VirtualUserTable, VirtualUserTableManagement, DomainList, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.configuration.Configurable


Field Summary
 
Fields inherited from interface org.apache.james.api.vut.management.VirtualUserTableManagement
ROLE
 
Fields inherited from interface org.apache.james.api.domainlist.DomainList
ROLE
 
Constructor Summary
AbstractVirtualUserTable()
           
 
Method Summary
 boolean addAddressMapping(java.lang.String user, java.lang.String domain, java.lang.String address)
          Add address mapping
 boolean addAliasDomainMapping(java.lang.String aliasDomain, java.lang.String realDomain)
          Add aliasDomain mapping
 boolean addErrorMapping(java.lang.String user, java.lang.String domain, java.lang.String error)
          Add error mapping
 boolean addMapping(java.lang.String user, java.lang.String domain, java.lang.String mapping)
          Add mapping
protected abstract  boolean addMappingInternal(java.lang.String user, java.lang.String domain, java.lang.String mapping)
          Add new mapping
 boolean addRegexMapping(java.lang.String user, java.lang.String domain, java.lang.String regex)
          Add regex mapping
 void configure(org.apache.avalon.framework.configuration.Configuration arg0)
           
 java.util.Map getAllMappings()
          Return a Map which holds all mappings.
protected abstract  java.util.Map getAllMappingsInternal()
          Return a Map which holds all Mappings
 java.util.List getDomains()
          Return List of domains which should be used as localdomains.
protected abstract  java.util.List getDomainsInternal()
          Return List of all domains for which email should accepted
 java.util.Collection getMappings(java.lang.String user, java.lang.String domain)
          Return the mapped MailAddress for the given address.
 java.util.Collection getMappings(java.lang.String user, java.lang.String domain, int mappingLimit)
           
 java.util.Collection getUserDomainMappings(java.lang.String user, java.lang.String domain)
          Return the explicit mapping stored for the given user and domain.
protected abstract  java.util.Collection getUserDomainMappingsInternal(java.lang.String user, java.lang.String domain)
          Return Collection of all mappings for the given username and domain
protected abstract  java.lang.String mapAddressInternal(java.lang.String user, java.lang.String domain)
          Override to map virtual recipients to real recipients, both local and non-local.
 boolean removeAddressMapping(java.lang.String user, java.lang.String domain, java.lang.String address)
          Remove address mapping
 boolean removeAliasDomainMapping(java.lang.String aliasDomain, java.lang.String realDomain)
          Remove aliasDomain mapping
 boolean removeErrorMapping(java.lang.String user, java.lang.String domain, java.lang.String error)
          Remove error mapping
 boolean removeMapping(java.lang.String user, java.lang.String domain, java.lang.String mapping)
          Remove mapping
protected abstract  boolean removeMappingInternal(java.lang.String user, java.lang.String domain, java.lang.String mapping)
          Remove mapping
 boolean removeRegexMapping(java.lang.String user, java.lang.String domain, java.lang.String regex)
          Remove regex mapping
 void service(org.apache.avalon.framework.service.ServiceManager arg0)
           
 void setAutoDetect(boolean autoDetect)
          Set to true to autodetect the hostname of the host on which james is runnin, and add this to the domain service Default is true
 void setAutoDetectIP(boolean autoDetectIP)
          Set to true to lookup the ipaddresses for each given domain and add these to the domain service Default is true
 void setMappingLimit(int mappingLimit)
          Set the mappingLimit
 void setRecursiveMapping(boolean recursive)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.james.api.domainlist.DomainList
containsDomain
 

Constructor Detail

AbstractVirtualUserTable

public AbstractVirtualUserTable()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager arg0)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration arg0)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

setRecursiveMapping

public void setRecursiveMapping(boolean recursive)

setMappingLimit

public void setMappingLimit(int mappingLimit)
                     throws java.lang.IllegalArgumentException
Set the mappingLimit

Parameters:
mappingLimit - the mappingLimit
Throws:
java.lang.IllegalArgumentException - get thrown if mappingLimit smaller then 1 is used

getMappings

public java.util.Collection getMappings(java.lang.String user,
                                        java.lang.String domain)
                                 throws ErrorMappingException
Description copied from interface: VirtualUserTable
Return the mapped MailAddress for the given address. Return null if no matched mapping was found

Specified by:
getMappings in interface VirtualUserTable
Parameters:
user - the MailAddress
Returns:
the mapped mailAddress
Throws:
ErrorMappingException - get thrown if an error mapping was found
See Also:
VirtualUserTable.getMappings(String, String)

getMappings

public java.util.Collection getMappings(java.lang.String user,
                                        java.lang.String domain,
                                        int mappingLimit)
                                 throws ErrorMappingException
Throws:
ErrorMappingException

addRegexMapping

public boolean addRegexMapping(java.lang.String user,
                               java.lang.String domain,
                               java.lang.String regex)
                        throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Add regex mapping

Specified by:
addRegexMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
regex - the regex.
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.addRegexMapping(java.lang.String, java.lang.String, java.lang.String)

removeRegexMapping

public boolean removeRegexMapping(java.lang.String user,
                                  java.lang.String domain,
                                  java.lang.String regex)
                           throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Remove regex mapping

Specified by:
removeRegexMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
regex - the regex.
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.removeRegexMapping(java.lang.String, java.lang.String, java.lang.String)

addAddressMapping

public boolean addAddressMapping(java.lang.String user,
                                 java.lang.String domain,
                                 java.lang.String address)
                          throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Add address mapping

Specified by:
addAddressMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.addAddressMapping(java.lang.String, java.lang.String, java.lang.String)

removeAddressMapping

public boolean removeAddressMapping(java.lang.String user,
                                    java.lang.String domain,
                                    java.lang.String address)
                             throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Remove address mapping

Specified by:
removeAddressMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.removeAddressMapping(java.lang.String, java.lang.String, java.lang.String)

addErrorMapping

public boolean addErrorMapping(java.lang.String user,
                               java.lang.String domain,
                               java.lang.String error)
                        throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Add error mapping

Specified by:
addErrorMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
error - the regex.
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.addErrorMapping(java.lang.String, java.lang.String, java.lang.String)

removeErrorMapping

public boolean removeErrorMapping(java.lang.String user,
                                  java.lang.String domain,
                                  java.lang.String error)
                           throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Remove error mapping

Specified by:
removeErrorMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
Returns:
true if successfully
Throws:
InvalidMappingException - get thrown if an invalid argument was given
See Also:
VirtualUserTableManagement.removeErrorMapping(java.lang.String, java.lang.String, java.lang.String)

addMapping

public boolean addMapping(java.lang.String user,
                          java.lang.String domain,
                          java.lang.String mapping)
                   throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Add mapping

Specified by:
addMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
mapping - the mapping
Returns:
true if successfully
Throws:
InvalidMappingException
See Also:
VirtualUserTableManagement.addMapping(java.lang.String, java.lang.String, java.lang.String)

removeMapping

public boolean removeMapping(java.lang.String user,
                             java.lang.String domain,
                             java.lang.String mapping)
                      throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Remove mapping

Specified by:
removeMapping in interface VirtualUserTableManagement
Parameters:
user - the username. Null if no username should be used
domain - the domain. Null if no domain should be used
mapping - the mapping
Returns:
true if successfully
Throws:
InvalidMappingException
See Also:
VirtualUserTableManagement.removeMapping(java.lang.String, java.lang.String, java.lang.String)

getAllMappings

public java.util.Map getAllMappings()
Description copied from interface: VirtualUserTableManagement
Return a Map which holds all mappings. The key is the user@domain and the value is a Collection which holds all mappings

Specified by:
getAllMappings in interface VirtualUserTableManagement
Returns:
Map which holds all mappings
See Also:
VirtualUserTableManagement.getAllMappings()

getDomains

public java.util.List getDomains()
Description copied from interface: DomainList
Return List of domains which should be used as localdomains. Return null if no domains were found

Specified by:
getDomains in interface DomainList
Returns:
domains
See Also:
DomainList.getDomains()

getUserDomainMappings

public java.util.Collection getUserDomainMappings(java.lang.String user,
                                                  java.lang.String domain)
Description copied from interface: VirtualUserTableManagement
Return the explicit mapping stored for the given user and domain. Return null if no mapping was found

Specified by:
getUserDomainMappings in interface VirtualUserTableManagement
Parameters:
user - the username
domain - the domain
Returns:
the collection which holds the mappings.
See Also:
VirtualUserTableManagement.getUserDomainMappings(java.lang.String, java.lang.String)

setAutoDetect

public void setAutoDetect(boolean autoDetect)
Description copied from interface: DomainList
Set to true to autodetect the hostname of the host on which james is runnin, and add this to the domain service Default is true

Specified by:
setAutoDetect in interface DomainList
Parameters:
autoDetect - set to false for disable
See Also:
DomainList.setAutoDetect(boolean)

setAutoDetectIP

public void setAutoDetectIP(boolean autoDetectIP)
Description copied from interface: DomainList
Set to true to lookup the ipaddresses for each given domain and add these to the domain service Default is true

Specified by:
setAutoDetectIP in interface DomainList
Parameters:
autoDetectIP - set to false for disable
See Also:
DomainList.setAutoDetectIP(boolean)

addAliasDomainMapping

public boolean addAliasDomainMapping(java.lang.String aliasDomain,
                                     java.lang.String realDomain)
                              throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Add aliasDomain mapping

Specified by:
addAliasDomainMapping in interface VirtualUserTableManagement
Parameters:
aliasDomain - the aliasdomain which should be mapped to the realDomain
realDomain - the realDomain
Returns:
true if successfilly
Throws:
InvalidMappingException
See Also:
VirtualUserTableManagement.addAliasDomainMapping(java.lang.String, java.lang.String)

removeAliasDomainMapping

public boolean removeAliasDomainMapping(java.lang.String aliasDomain,
                                        java.lang.String realDomain)
                                 throws InvalidMappingException
Description copied from interface: VirtualUserTableManagement
Remove aliasDomain mapping

Specified by:
removeAliasDomainMapping in interface VirtualUserTableManagement
Parameters:
aliasDomain - the aliasdomain which should be mapped to the realDomain
realDomain - the realDomain
Returns:
true if successfilly
Throws:
InvalidMappingException
See Also:
VirtualUserTableManagement.removeAliasDomainMapping(java.lang.String, java.lang.String)

addMappingInternal

protected abstract boolean addMappingInternal(java.lang.String user,
                                              java.lang.String domain,
                                              java.lang.String mapping)
                                       throws InvalidMappingException
Add new mapping

Parameters:
user - the user
domain - the domain
mapping - the mapping
Returns:
true if successfully
Throws:
InvalidMappingException

removeMappingInternal

protected abstract boolean removeMappingInternal(java.lang.String user,
                                                 java.lang.String domain,
                                                 java.lang.String mapping)
                                          throws InvalidMappingException
Remove mapping

Parameters:
user - the user
domain - the domain
mapping - the mapping
Returns:
true if successfully
Throws:
InvalidMappingException

getDomainsInternal

protected abstract java.util.List getDomainsInternal()
Return List of all domains for which email should accepted

Returns:
domains the domains

getUserDomainMappingsInternal

protected abstract java.util.Collection getUserDomainMappingsInternal(java.lang.String user,
                                                                      java.lang.String domain)
Return Collection of all mappings for the given username and domain

Parameters:
user - the user
domain - the domain
Returns:
Collection which hold the mappings

getAllMappingsInternal

protected abstract java.util.Map getAllMappingsInternal()
Return a Map which holds all Mappings

Returns:
Map

mapAddressInternal

protected abstract java.lang.String mapAddressInternal(java.lang.String user,
                                                       java.lang.String domain)
Override to map virtual recipients to real recipients, both local and non-local. Each key in the provided map corresponds to a potential virtual recipient, stored as a MailAddress object. Translate virtual recipients to real recipients by mapping a string containing the address of the real recipient as a value to a key. Leave the value null if no mapping should be performed. Multiple recipients may be specified by delineating the mapped string with commas, semi-colons or colons.

Parameters:
user - the mapping of virtual to real recipients, as MailAddresses to Strings.


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.