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