james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [james-jdkim] 16/18: JDKIM-42 Remove apache-jdkim-mailets
Date Mon, 09 Sep 2019 05:09:12 GMT
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-jdkim.git

commit fa182865c949ed696e4aa3455d0729b13f700c22
Author: Rene Cordier <rcordier@linagora.com>
AuthorDate: Wed Sep 4 18:06:54 2019 +0700

    JDKIM-42 Remove apache-jdkim-mailets
    
    The JDKIM mailet has been moved into James server project
---
 assemble/pom.xml                                   |   4 -
 mailets/pom.xml                                    | 114 -------
 .../james/jdkim/mailets/CRLFOutputStream.java      | 161 ----------
 .../apache/james/jdkim/mailets/ConvertTo7Bit.java  |  85 -----
 .../org/apache/james/jdkim/mailets/DKIMSign.java   | 176 ----------
 .../org/apache/james/jdkim/mailets/DKIMVerify.java | 108 -------
 .../jdkim/mailets/HeaderSkippingOutputStream.java  |  71 -----
 .../james/jdkim/mailets/MimeMessageHeaders.java    |  70 ----
 mailets/src/reporting-site/site.xml                |  29 --
 .../apache/james/jdkim/mailets/DKIMSignTest.java   | 353 ---------------------
 .../apache/james/jdkim/mailets/DKIMVerifyTest.java | 126 --------
 main/pom.xml                                       |  14 -
 pom.xml                                            |  71 -----
 13 files changed, 1382 deletions(-)

diff --git a/assemble/pom.xml b/assemble/pom.xml
index 2468208..8dec225 100644
--- a/assemble/pom.xml
+++ b/assemble/pom.xml
@@ -51,10 +51,6 @@
             <groupId>org.apache.james.jdkim</groupId>
             <artifactId>apache-jdkim-library</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.james.jdkim</groupId>
