james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r993319 - /james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
Date Tue, 07 Sep 2010 11:12:39 GMT
Author: norman
Date: Tue Sep  7 11:12:39 2010
New Revision: 993319

URL: http://svn.apache.org/viewvc?rev=993319&view=rev
Log:
Allow to use wildcards

Modified:
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java

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=993319&r1=993318&r2=993319&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
Tue Sep  7 11:12:39 2010
@@ -80,11 +80,6 @@ public class NetworkIsInWhitelist extend
      * @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 {
-        // check if it's a local sender
-        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;
@@ -103,16 +98,27 @@ public class NetworkIsInWhitelist extend
                 }
                 selectStmt.setString(1, recipientUser);
                 selectStmt.setString(2, recipientHost);
-                selectStmt.setString(3, senderUser);
-                selectStmt.setString(4, senderHost);
                 selectRS = selectStmt.executeQuery();
                 List<String> nets = new ArrayList<String>();
                 while (selectRS.next()) {
                     nets.add(selectRS.getString(1));
                 }
                 NetMatcher matcher = new NetMatcher(nets, dns);
-                return matcher.matchInetNetwork(mail.getRemoteAddr());
+                boolean matched = matcher.matchInetNetwork(mail.getRemoteAddr());
 
+                if (matched == false) {
+                    selectStmt = conn.prepareStatement(selectNetworks);
+                    selectStmt.setString(1, "*");
+                    selectStmt.setString(2, recipientHost);
+                    selectRS = selectStmt.executeQuery();
+                    nets = new ArrayList<String>();
+                    while (selectRS.next()) {
+                        nets.add(selectRS.getString(1));
+                    }
+                    matcher = new NetMatcher(nets, dns);
+                    matched = matcher.matchInetNetwork(mail.getRemoteAddr());
+                }
+                return matched;
             } finally {
                 theJDBCUtil.closeJDBCResultSet(selectRS);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message