You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by pg...@apache.org on 2002/10/02 07:57:17 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/matchers HasHabeasWarrantMark.java
pgoldstein 2002/10/01 22:57:17
Added: src/java/org/apache/james/transport/mailets
AddHabeasWarrantMark.java
src/java/org/apache/james/transport/matchers
HasHabeasWarrantMark.java
Log:
Adding Habeas warrant matcher/mailet. Thanks to Noel Bergman
Revision Changes Path
1.1 jakarta-james/src/java/org/apache/james/transport/mailets/AddHabeasWarrantMark.java
Index: AddHabeasWarrantMark.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.james.transport.mailets;
import org.apache.james.transport.matchers.HasHabeasWarrantMark;
import org.apache.mailet.GenericMailet ;
import org.apache.mailet.Mail ;
/*
* This matcher adds the Hebeas Warrant Mark to a message.
* For details see: http://www.hebeas.com
*
* Usage: <mailet match="<suitable-matcher>" class="AddHabeasWarrantMark" />
*
* NOTE: Although this mailet is covered by the Apache Software License,
* the Habeas Warrant Mark is copyright. A separate license from Habeas
* is required in order to legally attach the Habeas Warrant Mark to
* e-mail messages. Each James Administrator is responsible for
* ensuring that James is configured to attach the Habeas Warrant Mark
* only to e-mail covered by a suitable license received from Habeas.
*
* Because the Habeas Warrant Mark is copyright material, I have asked
* for and received the following explicit statement from Habeas:
*
* -----------------------------------
* From: Lindsey Pettit [mailto:support@habeas.com]
* Sent: Sunday, September 29, 2002 5:51
* To: Noel J. Bergman
* Subject: RE: Habeas and Apache James
*
* Dear Noel,
*
* > FURTHERMORE, if James is to be capable of sending Habeas SWE, I need
* > to write a Mailet that attaches the headers. As with any MTA, it
* > would be up to the administrator to properly configure James and make
* > sure that licenses are acquired. Since the Habeas Warrant Mark is
* > copyright, I believe that I require authorization from you for that
* > Mailet, especially since it attaches the Habeas Warrant Mark. For my
* > own protection, please show me why such authorization is unnecessary,
* > send me a digitally signed e-mail, or FAX a signed authorization
*
* You do not yourself need the authorization to build the functionality
* into the [mailet]; what one needs authorization, in the form of a
* license, for, is to use the mark *in headers*, in outgoing email.
* However, please let me know if you would like something more
* formal, and I can try to have something faxed to you.
*
* > The Mailet docs would reference the Habeas website, and inform
* > administrators that in order to USE the mailet, they need to ensure
* > that they have whatever licenses are required from you as appropriate
* > to your licensing terms.
*
* That's absolutely perfect!
* -----------------------------------
*
* @author Noel J. Bergman <no...@devtech.com>
*/
public class AddHabeasWarrantMark extends GenericMailet
{
/**
* Called by the mailet container to allow the mailet to process to
* a message message.
*
* This method adds the Habeas Warrant Mark headers to the message,
* saves the changes, and then allows the message to fall through
* in the pipeline.
*
* @param mail - the Mail object that contains the message and routing information
* @throws javax.mail.MessagingException - if an message or address parsing exception occurs or
* an exception that interferes with the mailet's normal operation
*/
public void service(Mail mail) throws javax.mail.MessagingException
{
try
{
javax.mail.internet.MimeMessage message = mail.getMessage();
for(int i = 0 ; i < HasHabeasWarrantMark.warrantMark.length ; i++)
{
message.setHeader(HasHabeasWarrantMark.warrantMark[i][0], HasHabeasWarrantMark.warrantMark[i][1]);
}
message.saveChanges();
}
catch (javax.mail.MessagingException me)
{
log(me.getMessage());
}
}
/*
* Return a string describing this mailet.
*
* @return a string describing this mailet
*/
public String getMailetInfo()
{
return "Add Habeas Warrant Mark. Must be used in accordance with a license from Habeas (see http://www.habeas.com for details).";
}
}
1.1 jakarta-james/src/java/org/apache/james/transport/matchers/HasHabeasWarrantMark.java
Index: HasHabeasWarrantMark.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.james.transport.matchers;
import org.apache.mailet.GenericMatcher;
import org.apache.mailet.Mail;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.Collection;
/*
* This matcher tests for the Hebeas Warrant Mark.
* For details see: http://www.hebeas.com
*
* Usage: Place this matcher
*
* <mailet match="HasHabeasWarrantMark" class="ToProcessor">
* <processor> transport </processor>
* </mailet>
*
* in the root processs before the DNSRBL block lists (the InSpammerBlacklist matcher).
*
* Because the Habeas Warrant Mark is copyright material, I have asked for and
* received the following explicit statement from Habeas:
*
* -----------------------------------
* From: Lindsey Pettit [mailto:support@habeas.com]
* Sent: Sunday, September 29, 2002 5:51
* To: Noel J. Bergman
* Subject: RE: Habeas and Apache James
*
* Dear Noel,
*
* > I guess that since your Warrant Mark is copyright, I should ask for
* > something from you to explicitly authorize that Hebeas will permit
* > this code to be included and distributed as part of Apache James
* > under the Apache Software License. As we have established, the use
* > of the Habeas Warrant Mark for filtering is not restricted, but I
* > would like something to confirm that, so that Apache will be happy.
*
* I can hereby confirm to you that there is no license necessary in
* order to use the Habeas mark for filtering. That said, however, we
* do insist that it not ever be used as a basis for rejecting email which
* bears the Habeas mark.
* -----------------------------------
*
* @author Noel J. Bergman <no...@devtech.com>
*/
public class HasHabeasWarrantMark extends GenericMatcher
{
public static final String[][] warrantMark =
{
{ "X-Habeas-SWE-1", "winter into spring" },
{ "X-Habeas-SWE-2", "brightly anticipated" },
{ "X-Habeas-SWE-3", "like Habeas SWE (tm)" },
{ "X-Habeas-SWE-4", "Copyright 2002 Habeas (tm)" },
{ "X-Habeas-SWE-5", "Sender Warranted Email (SWE) (tm). The sender of this" },
{ "X-Habeas-SWE-6", "email in exchange for a license for this Habeas" },
{ "X-Habeas-SWE-7", "warrant mark warrants that this is a Habeas Compliant" },
{ "X-Habeas-SWE-8", "Message (HCM) and not spam. Please report use of this" },
{ "X-Habeas-SWE-9", "mark in spam to <http://www.habeas.com/report/>." },
};
public Collection match(Mail mail) throws MessagingException
{
MimeMessage message = mail.getMessage();
//Loop through all the patterns
for (int i = 0; i < warrantMark.length; i++) try
{
String headerName = warrantMark[i][0]; //Get the header name
String requiredValue = warrantMark[i][1]; //Get the required value
String headerValue = message.getHeader(headerName, null); //Get the header value(s)
// We want an exact match, so only test the first value.
// If there are multiple values, the header may be
// (illegally) forged. I'll leave it as an exercise to
// others if they want to detect and report potentially
// forged headers.
if (!(requiredValue.equals(headerValue))) return null;
}
catch (Exception e)
{
log(e.toString());
return null; //if we get an exception, don't validate the mark
}
// If we get here, all headers are present and match.
return mail.getRecipients();
}
/*
* Returns information about the matcher, such as author, version, and copyright.
* <p>
* The string that this method returns should be plain text and not markup
* of any kind (such as HTML, XML, etc.).
*
* @return a String containing matcher information
*/
public String getMatcherInfo()
{
return "Habeas Warrant Mark Matcher (see http://www.habeas.com for details).";
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>