-            <artifactId>apache-jdkim-mailets</artifactId>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/mailets/pom.xml b/mailets/pom.xml
deleted file mode 100644
index 846c386..0000000
--- a/mailets/pom.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements. See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership. The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License. You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied. See the License for the
-    specific language governing permissions and limitations
-    under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <artifactId>apache-jdkim-project</artifactId>
-        <groupId>org.apache.james.jdkim</groupId>
-        <version>0.3-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <artifactId>apache-jdkim-mailets</artifactId>
-    <packaging>bundle</packaging>
-
-    <name>Apache James :: jDKIM :: Mailets</name>
-    <description>Mailets integrating DKIM functions</description>
-    <url>http://james.apache.org/jdkim/mailets/</url>
-
-    <dependencies>
-        <dependency>
-            <groupId>ca.juliusdavies</groupId>
-            <artifactId>not-yet-commons-ssl</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.javamail</groupId>
-            <artifactId>geronimo-javamail_1.4_mail</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-activation_1.1_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.jdkim</groupId>
-            <artifactId>apache-jdkim-library</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.james</groupId>
-                    <artifactId>apache-mime4j-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.james</groupId>
-                    <artifactId>apache-mime4j-dom</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james.jdkim</groupId>
-            <artifactId>apache-jdkim-library</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.james</groupId>
-                    <artifactId>apache-mime4j-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.james</groupId>
-                    <artifactId>apache-mime4j-dom</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.logging.log4j</groupId>
-            <artifactId>log4j-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-</project>
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/CRLFOutputStream.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/CRLFOutputStream.java
deleted file mode 100644
index b686b72..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/CRLFOutputStream.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * A Filter for use with SMTP or other protocols in which lines must end with
- * CRLF. Converts every "isolated" occourency of \r or \n with \r\n
- * 
- * RFC 2821 #2.3.7 mandates that line termination is CRLF, and that CR and LF
- * must not be transmitted except in that pairing. If we get a naked LF, convert
- * to CRLF.
- * 
- */
-public class CRLFOutputStream extends FilterOutputStream {
-
-    /**
-     * Counter for number of last (0A or 0D).
-     */
-    protected int statusLast;
-
-    protected final static int LAST_WAS_OTHER = 0;
-
-    protected final static int LAST_WAS_CR = 1;
-
-    protected final static int LAST_WAS_LF = 2;
-
-    protected boolean startOfLine = true;
-
-    /**
-     * Constructor that wraps an OutputStream.
-     * 
-     * @param out
-     *            the OutputStream to be wrapped
-     */
-    public CRLFOutputStream(OutputStream out) {
-        super(out);
-        statusLast = LAST_WAS_LF; // we already assume a CRLF at beginning
-        // (otherwise TOP would not work correctly
-        // !)
-    }
-
-    /**
-     * Writes a byte to the stream Fixes any naked CR or LF to the RFC 2821
-     * mandated CFLF pairing.
-     * 
-     * @param b
-     *            the byte to write
-     * 
-     * @throws IOException
-     *             if an error occurs writing the byte
-     */
-    public void write(int b) throws IOException {
-        switch (b) {
-            case '\r':
-                out.write('\r');
-                out.write('\n');
-                startOfLine = true;
-                statusLast = LAST_WAS_CR;
-                break;
-            case '\n':
-                if (statusLast != LAST_WAS_CR) {
-                    out.write('\r');
-                    out.write('\n');
-                    startOfLine = true;
-                }
-                statusLast = LAST_WAS_LF;
-                break;
-            default:
-                // we're no longer at the start of a line
-                out.write(b);
-                startOfLine = false;
-                statusLast = LAST_WAS_OTHER;
-                break;
-        }
-    }
-
-    /**
-     * Provides an extension point for ExtraDotOutputStream to be able to add
-     * dots at the beginning of new lines.
-     * 
-     * @see java.io.FilterOutputStream#write(byte[], int, int)
-     */
-    protected void writeChunk(byte buffer[], int offset, int length)
-            throws IOException {
-        out.write(buffer, offset, length);
-    }
-
-    /**
-     * @see java.io.FilterOutputStream#write(byte[], int, int)
-     */
-    public synchronized void write(byte buffer[], int offset, int length)
-            throws IOException {
-        /* optimized */
-        int lineStart = offset;
-        for (int i = offset; i < length + offset; i++) {
-            switch (buffer[i]) {
-                case '\r':
-                    // CR case. Write down the last line
-                    // and position the new lineStart at the next char
-                    writeChunk(buffer, lineStart, i - lineStart);
-                    out.write('\r');
-                    out.write('\n');
-                    startOfLine = true;
-                    lineStart = i + 1;
-                    statusLast = LAST_WAS_CR;
-                    break;
-                case '\n':
-                    if (statusLast != LAST_WAS_CR) {
-                        writeChunk(buffer, lineStart, i - lineStart);
-                        out.write('\r');
-                        out.write('\n');
-                        startOfLine = true;
-                    }
-                    lineStart = i + 1;
-                    statusLast = LAST_WAS_LF;
-                    break;
-                default:
-                    statusLast = LAST_WAS_OTHER;
-            }
-        }
-        if (length + offset > lineStart) {
-            writeChunk(buffer, lineStart, length + offset - lineStart);
-            startOfLine = false;
-        }
-    }
-
-    /**
-     * Ensure that the stream is CRLF terminated.
-     * 
-     * @throws IOException
-     *             if an error occurs writing the byte
-     */
-    public void checkCRLFTerminator() throws IOException {
-        if (statusLast == LAST_WAS_OTHER) {
-            out.write('\r');
-            out.write('\n');
-            statusLast = LAST_WAS_CR;
-        }
-    }
-}
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/ConvertTo7Bit.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/ConvertTo7Bit.java
deleted file mode 100644
index 72e4e77..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/ConvertTo7Bit.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.IOException;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-import javax.mail.internet.MimePart;
-
-import org.apache.mailet.Mail;
-import org.apache.mailet.base.GenericMailet;
-
-/**
- * Make sure the message stream is 7bit. Every 8bit part is encoded to
- * quoted-printable or base64 and the message is saved.
- */
-public class ConvertTo7Bit extends GenericMailet {
-
-    public void service(Mail mail) throws MessagingException {
-        MimeMessage message = mail.getMessage();
-        try {
-            convertTo7Bit(message);
-            message.saveChanges();
-        } catch (IOException e) {
-            throw new MessagingException(
-                    "IOException converting message to 7bit: " + e.getMessage(),
-                    e);
-        }
-    }
-
-    /**
-     * Converts a message to 7 bit.
-     * 
-     * @param part
-     */
-    private void convertTo7Bit(MimePart part) throws MessagingException,
-            IOException {
-        if (part.isMimeType("multipart/*")) {
-            MimeMultipart parts = (MimeMultipart) part.getContent();
-            int count = parts.getCount();
-            for (int i = 0; i < count; i++) {
-                convertTo7Bit((MimePart) parts.getBodyPart(i));
-            }
-        } else if ("8bit".equals(part.getEncoding())) {
-            // The content may already be in encoded the form (likely with mail
-            // created from a stream). In that case, just changing the encoding
-            // to quoted-printable will mangle the result when this is
-            // transmitted.
-            // We must first convert the content into its native format, set it
-            // back, and only THEN set the transfer encoding to force the
-            // content to be encoded appropriately.
-
-            // if the part doesn't contain text it will be base64 encoded.
-            String contentTransferEncoding = part.isMimeType("text/*") ? "quoted-printable"
-                    : "base64";
-            part.setContent(part.getContent(), part.getContentType());
-            part
-                    .setHeader("Content-Transfer-Encoding",
-                            contentTransferEncoding);
-            part.addHeader("X-MIME-Autoconverted", "from 8bit to "
-                    + contentTransferEncoding + " by "
-                    + getMailetContext().getServerInfo());
-        }
-    }
-
-}
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java
deleted file mode 100644
index c71d754..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.GeneralSecurityException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.mail.Header;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.commons.ssl.PKCS8Key;
-import org.apache.james.jdkim.DKIMSigner;
-import org.apache.james.jdkim.api.BodyHasher;
-import org.apache.james.jdkim.api.Headers;
-import org.apache.james.jdkim.api.SignatureRecord;
-import org.apache.james.jdkim.exceptions.PermFailException;
-import org.apache.mailet.Mail;
-import org.apache.mailet.base.GenericMailet;
-
-/**
- * This mailet sign a message using the DKIM protocol
- * If the privateKey is encoded using a password then you can pass
- * the password as privateKeyPassword parameter.
- * 
- * Sample configuration:
- * 
- * <pre><code>
- * &lt;mailet match=&quot;All&quot; class=&quot;DKIMSign&quot;&gt;
- *   &lt;signatureTemplate&gt;v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;&lt;/signatureTemplate&gt;
- *   &lt;privateKey&gt;
- *   -----BEGIN RSA PRIVATE KEY-----
- *   MIICXAIBAAKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoT
- *   M5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRH
- *   r7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB
- *   AoGBAI8XcwnZi0Sq5N89wF+gFNhnREFo3rsJDaCY8iqHdA5DDlnr3abb/yhipw0I
- *   /1HlgC6fIG2oexXOXFWl+USgqRt1kTt9jXhVFExg8mNko2UelAwFtsl8CRjVcYQO
- *   cedeH/WM/mXjg2wUqqZenBmlKlD6vNb70jFJeVaDJ/7n7j8BAkEA9NkH2D4Zgj/I
- *   OAVYccZYH74+VgO0e7VkUjQk9wtJ2j6cGqJ6Pfj0roVIMUWzoBb8YfErR8l6JnVQ
- *   bfy83gJeiQJBAOHk3ow7JjAn8XuOyZx24KcTaYWKUkAQfRWYDFFOYQF4KV9xLSEt
- *   ycY0kjsdxGKDudWcsATllFzXDCQF6DTNIWECQEA52ePwTjKrVnLTfCLEG4OgHKvl
- *   Zud4amthwDyJWoMEH2ChNB2je1N4JLrABOE+hk+OuoKnKAKEjWd8f3Jg/rkCQHj8
- *   mQmogHqYWikgP/FSZl518jV48Tao3iXbqvU9Mo2T6yzYNCCqIoDLFWseNVnCTZ0Q
- *   b+IfiEf1UeZVV5o4J+ECQDatNnS3V9qYUKjj/krNRD/U0+7eh8S2ylLqD3RlSn9K
- *   tYGRMgAtUXtiOEizBH6bd/orzI9V9sw8yBz+ZqIH25Q=
- *   -----END RSA PRIVATE KEY-----
- *   &lt;/privateKey&gt;
- * &lt;/mailet&gt;
- * </code></pre>
- * 
- * By default the mailet assume that Javamail will convert LF to CRLF when sending 
- * so will compute the hash using converted newlines. If you don't want this 
- * behaviout then set forceCRLF attribute to false. 
- */
-public class DKIMSign extends GenericMailet {
-
-    private String signatureTemplate;
-    private PrivateKey privateKey;
-    private boolean forceCRLF;
-
-	/**
-	 * @return the signatureTemplate
-	 */
-	protected String getSignatureTemplate() {
-		return signatureTemplate;
-	}
-
-	/**
-	 * @return the privateKey
-	 */
-	protected PrivateKey getPrivateKey() {
-		return privateKey;
-	}
-
-    public void init() throws MessagingException {
-        signatureTemplate = getInitParameter("signatureTemplate");
-        String privateKeyString = getInitParameter("privateKey");
-        String privateKeyPassword = getInitParameter("privateKeyPassword", null);
-        forceCRLF = getInitParameter("forceCRLF", true);
-        try {
-            PKCS8Key pkcs8 = new PKCS8Key(new ByteArrayInputStream(
-                    privateKeyString.getBytes()),
-                    privateKeyPassword != null ? privateKeyPassword
-                            .toCharArray() : null);
-            privateKey = pkcs8.getPrivateKey();
-            // privateKey = DKIMSigner.getPrivateKey(privateKeyString);
-        } catch (NoSuchAlgorithmException e) {
-            throw new MessagingException("Unknown private key algorythm: "
-                    + e.getMessage(), e);
-        } catch (InvalidKeySpecException e) {
-            throw new MessagingException(
-                    "PrivateKey should be in base64 encoded PKCS8 (der) format: "
-                            + e.getMessage(), e);
-        } catch (GeneralSecurityException e) {
-            throw new MessagingException("General security exception: "
-                    + e.getMessage(), e);
-        }
-    }
-
-    public void service(Mail mail) throws MessagingException {
-        DKIMSigner signer = new DKIMSigner(getSignatureTemplate(), getPrivateKey());
-        SignatureRecord signRecord = signer
-                .newSignatureRecordTemplate(getSignatureTemplate());
-        try {
-            BodyHasher bhj = signer.newBodyHasher(signRecord);
-            MimeMessage message = mail.getMessage();
-            Headers headers = new MimeMessageHeaders(message);
-            try {
-            	OutputStream os = new HeaderSkippingOutputStream(bhj.getOutputStream());
-            	if (forceCRLF) os = new CRLFOutputStream(os);
-                message.writeTo(os);
-                bhj.getOutputStream().close();
-            } catch (IOException e) {
-                throw new MessagingException("Exception calculating bodyhash: "
-                        + e.getMessage(), e);
-            }
-            String signatureHeader = signer.sign(headers, bhj);
-            // Unfortunately JavaMail does not give us a method to add headers
-            // on top.
-            // message.addHeaderLine(signatureHeader);
-            prependHeader(message, signatureHeader);
-        } catch (PermFailException e) {
-            throw new MessagingException("PermFail while signing: "
-                    + e.getMessage(), e);
-        }
-
-    }
-
-    private void prependHeader(MimeMessage message, String signatureHeader)
-            throws MessagingException {
-        List<String> prevHeader = new LinkedList<String>();
-        // read all the headers
-        for (Enumeration<String> e = message.getAllHeaderLines(); e.hasMoreElements();) {
-            String headerLine = e.nextElement();
-            prevHeader.add(headerLine);
-        }
-        // remove all the headers
-        for (Enumeration<Header> e = message.getAllHeaders(); e.hasMoreElements();) {
-            Header header = e.nextElement();
-            message.removeHeader(header.getName());
-        }
-        // add our header
-        message.addHeaderLine(signatureHeader);
-        // add the remaining headers using "addHeaderLine" that won't alter the
-        // insertion order.
-        for (String header : prevHeader) {
-            message.addHeaderLine(header);
-        }
-    }
-
-}
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
deleted file mode 100644
index 68c0cf9..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.james.jdkim.DKIMVerifier;
-import org.apache.james.jdkim.api.BodyHasher;
-import org.apache.james.jdkim.api.Headers;
-import org.apache.james.jdkim.api.SignatureRecord;
-import org.apache.james.jdkim.exceptions.FailException;
-import org.apache.mailet.Mail;
-import org.apache.mailet.base.GenericMailet;
-
-/**
- * This mailet verify a message using the DKIM protocol
- * 
- * Sample configuration:
- * <pre><code>
- * &lt;mailet match=&quot;All&quot; class=&quot;DKIMVerify&quot;&gt;
- * &lt;/mailet&gt;
- * </code></pre>
- * 
- * By default the mailet assume that Javamail will use LF instead of CRLF 
- * so it will verify the hash using converted newlines. If you don't want this 
- * behaviout then set forceCRLF attribute to false. 
- */
-public class DKIMVerify extends GenericMailet {
-
-    public static final String DKIM_AUTH_RESULT_ATTRIBUTE = "jDKIM.AUTHRESULT";
-    
-    protected DKIMVerifier verifier = null;
-    private boolean forceCRLF;
-
-    @Override
-    public void init() throws MessagingException {
-        verifier = new DKIMVerifier();
-        forceCRLF = getInitParameter("forceCRLF", true);
-    }
-    
-    public void service(Mail mail) throws MessagingException {
-        try {
-            MimeMessage message = mail.getMessage();
-            List<SignatureRecord> res = verify(verifier, message, forceCRLF);
-            if (res == null || res.isEmpty()) {
-                // neutral
-                mail.setAttribute(DKIM_AUTH_RESULT_ATTRIBUTE, "neutral (no signatures)");
-            } else {
-                // pass
-                StringBuilder msg = new StringBuilder();
-                msg.append("pass");
-                for (SignatureRecord rec : res) {
-                    msg.append(" (");
-                    msg.append("identity ");
-                    msg.append(rec.getIdentity().toString());
-                    msg.append(")");
-                }
-                mail.setAttribute(DKIM_AUTH_RESULT_ATTRIBUTE, msg.toString());
-            }
-        } catch (FailException e) {
-            // fail
-            mail.setAttribute(DKIM_AUTH_RESULT_ATTRIBUTE, "fail ("+(e.getRelatedRecordIdentity() != null ? "identity "+ e.getRelatedRecordIdentity() + ": " : "")+e.getMessage()+")");
-        }
-        
-    }
-
-	protected static List<SignatureRecord> verify(DKIMVerifier verifier, MimeMessage message, boolean forceCRLF)
-			throws MessagingException, FailException {
-		Headers headers = new MimeMessageHeaders(message);
-		BodyHasher bh = verifier.newBodyHasher(headers);
-		try {
-		    if (bh != null) {
-		    	OutputStream os = new HeaderSkippingOutputStream(bh
-		                .getOutputStream());
-		    	if (forceCRLF) os = new CRLFOutputStream(os);
-		        message.writeTo(os);
-		        bh.getOutputStream().close();
-		    }
-		    
-		} catch (IOException e) {
-		    throw new MessagingException("Exception calculating bodyhash: "
-		            + e.getMessage(), e);
-		}
-		return verifier.verify(bh);
-	}
-}
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/HeaderSkippingOutputStream.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/HeaderSkippingOutputStream.java
deleted file mode 100644
index 16e7f25..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/HeaderSkippingOutputStream.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Ignore writes until the given sequence is found.
- */
-public class HeaderSkippingOutputStream extends FilterOutputStream {
-
-    boolean inHeaders = true;
-    final byte[] skipTo = "\r\n\r\n".getBytes();
-    int pos = 0;
-
-    public HeaderSkippingOutputStream(OutputStream out) {
-        super(out);
-    }
-
-    public void write(byte[] b, int off, int len) throws IOException {
-        if (inHeaders) {
-            for (int i = off; i < off + len; i++) {
-                if (b[i] == skipTo[pos]) {
-                    pos++;
-                    if (pos == skipTo.length) {
-                        inHeaders = false;
-                        if (len - i - 1 > 0)
-                            out.write(b, i + 1, len - i - 1);
-                        break;
-                    }
-                } else
-                    pos = 0;
-            }
-        } else {
-            out.write(b, off, len);
-        }
-    }
-
-    public void write(int b) throws IOException {
-        if (inHeaders) {
-            if (skipTo[pos] == b) {
-                pos++;
-                if (pos == skipTo.length)
-                    inHeaders = false;
-            } else
-                pos = 0;
-        } else {
-            out.write(b);
-        }
-    }
-
-}
diff --git a/mailets/src/main/java/org/apache/james/jdkim/mailets/MimeMessageHeaders.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/MimeMessageHeaders.java
deleted file mode 100644
index 5b70968..0000000
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/MimeMessageHeaders.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.james.jdkim.api.Headers;
-
-/**
- * An adapter to let DKIMSigner read headers from MimeMessage
- */
-final class MimeMessageHeaders implements Headers {
-
-    private final Map<String, List<String>> headers;
-    private final List<String> fields;
-
-    public MimeMessageHeaders(MimeMessage message)
-            throws MessagingException {
-        headers = new HashMap<String, List<String>>();
-        fields = new LinkedList<String>();
-        for (Enumeration<String> e = message.getAllHeaderLines(); e
-                .hasMoreElements();) {
-            String head = e.nextElement();
-            int p = head.indexOf(':');
-            if (p <= 0)
-                throw new MessagingException("Bad header line: " + head);
-            String headerName = head.substring(0, p).trim();
-            String headerNameLC = headerName.toLowerCase();
-            fields.add(headerName);
-            List<String> strings = headers.get(headerNameLC);
-            if (strings == null) {
-                strings = new LinkedList<String>();
-                headers.put(headerNameLC, strings);
-            }
-            strings.add(head);
-        }
-    }
-
-    public List<String> getFields() {
-        return fields;
-    }
-
-    public List<String> getFields(String name) {
-        return headers.get(name.toLowerCase());
-    }
-}
\ No newline at end of file
diff --git a/mailets/src/reporting-site/site.xml b/mailets/src/reporting-site/site.xml
deleted file mode 100644
index d919164..0000000
--- a/mailets/src/reporting-site/site.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-    
-    http://www.apache.org/licenses/LICENSE-2.0
-    
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.    
--->
-<project name="${project.name}">
-
-    <body>
-
-        <menu ref="parent" />
-        <menu ref="reports" />
-
-    </body>
-
-</project>
diff --git a/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java b/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java
deleted file mode 100644
index 2e46dd0..0000000
--- a/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMSignTest.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import org.apache.james.jdkim.DKIMVerifier;
-import org.apache.james.jdkim.MockPublicKeyRecordRetriever;
-import org.apache.james.jdkim.api.SignatureRecord;
-import org.apache.james.jdkim.exceptions.FailException;
-import org.apache.james.jdkim.exceptions.PermFailException;
-import org.apache.mailet.Mail;
-import org.apache.mailet.Mailet;
-import org.apache.mailet.base.test.FakeMail;
-import org.apache.mailet.base.test.FakeMailContext;
-import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import org.junit.Test;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMessage.RecipientType;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-
-public class DKIMSignTest {
-
-    private static final String TESTING_PEM = "-----BEGIN RSA PRIVATE KEY-----\r\n" +
-            "MIICXAIBAAKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoT\r\n" +
-            "M5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRH\r\n" +
-            "r7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB\r\n" +
-            "AoGBAI8XcwnZi0Sq5N89wF+gFNhnREFo3rsJDaCY8iqHdA5DDlnr3abb/yhipw0I\r\n" +
-            "/1HlgC6fIG2oexXOXFWl+USgqRt1kTt9jXhVFExg8mNko2UelAwFtsl8CRjVcYQO\r\n" +
-            "cedeH/WM/mXjg2wUqqZenBmlKlD6vNb70jFJeVaDJ/7n7j8BAkEA9NkH2D4Zgj/I\r\n" +
-            "OAVYccZYH74+VgO0e7VkUjQk9wtJ2j6cGqJ6Pfj0roVIMUWzoBb8YfErR8l6JnVQ\r\n" +
-            "bfy83gJeiQJBAOHk3ow7JjAn8XuOyZx24KcTaYWKUkAQfRWYDFFOYQF4KV9xLSEt\r\n" +
-            "ycY0kjsdxGKDudWcsATllFzXDCQF6DTNIWECQEA52ePwTjKrVnLTfCLEG4OgHKvl\r\n" +
-            "Zud4amthwDyJWoMEH2ChNB2je1N4JLrABOE+hk+OuoKnKAKEjWd8f3Jg/rkCQHj8\r\n" +
-            "mQmogHqYWikgP/FSZl518jV48Tao3iXbqvU9Mo2T6yzYNCCqIoDLFWseNVnCTZ0Q\r\n" +
-            "b+IfiEf1UeZVV5o4J+ECQDatNnS3V9qYUKjj/krNRD/U0+7eh8S2ylLqD3RlSn9K\r\n" +
-            "tYGRMgAtUXtiOEizBH6bd/orzI9V9sw8yBz+ZqIH25Q=\r\n" +
-            "-----END RSA PRIVATE KEY-----\r\n";
-    private static final FakeMailContext FAKE_MAIL_CONTEXT = FakeMailContext.defaultContext();
-
-    @Test
-    public void testDKIMSign() throws MessagingException, IOException,
-            FailException {
-        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";
-
-        Mailet mailet = new DKIMSign();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        mailet.init(mci);
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(new MimeMessage(Session
-                .getDefaultInstance(new Properties()),
-                new ByteArrayInputStream(message.getBytes())))
-            .build();
-
-        mailet.service(mail);
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-        verify(rawMessage, mockPublicKeyRecordRetriever);
-    }
-
-    private List<SignatureRecord> verify(ByteArrayOutputStream rawMessage,
-                                         MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever)
-            throws MessagingException, FailException {
-        List<SignatureRecord> signs = DKIMVerify.verify(new DKIMVerifier(mockPublicKeyRecordRetriever), new MimeMessage(Session.getDefaultInstance(new Properties()), new ByteArrayInputStream(rawMessage.toByteArray())), true);
-        assertNotNull(signs);
-        assertEquals(1, signs.size());
-        return signs;
-    }
-
-    @Test
-    public void testDKIMSignFuture() throws MessagingException, IOException,
-            FailException {
-        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";
-
-        Mailet mailet = new DKIMSign();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; t=" + ((System.currentTimeMillis() / 1000) + 1000) + "; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        mailet.init(mci);
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(new MimeMessage(Session
-                .getDefaultInstance(new Properties()),
-                new ByteArrayInputStream(message.getBytes())))
-            .build();
-
-        mailet.service(mail);
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-        try {
-            verify(rawMessage, mockPublicKeyRecordRetriever);
-            Assert.fail("Expecting signature to be ignored");
-        } catch (PermFailException e) {
-            // signature ignored, so fail for missing signatures.
-        }
-    }
-
-
-    @Test
-    public void testDKIMSignTime() throws MessagingException, IOException,
-            FailException {
-        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";
-
-        Mailet mailet = new DKIMSign();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; t=; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        mailet.init(mci);
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(new MimeMessage(Session
-                .getDefaultInstance(new Properties()),
-                new ByteArrayInputStream(message.getBytes())))
-            .build();
-
-        mailet.service(mail);
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-        verify(rawMessage, mockPublicKeyRecordRetriever);
-
-        List<SignatureRecord> rs = verify(rawMessage, mockPublicKeyRecordRetriever);
-
-        // check we have a valued signatureTimestamp
-        Assert.assertNotNull(rs.get(0).getSignatureTimestamp());
-        long ref = System.currentTimeMillis() / 1000;
-        // Chech that the signature timestamp is in the past 60 seconds.
-        Assert.assertTrue(rs.get(0).getSignatureTimestamp() <= ref);
-        Assert.assertTrue(rs.get(0).getSignatureTimestamp() >= ref - 60);
-    }
-
-    @Test
-    public void testDKIMSignMessageAsText() throws MessagingException,
-            IOException, FailException {
-        MimeMessage mm = new MimeMessage(Session
-                .getDefaultInstance(new Properties()));
-        mm.addFrom(new Address[]{new InternetAddress("io@bago.org")});
-        mm.addRecipient(RecipientType.TO, new InternetAddress("io@bago.org"));
-        mm.setText("An 8bit encoded body with \u20ACuro symbol.", "ISO-8859-15");
-
-        Mailet mailet = new DKIMSign();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        mailet.init(mci);
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(mm)
-            .build();
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-
-        mailet.service(mail);
-
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-
-        verify(rawMessage, mockPublicKeyRecordRetriever);
-    }
-
-    @Test
-    public void testDKIMSignMessageAsObjectConvertedTo7Bit()
-            throws MessagingException, IOException, FailException {
-        MimeMessage mm = new MimeMessage(Session
-                .getDefaultInstance(new Properties()));
-        mm.addFrom(new Address[]{new InternetAddress("io@bago.org")});
-        mm.addRecipient(RecipientType.TO, new InternetAddress("io@bago.org"));
-        mm.setContent("An 8bit encoded body with \u20ACuro symbol.",
-                "text/plain; charset=iso-8859-15");
-        mm.setHeader("Content-Transfer-Encoding", "8bit");
-        mm.saveChanges();
-
-        FakeMailContext FakeMailContext = FAKE_MAIL_CONTEXT;
-        FakeMailContext.getServerInfo();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(mm)
-            .build();
-
-        Mailet mailet = new DKIMSign();
-        mailet.init(mci);
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-        m7bit.service(mail);
-
-        mailet.service(mail);
-
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-        verify(rawMessage, mockPublicKeyRecordRetriever);
-    }
-
-    @Test
-    public void testDKIMSignMessageAsObjectNotConverted()
-            throws MessagingException, IOException, FailException {
-        MimeMessage mm = new MimeMessage(Session
-                .getDefaultInstance(new Properties()));
-        mm.addFrom(new Address[]{new InternetAddress("io@bago.org")});
-        mm.addRecipient(RecipientType.TO, new InternetAddress("io@bago.org"));
-        mm.setContent("An 8bit encoded body with \u20ACuro symbol.",
-                "text/plain; charset=iso-8859-15");
-        mm.setHeader("Content-Transfer-Encoding", "8bit");
-        mm.saveChanges();
-
-        FakeMailContext FakeMailContext = FAKE_MAIL_CONTEXT;
-        FakeMailContext.getServerInfo();
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FAKE_MAIL_CONTEXT)
-                .setProperty(
-                        "signatureTemplate",
-                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;")
-                .setProperty("privateKey", TESTING_PEM)
-                .build();
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(mm)
-            .build();
-
-        Mailet mailet = new DKIMSign();
-        mailet.init(mci);
-
-        Mailet m7bit = new ConvertTo7Bit();
-        m7bit.init(mci);
-        // m7bit.service(mail);
-
-        mailet.service(mail);
-
-        m7bit.service(mail);
-
-        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
-        mail.getMessage().writeTo(rawMessage);
-
-        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
-                "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                "selector", "example.com");
-        try {
-            verify(rawMessage, mockPublicKeyRecordRetriever);
-            Assert.fail("Expected PermFail");
-        } catch (PermFailException e) {
-
-        }
-    }
-
-}
diff --git a/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java b/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java
deleted file mode 100644
index cf4129a..0000000
--- a/mailets/src/test/java/org/apache/james/jdkim/mailets/DKIMVerifyTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.jdkim.mailets;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.james.jdkim.DKIMVerifier;
-import org.apache.james.jdkim.MockPublicKeyRecordRetriever;
-import org.apache.james.jdkim.exceptions.FailException;
-import org.apache.mailet.Mail;
-import org.apache.mailet.Mailet;
-import org.apache.mailet.base.test.FakeMail;
-import org.apache.mailet.base.test.FakeMailContext;
-import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DKIMVerifyTest {
-
-    @Test
-    public void testDKIMVerifyPass() throws MessagingException, IOException,
-            FailException {
-        String message = "DKIM-Signature: v=1; d=example.com; t=1284762805; b=ZFfwSIzTQM7k9syRnl9VfQh0/dr99euvBe1gn/DiTrnEZjxyjzQBD2MMvowVdbHpPMtSjtCtehU9zZ3urXmj5iHKujpEkP92FEKinzElkQ2eT2zoxdg1zByPHsKPX+KjrBespAJcO2k052aOK5kIBFxpQumP4aiW7ZklBKSWMBk=; s=selector; a=rsa-sha256; bh=rHOD7fd9xnNxK7OSl5ellpQVF14NNFbOIizqtUMhnio=; h=from:to:received:received;\r\n"
-            + "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";
-
-        Mail mail = process(message);
-        
-        String attr = (String) mail.getAttribute(DKIMVerify.DKIM_AUTH_RESULT_ATTRIBUTE);
-        Assert.assertNotNull(attr);
-        Assert.assertTrue(attr.startsWith("pass"));
-    }
-
-    @Test
-    public void testDKIMVerifyFail() throws MessagingException, IOException,
-            FailException {
-        // altered message body
-        String message = "DKIM-Signature: v=1; d=example.com; t=1284762805; b=ZFfwSIzTQM7k9syRnl9VfQh0/dr99euvBe1gn/DiTrnEZjxyjzQBD2MMvowVdbHpPMtSjtCtehU9zZ3urXmj5iHKujpEkP92FEKinzElkQ2eT2zoxdg1zByPHsKPX+KjrBespAJcO2k052aOK5kIBFxpQumP4aiW7ZklBKSWMBk=; s=selector; a=rsa-sha256; bh=rHOD7fd9xnNxK7OSl5ellpQVF14NNFbOIizqtUMhnio=; h=from:to:received:received;\r\n"
-            + "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova altered\r\n";
-
-        Mail mail = process(message);
-        
-        String attr = (String) mail.getAttribute(DKIMVerify.DKIM_AUTH_RESULT_ATTRIBUTE);
-        Assert.assertNotNull(attr);
-        Assert.assertTrue(attr.startsWith("fail"));
-    }
-
-    @Test
-    public void testDKIMVerifyFailInvalid() throws MessagingException, IOException,
-            FailException {
-        // invalid version v=2
-        String message = "DKIM-Signature: v=2; d=example.com; t=1284762805; b=ZFfwSIzTQM7k9syRnl9VfQh0/dr99euvBe1gn/DiTrnEZjxyjzQBD2MMvowVdbHpPMtSjtCtehU9zZ3urXmj5iHKujpEkP92FEKinzElkQ2eT2zoxdg1zByPHsKPX+KjrBespAJcO2k052aOK5kIBFxpQumP4aiW7ZklBKSWMBk=; s=selector; a=rsa-sha256; bh=rHOD7fd9xnNxK7OSl5ellpQVF14NNFbOIizqtUMhnio=; h=from:to:received:received;\r\n"
-            + "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";
-
-        Mail mail = process(message);
-        
-        String attr = (String) mail.getAttribute(DKIMVerify.DKIM_AUTH_RESULT_ATTRIBUTE);
-        Assert.assertNotNull(attr);
-        Assert.assertTrue(attr.startsWith("fail"));
-    }
-
-    @Test
-    public void testDKIMVerifyNeutral() throws MessagingException, IOException,
-            FailException {
-        // no signatures!
-        String message = ""
-            + "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova altered\r\n";
-
-        Mail mail = process(message);
-        
-        String attr = (String) mail.getAttribute(DKIMVerify.DKIM_AUTH_RESULT_ATTRIBUTE);
-        Assert.assertNotNull(attr);
-        Assert.assertTrue(attr.startsWith("neutral"));
-    }
-
-    private Mail process(String message) throws MessagingException {
-        Mailet mailet = new DKIMVerify() {
-
-            @Override
-            public void init() throws MessagingException {
-                verifier = new DKIMVerifier(new MockPublicKeyRecordRetriever(
-                        "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
-                        "selector", "example.com"));
-            }
-            
-        };
-
-        FakeMailetConfig mci = FakeMailetConfig.builder()
-                .mailetName("Test")
-                .mailetContext(FakeMailContext.defaultContext())
-                .build();
-
-        mailet.init(mci);
-
-        Mail mail = FakeMail.builder()
-            .mimeMessage(new MimeMessage(Session
-                .getDefaultInstance(new Properties()),
-                new ByteArrayInputStream(message.getBytes())))
-            .build();
-
-        mailet.service(mail);
-        return mail;
-    }
-}
diff --git a/main/pom.xml b/main/pom.xml
index 6d6c375..20c2d0b 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -61,20 +61,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-mailet-base</artifactId>
-            <scope>test</scope>
-            <classifier>tests</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
             <artifactId>apache-mime4j-core</artifactId>
         </dependency>
         <dependency>
