You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2006/05/01 18:56:09 UTC

svn commit: r398634 [3/3] - in /geronimo/branches/1.1/modules/javamail-transport/src: java/org/apache/geronimo/javamail/authentication/ java/org/apache/geronimo/javamail/transport/smtp/ java/org/apache/geronimo/javamail/util/ resources/META-INF/

Modified: geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java?rev=398634&r1=398633&r2=398634&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java (original)
+++ geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java Mon May  1 09:56:06 2006
@@ -18,8 +18,8 @@
 package org.apache.geronimo.javamail.transport.smtp;
 
 /**
- *  General purpose Exception
- *
+ * General purpose Exception
+ * 
  * @version $Id$
  */
 class SMTPTransportException extends Exception {
@@ -32,11 +32,11 @@
         super(s);
     }
 
-    SMTPTransportException(String s, Throwable t) {
-        super(s,t);
+    SMTPTransportException(String s, Exception t) {
+        super(s, t);
     }
 
-    SMTPTransportException(Throwable t) {
-        super(t);
+    SMTPTransportException(Exception t) {
+        super("SMTP Transport error", t);
     }
 }

Added: geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/MIMEOutputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/MIMEOutputStream.java?rev=398634&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/MIMEOutputStream.java (added)
+++ geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/MIMEOutputStream.java Mon May  1 09:56:06 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.javamail.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An implementation of an OutputStream that performs MIME linebreak
+ * canonicalization and "byte-stuff" so that data content does not get mistaken
+ * for a message data-end marker (CRLF.CRLF)l
+ * 
+ * @version $Rev: 390524 $ $Date: 2006-03-31 17:24:52 -0500 (Fri, 31 Mar 2006) $
+ */
+public class MIMEOutputStream extends OutputStream {
+
+    // the wrappered output stream.
+    protected OutputStream out;
+
+    // last character we handled...used to recongnize line breaks.
+    protected int lastWrite = -1;
+
+    // a flag to indicate we've just processed a line break. This is used for
+    // byte stuffing purposes. This
+    // is initially true, because if the first character of the content is a
+    // period, we need to byte-stuff
+    // immediately.
+    protected boolean atLineBreak = true;
+
+    /**
+     * Create an output stream that writes to the target output stream.
+     * 
+     * @param out
+     *            The wrapped output stream.
+     */
+    public MIMEOutputStream(OutputStream out) {
+        this.out = out;
+    }
+
+    // in order for this to work, we only need override the single character
+    // form, as the others
+    // funnel through this one by default.
+    public void write(int ch) throws IOException {
+        // if this is a CR character, always write out a full sequence, and
+        // remember that we just did this.
+        if (ch == '\r') {
+            out.write((byte) '\r');
+            out.write((byte) '\n');
+            // we've just taken a break;
+            atLineBreak = true;
+        }
+        // if this is a new line, then we need to determine if this is a loner
+        // or part of a CRLF sequence.
+        else if (ch == '\n') {
+            // is this a lone ranger?
+            if (lastWrite != '\r') {
+                // write the full CRLF sequence.
+                out.write((byte) '\r');
+                out.write((byte) '\n');
+            }
+            // regardless of whether we wrote something or not, we're still at a
+            // line break.
+            atLineBreak = true;
+        }
+        // potential byte-stuffing situation?
+        else if (ch == '.') {
+            // ok, this is a potential stuff situation. Did we just have a line
+            // break? Double up the character.
+            if (atLineBreak) {
+                out.write('.');
+            }
+            out.write('.');
+            atLineBreak = false;
+        } else {
+            // just write this out and flip the linebreak flag.
+            out.write(ch);
+            atLineBreak = false;
+        }
+        // remember this last one for CRLF tracking purposes.
+        lastWrite = ch;
+    }
+}

Added: geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceInputStream.java?rev=398634&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceInputStream.java (added)
+++ geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceInputStream.java Mon May  1 09:56:06 2006
@@ -0,0 +1,119 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.javamail.util;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.geronimo.mail.util.QuotedPrintableEncoderStream;
+
+/**
+ * @version $Rev: 390524 $ $Date: 2006-03-31 17:24:52 -0500 (Fri, 31 Mar 2006) $
+ */
+public class TraceInputStream extends FilterInputStream {
+    // the current debug setting
+    protected boolean debug = false;
+
+    // the target trace output stream.
+    protected OutputStream traceStream;
+
+    /**
+     * Construct a debug trace stream.
+     * 
+     * @param in
+     *            The source input stream.
+     * @param traceStream
+     *            The side trace stream to which trace data gets written.
+     * @param encode
+     *            Indicates whether we wish the Trace data to be Q-P encoded.
+     */
+    public TraceInputStream(InputStream in, OutputStream traceStream, boolean debug, boolean encode) {
+        super(in);
+        this.debug = debug;
+        if (encode) {
+            this.traceStream = new QuotedPrintableEncoderStream(traceStream);
+        } else {
+            this.traceStream = traceStream;
+        }
+    }
+
+    /**
+     * Set the current setting of the debug trace stream debug flag.
+     * 
+     * @param d
+     *            The new debug flag settings.
+     */
+    public void setDebug(boolean d) {
+        debug = d;
+    }
+
+    /**
+     * Reads up to <code>len</code> bytes of data from this input stream into
+     * an array of bytes. This method blocks until some input is available.
+     * <p>
+     * This method simply performs <code>in.read(b, off, len)</code> and
+     * returns the result.
+     * 
+     * @param b
+     *            the buffer into which the data is read.
+     * @param off
+     *            the start offset of the data.
+     * @param len
+     *            the maximum number of bytes read.
+     * @return the total number of bytes read into the buffer, or
+     *         <code>-1</code> if there is no more data because the end of the
+     *         stream has been reached.
+     * @exception IOException
+     *                if an I/O error occurs.
+     * @see java.io.FilterInputStream#in
+     */
+    public int read(byte b[], int off, int len) throws IOException {
+        int count = in.read(b, off, len);
+        if (debug && count > 0) {
+            traceStream.write(b, off, count);
+        }
+        return count;
+    }
+
+    /**
+     * Reads the next byte of data from this input stream. The value byte is
+     * returned as an <code>int</code> in the range <code>0</code> to
+     * <code>255</code>. If no byte is available because the end of the
+     * stream has been reached, the value <code>-1</code> is returned. This
+     * method blocks until input data is available, the end of the stream is
+     * detected, or an exception is thrown.
+     * <p>
+     * This method simply performs <code>in.read()</code> and returns the
+     * result.
+     * 
+     * @return the next byte of data, or <code>-1</code> if the end of the
+     *         stream is reached.
+     * @exception IOException
+     *                if an I/O error occurs.
+     * @see java.io.FilterInputStream#in
+     */
+    public int read() throws IOException {
+        int b = in.read();
+        if (debug) {
+            traceStream.write(b);
+        }
+        return b;
+    }
+}

Added: geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceOutputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceOutputStream.java?rev=398634&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceOutputStream.java (added)
+++ geronimo/branches/1.1/modules/javamail-transport/src/java/org/apache/geronimo/javamail/util/TraceOutputStream.java Mon May  1 09:56:06 2006
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.javamail.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.geronimo.mail.util.QuotedPrintableEncoderStream;
+
+/**
+ * @version $Rev: 390524 $ $Date: 2006-03-31 17:24:52 -0500 (Fri, 31 Mar 2006) $
+ */
+public class TraceOutputStream extends FilterOutputStream {
+    // the current debug setting
+    protected boolean debug = false;
+
+    // the target trace output stream.
+    protected OutputStream traceStream;
+
+    /**
+     * Construct a debug trace stream.
+     * 
+     * @param out
+     *            The target out put stream.
+     * @param traceStream
+     *            The side trace stream to which trace data gets written.
+     * @param encode
+     *            Indicates whether we wish the Trace data to be Q-P encoded.
+     */
+    public TraceOutputStream(OutputStream out, OutputStream traceStream, boolean debug, boolean encode) {
+        super(out);
+        this.debug = debug;
+        if (encode) {
+            this.traceStream = new QuotedPrintableEncoderStream(traceStream);
+        } else {
+            this.traceStream = traceStream;
+        }
+    }
+
+    /**
+     * Set the current setting of the debug trace stream debug flag.
+     * 
+     * @param d
+     *            The new debug flag settings.
+     */
+    public void setDebug(boolean d) {
+        debug = d;
+    }
+
+    /**
+     * Writes <code>len</code> bytes from the specified <code>byte</code>
+     * array starting at offset <code>off</code> to this output stream.
+     * <p>
+     * The <code>write</code> method of <code>FilterOutputStream</code>
+     * calls the <code>write</code> method of one argument on each
+     * <code>byte</code> to output.
+     * <p>
+     * Note that this method does not call the <code>write</code> method of
+     * its underlying input stream with the same arguments. Subclasses of
+     * <code>FilterOutputStream</code> should provide a more efficient
+     * implementation of this method.
+     * 
+     * @param b
+     *            the data.
+     * @param off
+     *            the start offset in the data.
+     * @param len
+     *            the number of bytes to write.
+     * @exception IOException
+     *                if an I/O error occurs.
+     * @see java.io.FilterOutputStream#write(int)
+     */
+    public void write(byte b[], int off, int len) throws IOException {
+        if (debug) {
+            for (int i = 0; i < len; i++) {
+                traceStream.write(b[off + i]);
+            }
+        }
+        super.write(b, off, len);
+    }
+
+    /**
+     * Writes the specified <code>byte</code> to this output stream.
+     * <p>
+     * The <code>write</code> method of <code>FilterOutputStream</code>
+     * calls the <code>write</code> method of its underlying output stream,
+     * that is, it performs <tt>out.write(b)</tt>.
+     * <p>
+     * Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>.
+     * 
+     * @param b
+     *            the <code>byte</code>.
+     * @exception IOException
+     *                if an I/O error occurs.
+     */
+    public void write(int b) throws IOException {
+        if (debug) {
+            traceStream.write(b);
+        }
+        super.write(b);
+    }
+}

Modified: geronimo/branches/1.1/modules/javamail-transport/src/resources/META-INF/javamail.default.providers
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/javamail-transport/src/resources/META-INF/javamail.default.providers?rev=398634&r1=398633&r2=398634&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/javamail-transport/src/resources/META-INF/javamail.default.providers (original)
+++ geronimo/branches/1.1/modules/javamail-transport/src/resources/META-INF/javamail.default.providers Mon May  1 09:56:06 2006
@@ -6,4 +6,5 @@
 #
 # $Rev$ $Date$
 #
-protocol=smtp; type=transport; class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport; vendor=Apache Software Foundation; version=1.0
+protocol=smtp; type=transport; class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport; vendor=Apache Software Foundation; version=1.1
+protocol=smtps; type=transport; class=org.apache.geronimo.javamail.transport.smtp.SMTPSTransport; vendor=Apache Software Foundation; version=1.1