1 /************************************************************************
2 * Copyright (c) 2000-2006 The Apache Software Foundation. *
3 * All rights reserved. *
4 * ------------------------------------------------------------------- *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you *
6 * may not use this file except in compliance with the License. You *
7 * may obtain a copy of the License at: *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14 * implied. See the License for the specific language governing *
15 * permissions and limitations under the License. *
16 ***********************************************************************/
17
18 package org.apache.james.transport.mailets;
19
20 import org.apache.james.transport.matchers.HasHabeasWarrantMark;
21 import org.apache.mailet.GenericMailet ;
22 import org.apache.mailet.Mail ;
23
24 /*
25 * This matcher adds the Hebeas Warrant Mark to a message.
26 * For details see: http://www.hebeas.com
27 *
28 * Usage: <mailet match="<suitable-matcher>" class="AddHabeasWarrantMark" />
29 *
30 * NOTE: Although this mailet is covered by the Apache Software License,
31 * the Habeas Warrant Mark is copyright. A separate license from Habeas
32 * is required in order to legally attach the Habeas Warrant Mark to
33 * e-mail messages. Each James Administrator is responsible for
34 * ensuring that James is configured to attach the Habeas Warrant Mark
35 * only to e-mail covered by a suitable license received from Habeas.
36 *
37 * Because the Habeas Warrant Mark is copyright material, I have asked
38 * for and received the following explicit statement from Habeas:
39 *
40 * -----------------------------------
41 * From: Lindsey Pettit [mailto:support@habeas.com]
42 * Sent: Sunday, September 29, 2002 5:51
43 * To: Noel J. Bergman
44 * Subject: RE: Habeas and Apache James
45 *
46 * Dear Noel,
47 *
48 * > FURTHERMORE, if James is to be capable of sending Habeas SWE, I need
49 * > to write a Mailet that attaches the headers. As with any MTA, it
50 * > would be up to the administrator to properly configure James and make
51 * > sure that licenses are acquired. Since the Habeas Warrant Mark is
52 * > copyright, I believe that I require authorization from you for that
53 * > Mailet, especially since it attaches the Habeas Warrant Mark. For my
54 * > own protection, please show me why such authorization is unnecessary,
55 * > send me a digitally signed e-mail, or FAX a signed authorization
56 *
57 * You do not yourself need the authorization to build the functionality
58 * into the [mailet]; what one needs authorization, in the form of a
59 * license, for, is to use the mark *in headers*, in outgoing email.
60 * However, please let me know if you would like something more
61 * formal, and I can try to have something faxed to you.
62 *
63 * > The Mailet docs would reference the Habeas website, and inform
64 * > administrators that in order to USE the mailet, they need to ensure
65 * > that they have whatever licenses are required from you as appropriate
66 * > to your licensing terms.
67 *
68 * That's absolutely perfect!
69 * -----------------------------------
70 *
71 */
72
73 public class AddHabeasWarrantMark extends GenericMailet
74 {
75 /***
76 * Called by the mailet container to allow the mailet to process to
77 * a message message.
78 *
79 * This method adds the Habeas Warrant Mark headers to the message,
80 * saves the changes, and then allows the message to fall through
81 * in the pipeline.
82 *
83 * @param mail - the Mail object that contains the message and routing information
84 * @throws javax.mail.MessagingException - if an message or address parsing exception occurs or
85 * an exception that interferes with the mailet's normal operation
86 */
87 public void service(Mail mail) throws javax.mail.MessagingException
88 {
89 try
90 {
91 javax.mail.internet.MimeMessage message = mail.getMessage();
92
93 for(int i = 0 ; i < HasHabeasWarrantMark.warrantMark.length ; i++)
94 {
95 message.setHeader(HasHabeasWarrantMark.warrantMark[i][0], HasHabeasWarrantMark.warrantMark[i][1]);
96 }
97
98 message.saveChanges();
99 }
100 catch (javax.mail.MessagingException me)
101 {
102 log(me.getMessage());
103 }
104 }
105
106 /*
107 * Return a string describing this mailet.
108 *
109 * @return a string describing this mailet
110 */
111 public String getMailetInfo()
112 {
113 return "Add Habeas Warrant Mark. Must be used in accordance with a license from Habeas (see http://www.habeas.com for details).";
114 }
115 }