diff --git a/pom.xml b/pom.xml
index f1e0082..478988a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@
 
     <modules>
         <module>assemble</module>
-        <module>mailets</module>
         <module>main</module>
     </modules>
 
@@ -62,7 +61,6 @@
     </distributionManagement>
 
     <properties>
-        <apache-mailet.version>3.1.0-SNAPSHOT</apache-mailet.version>
         <apache-mime4j.version>0.8.3</apache-mime4j.version>
         <commons-codec.version>1.13</commons-codec.version>
         <commons-logging.version>1.2</commons-logging.version>
@@ -134,70 +132,6 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
-                <artifactId>apache-mailet-api</artifactId>
-                <version>${apache-mailet.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>javax.mail</groupId>
-                        <artifactId>mail</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.james</groupId>
-                <artifactId>apache-mailet-base</artifactId>
-                <version>${apache-mailet.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>javax.mail</groupId>
-                        <artifactId>mail</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.james</groupId>
-                <artifactId>apache-mailet-base</artifactId>
-                <version>${apache-mailet.version}</version>
-                <type>test-jar</type>
-                <scope>test</scope>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>javax.mail</groupId>
-                        <artifactId>mail</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.james</groupId>
-                <artifactId>apache-mailet-base</artifactId>
-                <version>${apache-mailet.version}</version>
-                <scope>test</scope>
-                <classifier>tests</classifier>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.mail</groupId>
-                        <artifactId>mail</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.james</groupId>
                 <artifactId>apache-mime4j-core</artifactId>
                 <version>${apache-mime4j.version}</version>
             </dependency>
@@ -219,11 +153,6 @@
                 <scope>test</scope>
             </dependency>
             <dependency>
-                <groupId>org.apache.james.jdkim</groupId>
-                <artifactId>apache-jdkim-mailets</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
                 <groupId>org.apache.logging.log4j</groupId>
                 <artifactId>log4j-core</artifactId>
                 <scope>runtime</scope>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message