upgrade to mime4j 0.7 final
remove of "src" assembly (it is already generated by our apache parent pom during release)
renamed LICENSE/NOTICE to remove the .txt extension (so the source package from the parent pom is ok)
removed sun's javamail dependency in favor of geronimo deps, so we can build without external repositories.
created a CRLFOutputStream (copied from the one in james-mailbox, previously in server/util/stream) so to not use the one from javamail com.sun package anymore.

git-svn-id: https://svn.apache.org/repos/asf/james/jdkim/trunk@1150625 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/LICENSE.txt b/LICENSE
similarity index 100%
rename from LICENSE.txt
rename to LICENSE
diff --git a/NOTICE.txt b/NOTICE
similarity index 100%
rename from NOTICE.txt
rename to NOTICE
diff --git a/assemble/src/assemble/bin.xml b/assemble/src/assemble/bin.xml
index 767a682..b1b6eea 100644
--- a/assemble/src/assemble/bin.xml
+++ b/assemble/src/assemble/bin.xml
@@ -29,8 +29,8 @@
       <directory>..</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>LICENSE.*</include>
-        <include>NOTICE.*</include>
+        <include>LICENSE</include>
+        <include>NOTICE</include>
         <include>RELEASE_NOTES.txt</include>
       </includes>
     </fileSet>
diff --git a/mailets/pom.xml b/mailets/pom.xml
index a23a100..313dc1d 100644
--- a/mailets/pom.xml
+++ b/mailets/pom.xml
@@ -90,12 +90,12 @@
             <scope>test</scope>

         </dependency>

         <dependency>

-            <groupId>javax.mail</groupId>

-            <artifactId>mail</artifactId>

+            <groupId>org.apache.geronimo.specs</groupId>

+            <artifactId>geronimo-activation_1.1_spec</artifactId>

         </dependency>

         <dependency>

-            <groupId>javax.activation</groupId>

-            <artifactId>activation</artifactId>

+            <groupId>org.apache.geronimo.javamail</groupId>

+            <artifactId>geronimo-javamail_1.4_mail</artifactId>

         </dependency>

         <dependency>

             <groupId>ca.juliusdavies</groupId>

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
new file mode 100644
index 0000000..b686b72
--- /dev/null
+++ b/mailets/src/main/java/org/apache/james/jdkim/mailets/CRLFOutputStream.java
@@ -0,0 +1,161 @@
+/****************************************************************
+ * 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/DKIMSign.java b/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java
index 856f980..b4d8a72 100644
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java
+++ b/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMSign.java
@@ -44,8 +44,6 @@
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMailet;
 
-import com.sun.mail.util.CRLFOutputStream;
-
 /**
  * This mailet sign a message using the DKIM protocol
  * If the privateKey is encoded using a password then you can pass
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
index 1dc0e2c..68c0cf9 100644
--- a/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
+++ b/mailets/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
@@ -34,8 +34,6 @@
 import org.apache.mailet.Mail;

 import org.apache.mailet.base.GenericMailet;

 

-import com.sun.mail.util.CRLFOutputStream;

-

 /**

  * This mailet verify a message using the DKIM protocol

  * 

diff --git a/main/pom.xml b/main/pom.xml
index 2d59d29..528c1ca 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -56,12 +56,12 @@
             <artifactId>junit</artifactId>
         </dependency>
         <dependency>
-            <groupId>javax.mail</groupId>
-            <artifactId>mail</artifactId>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-activation_1.1_spec</artifactId>
         </dependency>
         <dependency>
-            <groupId>javax.activation</groupId>
-            <artifactId>activation</artifactId>
+            <groupId>org.apache.geronimo.javamail</groupId>
+            <artifactId>geronimo-javamail_1.4_mail</artifactId>
         </dependency>
         <dependency>
             <groupId>commons-codec</groupId>
diff --git a/pom.xml b/pom.xml
index 94cf733..fe8e5a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,14 +80,14 @@
                 <scope>test</scope>

             </dependency>

             <dependency>

-                <groupId>javax.mail</groupId>

-                <artifactId>mail</artifactId>

-                <version>1.4.1</version>

+                <groupId>org.apache.geronimo.specs</groupId>

+                <artifactId>geronimo-activation_1.1_spec</artifactId>

+                <version>1.0.2</version>

             </dependency>

             <dependency>

-                <groupId>javax.activation</groupId>

-                <artifactId>activation</artifactId>

-                <version>1.1.1</version>

+                <groupId>org.apache.geronimo.javamail</groupId>

+                <artifactId>geronimo-javamail_1.4_mail</artifactId>

+                <version>1.6</version>

             </dependency>

             <dependency>

                 <groupId>commons-codec</groupId>

@@ -121,6 +121,16 @@
                 <groupId>org.apache.james</groupId>

                 <artifactId>apache-mailet-base</artifactId>

                 <version>1.1</version>

+                <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>

@@ -128,6 +138,16 @@
                 <version>1.1</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>

@@ -135,11 +155,31 @@
                 <version>1.1</version>

                 <type>test-jar</type>

                 <scope>test</scope>

+                <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-mailet</artifactId>

                 <version>2.4</version>

+                <exclusions>

+                    <exclusion>

+                        <groupId>javax.mail</groupId>

+                        <artifactId>mail</artifactId>

+                    </exclusion>

+                    <exclusion>

+                        <groupId>javax.activation</groupId>

+                        <artifactId>activation</artifactId>

+                    </exclusion>

+                </exclusions>

             </dependency>

             <dependency>

                 <groupId>log4j</groupId>

@@ -150,7 +190,7 @@
             <dependency>

                 <groupId>dnsjava</groupId>

                 <artifactId>dnsjava</artifactId>

-                <version>2.0.8</version>

+                <version>2.1.1</version>

             </dependency>

             <dependency>

                 <groupId>org.apache.james.jdkim</groupId>

@@ -177,12 +217,12 @@
             <dependency>

                 <groupId>org.apache.james</groupId>

                 <artifactId>apache-mime4j-core</artifactId>

-                <version>0.7-SNAPSHOT</version>

+                <version>0.7</version>

             </dependency>

             <dependency>

                 <groupId>org.apache.james</groupId>

                 <artifactId>apache-mime4j-dom</artifactId>

-                <version>0.7-SNAPSHOT</version>

+                <version>0.7</version>

             </dependency>

         </dependencies>

     </dependencyManagement>