Package org.owasp.esapi.waf.internal
Class InterceptingServletOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- javax.servlet.ServletOutputStream
-
- org.owasp.esapi.waf.internal.InterceptingServletOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class InterceptingServletOutputStream extends javax.servlet.ServletOutputStreamThis class was inspired by ModSecurity for Java by Ivan Ristic. We hook the response stream and queue up all outbound data so that we can apply egress rules. For efficiency, we decide off the bat if we need to buffer responses to accomplish any of the rules in the policy file. If not, we just forward everything through, otherwise we write data to our byte stream that we will eventually forward en totale to the user agent.- Author:
- Arshan Dabirsiaghi
-
-
Constructor Summary
Constructors Constructor Description InterceptingServletOutputStream(javax.servlet.ServletOutputStream os, boolean buffered)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcommit()voidflush()byte[]getResponseBytes()booleanisReady()voidreset()voidsetResponseBytes(byte[] responseBytes)voidsetWriteListener(javax.servlet.WriteListener listener)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int i)
-
-
-
Method Detail
-
reset
public void reset() throws java.io.IOException- Throws:
java.io.IOException
-
getResponseBytes
public byte[] getResponseBytes() throws java.io.IOException- Throws:
java.io.IOException
-
setResponseBytes
public void setResponseBytes(byte[] responseBytes) throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(int i) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
commit
public void commit() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
isReady
public boolean isReady()
- Specified by:
isReadyin classjavax.servlet.ServletOutputStream
-
setWriteListener
public void setWriteListener(javax.servlet.WriteListener listener)
- Specified by:
setWriteListenerin classjavax.servlet.ServletOutputStream
-
-