001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.transport.mailets;
019:
020: import org.apache.james.transport.matchers.HasHabeasWarrantMark;
021: import org.apache.mailet.GenericMailet;
022: import org.apache.mailet.Mail;
023:
024: /*
025: * This matcher adds the Hebeas Warrant Mark to a message.
026: * For details see: http://www.hebeas.com
027: *
028: * Usage: <mailet match="<suitable-matcher>" class="AddHabeasWarrantMark" />
029: *
030: * NOTE: Although this mailet is covered by the Apache Software License,
031: * the Habeas Warrant Mark is copyright. A separate license from Habeas
032: * is required in order to legally attach the Habeas Warrant Mark to
033: * e-mail messages. Each James Administrator is responsible for
034: * ensuring that James is configured to attach the Habeas Warrant Mark
035: * only to e-mail covered by a suitable license received from Habeas.
036: *
037: * Because the Habeas Warrant Mark is copyright material, I have asked
038: * for and received the following explicit statement from Habeas:
039: *
040: * -----------------------------------
041: * From: Lindsey Pettit [mailto:support@habeas.com]
042: * Sent: Sunday, September 29, 2002 5:51
043: * To: Noel J. Bergman
044: * Subject: RE: Habeas and Apache James
045: *
046: * Dear Noel,
047: *
048: * > FURTHERMORE, if James is to be capable of sending Habeas SWE, I need
049: * > to write a Mailet that attaches the headers. As with any MTA, it
050: * > would be up to the administrator to properly configure James and make
051: * > sure that licenses are acquired. Since the Habeas Warrant Mark is
052: * > copyright, I believe that I require authorization from you for that
053: * > Mailet, especially since it attaches the Habeas Warrant Mark. For my
054: * > own protection, please show me why such authorization is unnecessary,
055: * > send me a digitally signed e-mail, or FAX a signed authorization
056: *
057: * You do not yourself need the authorization to build the functionality
058: * into the [mailet]; what one needs authorization, in the form of a
059: * license, for, is to use the mark *in headers*, in outgoing email.
060: * However, please let me know if you would like something more
061: * formal, and I can try to have something faxed to you.
062: *
063: * > The Mailet docs would reference the Habeas website, and inform
064: * > administrators that in order to USE the mailet, they need to ensure
065: * > that they have whatever licenses are required from you as appropriate
066: * > to your licensing terms.
067: *
068: * That's absolutely perfect!
069: * -----------------------------------
070: *
071: */
072:
073: public class AddHabeasWarrantMark extends GenericMailet {
074: /**
075: * Called by the mailet container to allow the mailet to process to
076: * a message message.
077: *
078: * This method adds the Habeas Warrant Mark headers to the message,
079: * saves the changes, and then allows the message to fall through
080: * in the pipeline.
081: *
082: * @param mail - the Mail object that contains the message and routing information
083: * @throws javax.mail.MessagingException - if an message or address parsing exception occurs or
084: * an exception that interferes with the mailet's normal operation
085: */
086: public void service(Mail mail) throws javax.mail.MessagingException {
087: try {
088: javax.mail.internet.MimeMessage message = mail.getMessage();
089:
090: for (int i = 0; i < HasHabeasWarrantMark.warrantMark.length; i++) {
091: message.setHeader(
092: HasHabeasWarrantMark.warrantMark[i][0],
093: HasHabeasWarrantMark.warrantMark[i][1]);
094: }
095:
096: message.saveChanges();
097: } catch (javax.mail.MessagingException me) {
098: log(me.getMessage());
099: }
100: }
101:
102: /*
103: * Return a string describing this mailet.
104: *
105: * @return a string describing this mailet
106: */
107: public String getMailetInfo() {
108: return "Add Habeas Warrant Mark. Must be used in accordance with a license from Habeas (see http://www.habeas.com for details).";
109: }
110: }
|