- java.lang.Object
-
- java.io.OutputStream
-
- org.refcodes.security.EncryptionOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,org.refcodes.mixin.Disposable
public class EncryptionOutputStream extends OutputStream implements org.refcodes.mixin.Disposable
AEncryptionOutputStream
wraps anOutputStream
and produces output bytes by applying aEncrypter
on each byte to be written before delegating the processed vale to the givenOutputStream
. The output of theEncryptionOutputStream
can be converted back by the accordingDecryptionInputStream
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Encrypter<byte[],byte[],EncryptionException>
_encrypter
-
Constructor Summary
Constructors Constructor Description EncryptionOutputStream(OutputStream aOutputStream, Encrypter<byte[],byte[],EncryptionException> aEncrypter)
Constructs theEncryptionOutputStream
by wrapping the givenOutputStream
for the providedEncrypter
to be applied on the bytes to be written.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
dispose()
boolean
equals(Object aObj)
void
flush()
int
hashCode()
String
toString()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int value)
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
_encrypter
protected Encrypter<byte[],byte[],EncryptionException> _encrypter
-
-
Constructor Detail
-
EncryptionOutputStream
public EncryptionOutputStream(OutputStream aOutputStream, Encrypter<byte[],byte[],EncryptionException> aEncrypter)
Constructs theEncryptionOutputStream
by wrapping the givenOutputStream
for the providedEncrypter
to be applied on the bytes to be written.- Parameters:
aOutputStream
- TheOutputStream
to be wrapped.aEncrypter
- TheEncrypter
to be applied to the bytes to be written.
-
-
Method Detail
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
public void write(int value) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
-