pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.util.streamscanner
Class OutputStreamScannerChain

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.torweg.pulse.util.streamscanner.OutputStreamScannerChain
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class OutputStreamScannerChain
extends java.io.FilterOutputStream

is a filter chain for user supplied files.

The OutputStreamScannerChain is applied for both form and WebDAV based file uploads and can of course be used in your own code.

Note: the OutputStreamScannerChain is not thread-safe.

The filter chain is configured in the main config directory ( WEB-INF/conf) by org.torweg.pulse.util.streamscanner.OutputStreamScannerChain.xml.

Version:
$Revision: 1914 $
Author:
Thomas Weber

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
OutputStreamScannerChain(java.io.OutputStream out, java.lang.String ct, User u)
          creates a new OutputStreamScannerChain for the given OutputStream.
 
Method Summary
 void close()
          closes the scanner chain and its underlying stream.
 void write(byte[] b)
          filters and then writes the given byte array to the underlying OutputStream.
 void write(byte[] b, int off, int len)
          scans and then writes len bytes from the specified byte array starting at offset off to the underlying OutputStream.
 void write(int b)
          scans and then writes the given byte to the underlying OutputStream.
 
Methods inherited from class java.io.FilterOutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputStreamScannerChain

public OutputStreamScannerChain(java.io.OutputStream out,
                                java.lang.String ct, User u)
creates a new OutputStreamScannerChain for the given OutputStream.

Parameters:
out - the OutputStream to be scanned
ct - the content-type of the scanned stream
u - the user
Method Detail

write

public void write(byte[] b)
           throws StreamException, InacceptableStreamException
filters and then writes the given byte array to the underlying OutputStream.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
b - the byte array to be scanned and written
Throws:
StreamException - on errors writing to the underlying stream
InacceptableStreamException - if the scanned stream is not acceptable (e.g. it contains a virus)

write

public void write(byte[] b,
                  int off,
                  int len)
           throws StreamException, InacceptableStreamException
scans and then writes len bytes from the specified byte array starting at offset off to the underlying OutputStream.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
b - the byte array
off - the offset
len - the length
Throws:
StreamException - on errors writing to the underlying stream
InacceptableStreamException - if the filtered stream is not acceptable (e.g. it contains a virus)

write

public void write(int b)
           throws StreamException, InacceptableStreamException
scans and then writes the given byte to the underlying OutputStream.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
b - the byte
Throws:
StreamException - on errors writing to the underlying stream
InacceptableStreamException - if the filtered stream is not acceptable (e.g. it contains a virus)

close

public void close()
           throws java.io.IOException, InacceptableStreamException
closes the scanner chain and its underlying stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException - on errors closing the underlying stream or any of the filters
InacceptableStreamException - if the filtered stream is not acceptable (e.g. it contains a virus)