edu.emory.mathcs.util.security.io
Class SecureByteArrayOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
edu.emory.mathcs.util.security.io.SecureByteArrayOutputStream
- public final class SecureByteArrayOutputStream
- extends java.io.ByteArrayOutputStream
Variant of ByteArrayOutputStream that ensures that all data is cleared
from temporary arrays before they are unreferenced. Hence, this class can
be safely used to convert sensitive information into byte arrays, provided
that it is closed
after use.
- Version:
- 1.0
- Author:
- Dawid Kurzyniec
Fields inherited from class java.io.ByteArrayOutputStream |
buf, count |
Method Summary |
void |
close()
Closing a SecureByteArrayOutputStream causes it to be reset() ,
that is, all data is discarded. |
void |
reset()
Resets the count field of this byte array output
stream to zero and clears up the entire buffer with zeros, so that all
currently accumulated output in the
ouput stream is discarded. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.io.ByteArrayOutputStream |
size, toByteArray, toString, toString, toString, writeTo |
Methods inherited from class java.io.OutputStream |
flush, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
SecureByteArrayOutputStream
public SecureByteArrayOutputStream()
SecureByteArrayOutputStream
public SecureByteArrayOutputStream(int size)
write
public void write(int b)
write
public void write(byte[] b,
int off,
int len)
reset
public void reset()
- Resets the
count
field of this byte array output
stream to zero and clears up the entire buffer with zeros, so that all
currently accumulated output in the
ouput stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.
- See Also:
ByteArrayInputStream.count
close
public void close()
throws java.io.IOException
- Closing a SecureByteArrayOutputStream causes it to be
reset()
,
that is, all data is discarded.
- Throws:
java.io.IOException