1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.mailet.GenericMatcher; 21 import org.apache.mailet.Mail; 22 23 import javax.mail.MessagingException ; 24 import javax.mail.internet.MimeMessage ; 25 import java.util.Collection ; 26 27 64 65 public class HasHabeasWarrantMark extends GenericMatcher 66 { 67 public static final String [][] warrantMark = 68 { 69 { "X-Habeas-SWE-1", "winter into spring" }, 70 { "X-Habeas-SWE-2", "brightly anticipated" }, 71 { "X-Habeas-SWE-3", "like Habeas SWE (tm)" }, 72 { "X-Habeas-SWE-4", "Copyright 2002 Habeas (tm)" }, 73 { "X-Habeas-SWE-5", "Sender Warranted Email (SWE) (tm). The sender of this" }, 74 { "X-Habeas-SWE-6", "email in exchange for a license for this Habeas" }, 75 { "X-Habeas-SWE-7", "warrant mark warrants that this is a Habeas Compliant" }, 76 { "X-Habeas-SWE-8", "Message (HCM) and not spam. Please report use of this" }, 77 { "X-Habeas-SWE-9", "mark in spam to <http://www.habeas.com/report/>." }, 78 }; 79 80 public Collection match(Mail mail) throws MessagingException 81 { 82 MimeMessage message = mail.getMessage(); 83 84 for (int i = 0; i < warrantMark.length; i++) try 86 { 87 String headerName = warrantMark[i][0]; String requiredValue = warrantMark[i][1]; String headerValue = message.getHeader(headerName, null); 91 97 if (!(requiredValue.equals(headerValue))) return null; 98 } 99 catch (Exception e) 100 { 101 log(e.toString()); 102 return null; } 104 105 return mail.getRecipients(); 107 } 108 109 117 118 public String getMatcherInfo() 119 { 120 return "Habeas Warrant Mark Matcher (see http://www.habeas.com for details)."; 121 } 122 } 123 124 | Popular Tags |