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