org.apache.james.transport.mailets
Class JDBCVirtualUserTable
java.lang.Object
|
+--org.apache.mailet.GenericMailet
|
+--org.apache.james.transport.mailets.JDBCVirtualUserTable
- All Implemented Interfaces:
- Mailet, MailetConfig
- public class JDBCVirtualUserTable
- extends GenericMailet
Implements a Virtual User Table for JAMES. Derived from the
JDBCAlias mailet, but whereas that mailet uses a simple map from a
source address to a destination address, this handles simple
wildcard selection, verifies that a catchall address is for a domain
in the Virtual User Table, and handles forwarding.
With JDBCAlias, if the destination address were remote it would be
subject to relay testing, even though it should be treated as a local
address. JDBCVirtualUserTable incorporates JDBCAlias processing for
local destinations, and Forward processing for remote destinations.
To prevent from breaking existing JDBCAlias applications, and to
allow for evolution of this mailet, it is released as a new mailet,
rather than as an update to JDBCAlias. However, anyone using
JDBCAlias should be able to upgrade to JDBCVirtualUserTable.
As with JDBCAlias, JDBCVirtualUserTable does not provide any
administation tools. You'll have to create the VirtualUserTable
yourself. The standard configuration is as follows:
CREATE TABLE VirtualUserTable
(
user varchar(64) NOT NULL default '',
domain varchar(255) NOT NULL default '',
target_address varchar(255) NOT NULL default '',
PRIMARY KEY (user,domain)
);
The standard query used with VirtualUserTable is:
select VirtualUserTable.target_address from VirtualUserTable, VirtualUserTable as VUTDomains
where (VirtualUserTable.user like ? or VirtualUserTable.user like "\%")
and (VirtualUserTable.domain like ?
or (VirtualUserTable.domain like "\%" and VUTDomains.domain like ?))
order by concat(VirtualUserTable.user,'@',VirtualUserTable.domain) desc limit 1
For a given [user, domain, domain] used with the query, this will
match as follows (in precedence order):
1. user@domain - explicit mapping for user@domain
2. user@% - catchall mapping for user anywhere
3. %@domain - catchall mapping for anyone at domain
4. null - no valid mapping
You need to set the connection. At the moment, there is a limit to
what you can change regarding the SQL Query, because there isn't a
means to specify where in the query to replace parameters. [TODO]
<mailet match="All" class="JDBCVirtualUserTable">
<table>db://maildb/VirtualUserTable</table>
<sqlquery>sqlquery</sqlquery>
</mailet>
- Author:
- Noel J. Begman
Field Summary |
protected org.apache.avalon.excalibur.datasource.DataSourceComponent |
datasource
|
protected String |
query
The query used by the mailet to get the alias mapping |
Method Summary |
String |
getMailetInfo()
Returns information about the mailet, such as author, version, and
copyright. |
void |
init()
Initialize the mailet |
void |
service(Mail mail)
Checks the recipient list of the email for user mappings. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
datasource
protected org.apache.avalon.excalibur.datasource.DataSourceComponent datasource
query
protected String query
- The query used by the mailet to get the alias mapping
JDBCVirtualUserTable
public JDBCVirtualUserTable()
init
public void init()
throws MessagingException
- Initialize the mailet
- Overrides:
init
in class GenericMailet
- Throws:
MessagingException
- if an exception occurs that interrupts the mailet's normal operation
service
public void service(Mail mail)
throws MessagingException
- Checks the recipient list of the email for user mappings. Maps recipients as
appropriate, modifying the recipient list of the mail and sends mail to any new
non-local recipients.
- Specified by:
service
in interface Mailet
- Specified by:
service
in class GenericMailet
- Parameters:
mail
- the mail to process
- Throws:
MessagingException
- - if an exception occurs that interferes with the mailet's normal operation
occurred
getMailetInfo
public String getMailetInfo()
- Description copied from class:
GenericMailet
- Returns information about the mailet, such as author, version, and
copyright. By default, this method returns an empty string. Override
this method to have it return a meaningful value.
- Specified by:
getMailetInfo
in interface Mailet
- Overrides:
getMailetInfo
in class GenericMailet
- Returns:
- String information about this mailet, by default an empty string
"Copyright © 1999-2002 Apache Jakarta Project. All Rights Reserved."