org.apache.james.smtpserver
Class SizeLimitedInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.apache.james.smtpserver.SizeLimitedInputStream

public class SizeLimitedInputStream
extends java.io.InputStream

This class wraps an underlying input stream, limiting the allowable size of an incoming MimeMessage. The size limit is configured in the conf file, and when the limit is reached, a MessageSizeException is thrown.

Author:
Matthew Pangaro

Constructor Summary
SizeLimitedInputStream(java.io.InputStream in, long maxmessagesize)
          Constructor for the stream.
 
Method Summary
 int read()
          Overrides the read method of InputStream to call the read() method of the wrapped input stream.
 int read(byte[] b, int off, int len)
          Overrides the read method of InputStream to call the read() method of the wrapped input stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeLimitedInputStream

public SizeLimitedInputStream(java.io.InputStream in,
                              long maxmessagesize)
Constructor for the stream. Wraps an underlying stream.

Parameters:
in - InputStream to use as basis for new Stream.
maxmessagesize - Message size limit, in Kilobytes
Method Detail

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides the read method of InputStream to call the read() method of the wrapped input stream.

Overrides:
read in class java.io.InputStream
Returns:
Returns the number of bytes read.
Throws:
java.io.IOException - Throws a MessageSizeException, which is a sub-type of IOException

read

public int read()
         throws java.io.IOException
Overrides the read method of InputStream to call the read() method of the wrapped input stream.

Specified by:
read in class java.io.InputStream
Returns:
Returns the int character value of the byte read.
Throws:
java.io.IOException - Throws a MessageSizeException, which is a sub-type of IOException.


"Copyright © 2001 Apache Jakarta Project. All Rights Reserved."