Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/XMLVirtualUserTable.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.mailets; import java.util.Collection; @@ -32,75 +30,90 @@ import org.apache.james.vut.lib.VirtualU import org.apache.mailet.MailAddress; /** - * Implements a Virtual User Table to translate virtual users - * to real users. This implementation has the same functionality - * as <code>JDBCVirtualUserTable</code>, but is configured in the - * JAMES configuration and is thus probably most suitable for smaller - * and less dynamic mapping requirements. - * + * <p> + * Implements a Virtual User Table to translate virtual users to real users. + * This implementation has the same functionality as + * <code>JDBCVirtualUserTable</code>, but is configured in the JAMES + * configuration and is thus probably most suitable for smaller and less dynamic + * mapping requirements. + * </p> + * <p> * The configuration is specified in the form: * + * <pre> * <mailet match="All" class="XMLVirtualUserTable"> * <mapping>virtualuser@xxx=realuser[@yyy][;anotherrealuser[@zzz]]</mapping> * <mapping>virtualuser2@*=realuser2[@yyy][;anotherrealuser2[@zzz]]</mapping> * ... * </mailet> + * </pre> * + * </p> + * <p> * As many <mapping> elements can be added as necessary. As indicated, - * wildcards are supported, and multiple recipients can be specified with a - * semicolon-separated list. The target domain does not need to be specified if + * wildcards are supported, and multiple recipients can be specified with a + * semicolon-separated list. The target domain does not need to be specified if * the real user is local to the server. - * + * </p> + * <p> * Matching is done in the following 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 + * <ol> + * <li> + * user@domain - explicit mapping for user@domain</li> + * <li> + * user@* - catchall mapping for user anywhere</li> + * <li> + * *@domain - catchall mapping for anyone at domain</li> + * <li> + * null - no valid mapping</li> + * </ol> + * </p> * * @deprecated use the definitions in virtualusertable-store.xml instead * */ @Deprecated -public class XMLVirtualUserTable extends AbstractVirtualUserTable -{ - /** - * Holds the configured mappings - */ - private Map mappings = new HashMap(); - - /** - * Initialize the mailet - */ - public void init() throws MessagingException { - String mapping = getInitParameter("mapping"); - - if(mapping != null) { - mappings = VirtualUserTableUtil.getXMLMappings(mapping); - } - } - - /** - * Map any virtual recipients to real recipients using the configured mapping. - * - * @param recipientsMap the mapping of virtual to real recipients - */ - protected void mapRecipients(Map<MailAddress,String> recipientsMap) throws MessagingException { - Collection<MailAddress> recipients = recipientsMap.keySet(); - - for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext(); ) { - MailAddress source = i.next(); - String user = source.getLocalPart().toLowerCase(); - String domain = source.getDomain().toLowerCase(); - - String targetString = VirtualUserTableUtil.getTargetString(user, domain, mappings); - - if (targetString != null) { - recipientsMap.put(source, targetString); - } - } - } - - public String getMailetInfo() { - return "XML Virtual User Table mailet"; - } +public class XMLVirtualUserTable extends AbstractVirtualUserTable { + /** + * Holds the configured mappings + */ + private Map mappings = new HashMap(); + + /** + * Initialize the mailet + */ + public void init() throws MessagingException { + String mapping = getInitParameter("mapping"); + + if (mapping != null) { + mappings = VirtualUserTableUtil.getXMLMappings(mapping); + } + } + + /** + * Map any virtual recipients to real recipients using the configured + * mapping. + * + * @param recipientsMap + * the mapping of virtual to real recipients + */ + protected void mapRecipients(Map<MailAddress, String> recipientsMap) throws MessagingException { + Collection<MailAddress> recipients = recipientsMap.keySet(); + + for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext();) { + MailAddress source = i.next(); + String user = source.getLocalPart().toLowerCase(); + String domain = source.getDomain().toLowerCase(); + + String targetString = VirtualUserTableUtil.getTargetString(user, domain, mappings); + + if (targetString != null) { + recipientsMap.put(source, targetString); + } + } + } + + public String getMailetInfo() { + return "XML Virtual User Table mailet"; + } }
Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java Mon Apr 4 16:36:42 2011 @@ -29,36 +29,41 @@ import org.apache.james.dnsservice.libra import org.apache.mailet.base.GenericMatcher; /** - * AbstractNetworkMatcher makes writing IP Address matchers easier.<br/> - * <br/> - * This class extends the GenericMatcher, and as such, has access to the - * matcher condition via GenericMatcher.getCondition().<br/> - * On initialization, the init method retrieves the condition from the - * defined matcher and create a corresponding NetMatcher.<br/> - * The marcher condition has to respect the syntax waited by the NetMacher.<br/> - * <br/> - * This abstract network matcher needs to be implemented by a concrete class.<br/> - * The implementing concrete class will call the allowedNetworks or matchNetwork methods. - * - * @see org.apache.james.dnsservice.library.netmatcher.NetMatcher - */ + * <p> + * AbstractNetworkMatcher makes writing IP Address matchers easier. + * </p> + * <p> + * This class extends the GenericMatcher, and as such, has access to the matcher + * condition via GenericMatcher.getCondition().<br> + * On initialization, the init method retrieves the condition from the defined + * matcher and create a corresponding NetMatcher.<br> + * The marcher condition has to respect the syntax waited by the NetMacher. + * </p> + * <p> + * This abstract network matcher needs to be implemented by a concrete class.<br> + * The implementing concrete class will call the allowedNetworks or matchNetwork + * methods. + * </p> + * + * @see org.apache.james.dnsservice.library.netmatcher.NetMatcher + */ public abstract class AbstractNetworkMatcher extends GenericMatcher { /** - * This is a Network Matcher that should be configured to contain - * authorized networks + * This is a Network Matcher that should be configured to contain authorized + * networks */ private NetMatcher authorizedNetworks = null; - + /** * The DNSService */ private DNSService dnsServer; - + public void init() throws MessagingException { - + Collection<String> nets = allowedNetworks(); - + if (nets != null) { authorizedNetworks = new NetMatcher(allowedNetworks(), dnsServer) { protected void log(String s) { @@ -74,7 +79,8 @@ public abstract class AbstractNetworkMat if (getCondition() != null) { StringTokenizer st = new StringTokenizer(getCondition(), ", ", false); networks = new java.util.ArrayList<String>(); - while (st.hasMoreTokens()) networks.add(st.nextToken()); + while (st.hasMoreTokens()) + networks.add(st.nextToken()); } return networks; } @@ -86,15 +92,15 @@ public abstract class AbstractNetworkMat protected boolean matchNetwork(String addr) { return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr); } - + /** * Injection setter for the DNSService. * * @param dnsService */ - @Resource(name="dnsservice") + @Resource(name = "dnsservice") public void setDNSService(DNSService dnsService) { this.dnsServer = dnsService; } - + } Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java Mon Apr 4 16:36:42 2011 @@ -47,54 +47,48 @@ import org.apache.mailet.base.GenericMat public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher { - - /** The user repository for this mail server. Contains all the users with inboxes - * on this server. + /** + * The user repository for this mail server. Contains all the users with + * inboxes on this server. */ private UsersRepository localusers; protected DataSource datasource; - - /** - * Holds value of property sqlFile. - */ + /** Holds value of property sqlFile. */ private File sqlFile; - /** - * Holds value of property sqlParameters. - */ - private Map<String,String> sqlParameters = new HashMap<String,String>(); - + /** Holds value of property sqlParameters. */ + private Map<String, String> sqlParameters = new HashMap<String, String>(); - - @Resource(name="datasource") + @Resource(name = "datasource") public void setDataSource(DataSource datasource) { this.datasource = datasource; } - - @Resource(name="usersrepository") + + @Resource(name = "usersrepository") public void setUsersRepository(UsersRepository localusers) { this.localusers = localusers; } - + /** * Getter for property sqlParameters. + * * @return Value of property sqlParameters. */ - private Map<String,String> getSqlParameters() { + private Map<String, String> getSqlParameters() { return this.sqlParameters; } - + /** * The JDBCUtil helper class */ protected final JDBCUtil theJDBCUtil = new JDBCUtil() { protected void delegatedLog(String logString) { - log(getMatcherName() +": " + logString); + log(getMatcherName() + ": " + logString); } }; - + /** * Contains all of the sql strings for this component. */ @@ -102,11 +96,11 @@ public abstract class AbstractSQLWhiteli private FileSystem fs; - @Resource(name="filesystem") + @Resource(name = "filesystem") public void setFilesystem(FileSystem fs) { this.fs = fs; } - + @Override public void init() throws MessagingException { String repositoryPath = null; @@ -116,21 +110,18 @@ public abstract class AbstractSQLWhiteli } if (repositoryPath != null) { log("repositoryPath: " + repositoryPath); - } - else { + } else { throw new MessagingException("repositoryPath is null"); } - - try { initSqlQueries(datasource.getConnection(), getMailetContext()); } catch (Exception e) { throw new MessagingException("Exception initializing queries", e); - } - + } + super.init(); - } + } public Collection<MailAddress> match(Mail mail) throws MessagingException { // check if it's a local sender @@ -175,10 +166,12 @@ public abstract class AbstractSQLWhiteli return inWhiteList; } - + protected abstract boolean matchedWhitelist(MailAddress recipient, Mail mail) throws MessagingException; - - /** Gets the main name of a local customer, handling alias */ + + /** + * Gets the main name of a local customer, handling alias + */ protected String getPrimaryName(String originalUsername) { String username; try { @@ -187,30 +180,33 @@ public abstract class AbstractSQLWhiteli if (user.getAliasing()) { username = user.getAlias(); } - } - catch (Exception e) { + } catch (Exception e) { username = originalUsername; } return username; } - + /** - * Initializes the sql query environment from the SqlResources file. - * Will look for conf/sqlResources.xml. - * Will <I>not</I> create the database resources, if missing + * Initializes the sql query environment from the SqlResources file.<br> + * Will look for conf/sqlResources.xml.<br> + * Will <strong>not</<strong> create the database resources, if missing<br> * (this task is done, if needed, in the {@link WhiteListManager} * initialization routine). - * @param conn The connection for accessing the database - * @param mailetContext The current mailet context, - * for finding the conf/sqlResources.xml file - * @throws Exception If any error occurs + * + * @param conn + * The connection for accessing the database + * @param mailetContext + * The current mailet context, for finding the + * conf/sqlResources.xml file + * @throws Exception + * If any error occurs */ protected void initSqlQueries(Connection conn, org.apache.mailet.MailetContext mailetContext) throws Exception { try { if (conn.getAutoCommit()) { conn.setAutoCommit(false); } - + this.sqlFile = fs.getFile("classpath:sqlResources.xml"); sqlQueries.init(this.sqlFile, getSQLSectionName(), conn, getSqlParameters()); checkTables(conn); @@ -218,63 +214,55 @@ public abstract class AbstractSQLWhiteli theJDBCUtil.closeJDBCConnection(conn); } } - protected abstract String getTableName(); - + protected abstract String getTableCreateQueryName(); - + private void checkTables(Connection conn) throws SQLException { - // Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo. + // Need to ask in the case that identifiers are stored, ask the + // DatabaseMetaInfo. // Try UPPER, lower, and MixedCase, to see if the table is there. - + boolean dbUpdated = false; - + dbUpdated = createTable(conn, getTableName(), getTableCreateQueryName()); - - //Commit our changes if necessary. + + // Commit our changes if necessary. if (conn != null && dbUpdated && !conn.getAutoCommit()) { conn.commit(); dbUpdated = false; } - + } - + private boolean createTable(Connection conn, String tableNameSqlStringName, String createSqlStringName) throws SQLException { String tableName = sqlQueries.getSqlString(tableNameSqlStringName, true); - + DatabaseMetaData dbMetaData = conn.getMetaData(); // Try UPPER, lower, and MixedCase, to see if the table is there. if (theJDBCUtil.tableExists(dbMetaData, tableName)) { return false; } - + PreparedStatement createStatement = null; - + try { - createStatement = - conn.prepareStatement(sqlQueries.getSqlString(createSqlStringName, true)); + createStatement = conn.prepareStatement(sqlQueries.getSqlString(createSqlStringName, true)); createStatement.execute(); - + StringBuffer logBuffer = null; - logBuffer = - new StringBuffer(64) - .append("Created table '") - .append(tableName) - .append("' using sqlResources string '") - .append(createSqlStringName) - .append("'."); + logBuffer = new StringBuffer(64).append("Created table '").append(tableName).append("' using sqlResources string '").append(createSqlStringName).append("'."); log(logBuffer.toString()); - + } finally { theJDBCUtil.closeJDBCStatement(createStatement); } - + return true; } - - + protected abstract String getSQLSectionName(); } Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.matchers; import java.util.Iterator; @@ -48,46 +46,55 @@ import org.apache.mailet.MailAddress; import org.apache.mailet.MailetContext; /** - * <P>Experimental: Abstract matcher checking whether a recipient has exceeded a maximum allowed - * <I>storage</I> quota for messages standing in his inbox.</P> - * <P>"Storage quota" at this level is still an abstraction whose specific interpretation - * will be done by subclasses (e.g. could be specific for each user or common to all of them).</P> - * - * <P>This matcher need to calculate the mailbox size everytime it is called. This can slow down things if there are many mails in - * the mailbox. Some users also report big problems with the matcher if a JDBC based mailrepository is used. </P> - * - * @version CVS $Revision$ $Date$ + * <p> + * Experimental: Abstract matcher checking whether a recipient has exceeded a + * maximum allowed <I>storage</I> quota for messages standing in his inbox. + * </p> + * <p> + * "Storage quota" at this level is still an abstraction whose specific + * interpretation will be done by subclasses (e.g. could be specific for each + * user or common to all of them). + * </p> + * <p> + * This matcher need to calculate the mailbox size everytime it is called. This + * can slow down things if there are many mails in the mailbox. Some users also + * report big problems with the matcher if a JDBC based mailrepository is used. + * </p> + * * @since 2.2.0 */ -abstract public class AbstractStorageQuota extends AbstractQuotaMatcher { +abstract public class AbstractStorageQuota extends AbstractQuotaMatcher { private MailboxManager manager; - @Resource(name="mailboxmanager") + @Resource(name = "mailboxmanager") public void setMailboxManager(MailboxManager manager) { this.manager = manager; } - - @Resource(name="usersrepository") + + @Resource(name = "usersrepository") public void setUsersRepository(UsersRepository localusers) { this.localusers = localusers; } - /** The user repository for this mail server. Contains all the users with inboxes - * on this server. + + /** + * The user repository for this mail server. Contains all the users with + * inboxes on this server. */ private UsersRepository localusers; private MailetContextLog log; - - /** - * Checks the recipient. - * Does a <CODE>super.isRecipientChecked</CODE> and checks that the recipient - * is a known user in the local server. - * If a subclass overrides this method it should "and" <CODE>super.isRecipientChecked</CODE> - * to its check. - * - * @param recipient the recipient to check - */ + + /** + * Checks the recipient.<br> + * Does a <code>super.isRecipientChecked</code> and checks that the + * recipient is a known user in the local server.<br> + * If a subclass overrides this method it should "and" + * <code>super.isRecipientChecked</code> to its check. + * + * @param recipient + * the recipient to check + */ protected boolean isRecipientChecked(MailAddress recipient) throws MessagingException { MailetContext mailetContext = getMailetContext(); return super.isRecipientChecked(recipient) && (mailetContext.isLocalEmail(recipient)); @@ -96,23 +103,24 @@ abstract public class AbstractStorageQuo @Override public void init() throws MessagingException { super.init(); - + // init the log log = new MailetContextLog(getMailetContext()); } - /** + /** * Gets the storage used in the recipient's inbox. - * - * @param recipient the recipient to check - */ + * + * @param recipient + * the recipient to check + */ protected long getUsed(MailAddress recipient, Mail _) throws MessagingException { long size = 0; MailboxSession session; try { String username; try { - // see if we need use the full email address as username or not. + // see if we need use the full email address as username or not. // See JAMES-1197 if (localusers.supportVirtualHosting()) { username = recipient.toString().toLowerCase(Locale.US); @@ -122,15 +130,15 @@ abstract public class AbstractStorageQuo } catch (UsersRepositoryException e) { throw new MessagingException("Unable to access UsersRepository", e); } - session = manager.createSystemSession(username,log); + session = manager.createSystemSession(username, log); manager.startProcessingRequest(session); - + // get all mailboxes for the user to calculate the size // See JAMES-1198 List<MailboxMetaData> mList = manager.search(new MailboxQuery(MailboxPath.inbox(username), "", session.getPathDelimiter()), session); for (int i = 0; i < mList.size(); i++) { MessageManager mailbox = manager.getMailbox(mList.get(i).getPath(), session); - Iterator<MessageResult> results = mailbox.getMessages(MessageRange.all(), new FetchGroupImpl(FetchGroup.MINIMAL), session); + Iterator<MessageResult> results = mailbox.getMessages(MessageRange.all(), new FetchGroupImpl(FetchGroup.MINIMAL), session); while (results.hasNext()) { size += results.next().getSize(); } @@ -147,5 +155,4 @@ abstract public class AbstractStorageQuo } - } Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/InSpammerBlacklist.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.matchers; import java.net.UnknownHostException; @@ -34,44 +32,48 @@ import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; /** - * Checks the network IP address of the sending server against a - * blacklist of spammers. There are 3 lists that support this... + * Checks the network IP address of the sending server against a blacklist of + * spammers. There are 3 lists that support this... * <ul> - * <li><b>blackholes.mail-abuse.org</b>: Rejected - see http://www.mail-abuse.org/rbl/ - * <li><b>dialups.mail-abuse.org</b>: Dialup - see http://www.mail-abuse.org/dul/ - * <li><b>relays.mail-abuse.org</b>: Open spam relay - see http://www.mail-abuse.org/rss/ + * <li><b>blackholes.mail-abuse.org</b>: Rejected - see + * http://www.mail-abuse.org/rbl/ + * <li><b>dialups.mail-abuse.org</b>: Dialup - see + * http://www.mail-abuse.org/dul/ + * <li><b>relays.mail-abuse.org</b>: Open spam relay - see + * http://www.mail-abuse.org/rss/ * </ul> - * + * * Example: + * + * <pre> * <mailet match="InSpammerBlacklist=blackholes.mail-abuse.org." class="ToProcessor"> * <processor>spam</processor> * </mailet> - * + * </pre> */ public class InSpammerBlacklist extends GenericMatcher { private String network = null; - + private DNSService dnsServer; - - - @Resource(name="dnsservice") + @Resource(name = "dnsservice") public void setDNSService(DNSService dnsService) { this.dnsServer = dnsService; } - + public void init() throws MessagingException { network = getCondition(); - + // check if the needed condition was given - if (network == null) throw new MessagingException("Please configure a blacklist"); + if (network == null) + throw new MessagingException("Please configure a blacklist"); } public Collection<MailAddress> match(Mail mail) { String host = mail.getRemoteAddr(); try { - //Have to reverse the octets first + // Have to reverse the octets first StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(host, " .", false); @@ -79,17 +81,17 @@ public class InSpammerBlacklist extends sb.insert(0, st.nextToken() + "."); } - //Add the network prefix for this blacklist + // Add the network prefix for this blacklist sb.append(network); - //Try to look it up + // Try to look it up dnsServer.getByName(sb.toString()); - //If we got here, that's bad... it means the host - // was found in the blacklist + // If we got here, that's bad... it means the host + // was found in the blacklist return mail.getRecipients(); } catch (UnknownHostException uhe) { - //This is good... it's not on the list + // This is good... it's not on the list return null; } } Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java Mon Apr 4 16:36:42 2011 @@ -31,31 +31,29 @@ import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; /** - * <P> + * <p> * Matches recipients having the mail sender in the recipient's private * whitelist . - * </P> - * <P> + * </p> + * <p> * The recipient name is always converted to its primary name (handling * aliases). - * </P> - * <P> + * </p> + * <p> * Configuration string: The database name containing the white list table. - * </P> - * <P> + * </p> + * <p> * Example: - * </P> * - * <PRE> - * <CODE> - * <mailet match="IsInWhiteList=db://maildb" class="ToProcessor"> - * <processor> transport </processor> - * </mailet> - * </CODE> - * </PRE> + * <pre> + * <mailet match="IsInWhiteList=db://maildb" class="ToProcessor"> + * <processor> transport </processor> + * </mailet> + * </pre> + * + * </p> * * @see org.apache.james.transport.mailets.WhiteListManager - * @version SVN $Revision: $ $Date: $ * @since 2.3.0 */ public class IsInWhiteList extends AbstractSQLWhitelistMatcher { @@ -70,7 +68,9 @@ public class IsInWhiteList extends Abstr /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getSQLSectionName() + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * getSQLSectionName() */ protected String getSQLSectionName() { return "WhiteList"; @@ -78,13 +78,15 @@ public class IsInWhiteList extends Abstr /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#matchedWhitelist(org.apache.mailet.MailAddress, org.apache.mailet.Mail) + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * matchedWhitelist(org.apache.mailet.MailAddress, org.apache.mailet.Mail) */ protected boolean matchedWhitelist(MailAddress recipientMailAddress, Mail mail) throws MessagingException { MailAddress senderMailAddress = mail.getSender(); String senderUser = senderMailAddress.getLocalPart().toLowerCase(Locale.US); String senderHost = senderMailAddress.getDomain().toLowerCase(Locale.US); - + Connection conn = null; PreparedStatement selectStmt = null; ResultSet selectRS = null; @@ -108,11 +110,10 @@ public class IsInWhiteList extends Abstr // This address was already in the list return true; } - - - // check for wildcard domain entries + + // check for wildcard domain entries selectStmt = conn.prepareStatement(selectByPK); - + selectStmt.setString(1, recipientUser); selectStmt.setString(2, recipientHost); selectStmt.setString(3, "*"); @@ -122,11 +123,10 @@ public class IsInWhiteList extends Abstr // This address was already in the list return true; } - - - // check for wildcard recipient domain entries + + // check for wildcard recipient domain entries selectStmt = conn.prepareStatement(selectByPK); - + selectStmt.setString(1, "*"); selectStmt.setString(2, recipientHost); selectStmt.setString(3, senderUser); @@ -136,9 +136,9 @@ public class IsInWhiteList extends Abstr // This address was already in the list return true; } - // check for wildcard domain entries on both + // check for wildcard domain entries on both selectStmt = conn.prepareStatement(selectByPK); - + selectStmt.setString(1, "*"); selectStmt.setString(2, recipientHost); selectStmt.setString(3, "*"); @@ -161,7 +161,9 @@ public class IsInWhiteList extends Abstr /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableCreateQueryName() + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * getTableCreateQueryName() */ protected String getTableCreateQueryName() { return "createWhiteListTable"; @@ -169,7 +171,10 @@ public class IsInWhiteList extends Abstr /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableName() + * + * @see + * org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableName + * () */ protected String getTableName() { return "whiteListTableName"; Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/MailboxQuotaFixed.java Mon Apr 4 16:36:42 2011 @@ -25,19 +25,21 @@ import org.apache.mailet.MailAddress; import org.apache.mailet.Matcher; /** - * Matcher which can be used to set a quota for users Mailbox. This {@link Matcher} need to - * recalculate the used space of users mailbox on every call. So use it with caution! - * - * + * Matcher which can be used to set a quota for users Mailbox. This + * {@link Matcher} need to recalculate the used space of users mailbox on every + * call. So use it with caution! */ public class MailboxQuotaFixed extends AbstractStorageQuota { /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractQuotaMatcher#getQuota(org.apache.mailet.MailAddress, org.apache.mailet.Mail) + * + * @see + * org.apache.james.transport.matchers.AbstractQuotaMatcher#getQuota(org + * .apache.mailet.MailAddress, org.apache.mailet.Mail) */ protected long getQuota(MailAddress arg0, Mail arg1) throws MessagingException { - return parseQuota(this.getCondition()); + return parseQuota(this.getCondition()); } } Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java Mon Apr 4 16:36:42 2011 @@ -35,13 +35,16 @@ import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; /** - * Matcher which lookup whitelisted networks in a database. The networks can be specified via netmask. - * - * For example: - * 192.168.0.0/24 - * + * <p> + * Matcher which lookup whitelisted networks in a database. The networks can be + * specified via netmask. + * </p> + * <p> + * For example: <code>192.168.0.0/24</code> + * </p> + * <p> * Th whitelisting is done per recipient - * + * </p> */ public class NetworkIsInWhitelist extends AbstractSQLWhitelistMatcher { @@ -53,15 +56,16 @@ public class NetworkIsInWhitelist extend * * @param dnsService */ - @Resource(name="dnsservice") + @Resource(name = "dnsservice") public void setDNSService(DNSService dns) { this.dns = dns; } - /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getSQLSectionName() + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * getSQLSectionName() */ protected String getSQLSectionName() { return "NetworkWhiteList"; @@ -74,10 +78,11 @@ public class NetworkIsInWhitelist extend } - /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#matchedWhitelist(org.apache.mailet.MailAddress, org.apache.mailet.Mail) + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * matchedWhitelist(org.apache.mailet.MailAddress, org.apache.mailet.Mail) */ protected boolean matchedWhitelist(MailAddress recipientMailAddress, Mail mail) throws MessagingException { Connection conn = null; @@ -124,22 +129,25 @@ public class NetworkIsInWhitelist extend theJDBCUtil.closeJDBCResultSet(selectRS); theJDBCUtil.closeJDBCStatement(selectStmt); theJDBCUtil.closeJDBCConnection(conn); - } + } } - /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableCreateQueryName() + * + * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher# + * getTableCreateQueryName() */ protected String getTableCreateQueryName() { return "createNetworkWhiteListTable"; } - /* * (non-Javadoc) - * @see org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableName() + * + * @see + * org.apache.james.transport.matchers.AbstractSQLWhitelistMatcher#getTableName + * () */ protected String getTableName() { return "networkWhiteListTableName"; Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrInNetwork.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.matchers; import org.apache.mailet.Mail; @@ -27,12 +25,13 @@ import org.apache.mailet.MailAddress; import java.util.Collection; /** - * Checks the IP address of the sending server against a comma- - * delimited list of IP addresses, domain names or sub-nets. - * - * <p>See AbstractNetworkMatcher for details on how to specify - * entries.</p> - * + * <p> + * Checks the IP address of the sending server against a comma- delimited list + * of IP addresses, domain names or sub-nets. + * </p> + * <p> + * See AbstractNetworkMatcher for details on how to specify entries. + * </p> */ public class RemoteAddrInNetwork extends AbstractNetworkMatcher { public Collection<MailAddress> match(Mail mail) { Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/RemoteAddrNotInNetwork.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.matchers; import org.apache.mailet.Mail; @@ -27,12 +25,13 @@ import org.apache.mailet.MailAddress; import java.util.Collection; /** - * Checks the IP address of the sending server against a comma- - * delimited list of IP addresses, domain names or sub-nets. - * - * <p>See AbstractNetworkMatcher for details on how to specify - * entries.</p> - * + * <p> + * Checks the IP address of the sending server against a comma- delimited list + * of IP addresses, domain names or sub-nets. + * </p> + * <p> + * See AbstractNetworkMatcher for details on how to specify entries. + * </p> */ public class RemoteAddrNotInNetwork extends AbstractNetworkMatcher { public Collection<MailAddress> match(Mail mail) { Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java Mon Apr 4 16:36:42 2011 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.transport.matchers; import org.apache.mailet.Mail; @@ -27,10 +25,8 @@ import org.apache.mailet.MailAddress; import java.util.Collection; /** - * Does a DNS lookup (MX and A/CNAME records) on the sender's domain. If - * there are no entries, the domain is considered fake and the match is - * successful. - * + * Does a DNS lookup (MX and A/CNAME records) on the sender's domain. If there + * are no entries, the domain is considered fake and the match is successful. */ public class SenderInFakeDomain extends AbstractNetworkMatcher { @@ -39,13 +35,14 @@ public class SenderInFakeDomain extends return null; } String domain = mail.getSender().getDomain(); - //DNS Lookup for this domain + // DNS Lookup for this domain Collection<String> servers = getMailetContext().getMailServers(domain); if (servers.size() == 0) { - //No records...could not deliver to this domain, so matches criteria. + // No records...could not deliver to this domain, so matches + // criteria. log("No MX, A, or CNAME record found for domain: " + domain); return mail.getRecipients(); - } else if (matchNetwork(servers.iterator().next().toString())){ + } else if (matchNetwork(servers.iterator().next().toString())) { /* * It could be a wildcard address like these: * Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/util/MailetContextLog.java URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/util/MailetContextLog.java?rev=1088681&r1=1088680&r2=1088681&view=diff ============================================================================== --- james/server/trunk/mailets/src/main/java/org/apache/james/transport/util/MailetContextLog.java (original) +++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/util/MailetContextLog.java Mon Apr 4 16:36:42 2011 @@ -25,8 +25,6 @@ import org.slf4j.Marker; /** * {@link Logger} implementation which delegate the logging to a * {@link MailetContext} - * - * */ public class MailetContextLog implements Logger { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
