1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.mailet.GenericMatcher; 21 import org.apache.mailet.Mail; 22 import org.apache.mailet.MailAddress; 23 24 import java.util.Collection ; 25 import java.util.StringTokenizer ; 26 27 38 public class SMTPAuthUserIs extends GenericMatcher { 39 40 43 private final static String SMTP_AUTH_USER_ATTRIBUTE_NAME = "org.apache.james.SMTPAuthUser"; 44 45 private Collection users; 46 47 public void init() throws javax.mail.MessagingException { 48 StringTokenizer st = new StringTokenizer (getCondition(), ", \t", false); 49 users = new java.util.HashSet (); 50 while (st.hasMoreTokens()) { 51 users.add(st.nextToken()); 52 } 53 } 54 55 public Collection match(Mail mail) { 56 String authUser = (String ) mail.getAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME); 57 if (authUser != null && users.contains(authUser)) { 58 return mail.getRecipients(); 59 } else { 60 return null; 61 } 62 } 63 } 64 | Popular Tags |