public class MacInputStream
extends java.io.FilterInputStream
MacOutputStream
,
DigestInputStream
Modifier and Type | Field and Description |
---|---|
protected javax.crypto.Mac |
macEngine_
The MAC engine to use for MACing the data.
|
protected boolean |
macingActive_
Indicates, if this objects sends data read from this stream to the Mac
engine.
|
Constructor and Description |
---|
MacInputStream(java.io.InputStream stream,
javax.crypto.Mac macEngine)
Creates a MAC input stream, using the specified input stream
and MAC engine.
|
Modifier and Type | Method and Description |
---|---|
javax.crypto.Mac |
getMac()
Get the MAC engine used for MACing the data.
|
void |
on(boolean macingActive)
Turns the MACing on or off.
|
int |
read()
This methods reads a byte fom the underlying stream and upadtes the MAC
with this data, if the MACing is active.
|
int |
read(byte[] dataByteArray,
int offset,
int length)
This methods reads data bytes fom the underlying stream and upadtes the MAC
with this data, if the MACing is active.
|
void |
setMac(javax.crypto.Mac macEngine)
Set the MAC engine to use for MACing the data.
|
java.lang.String |
toString()
Returns a string representation of this MAC output stream.
|
protected boolean macingActive_
protected javax.crypto.Mac macEngine_
public MacInputStream(java.io.InputStream stream, javax.crypto.Mac macEngine)
stream
- The input stream to read the data from.macEngine
- The MAC engine to use for MACing the data.public javax.crypto.Mac getMac()
public void setMac(javax.crypto.Mac macEngine)
macEngine
- The MAC engine to use for MACing the data.public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- If reading from the underlaying stream fails.public int read(byte[] dataByteArray, int offset, int length) throws java.io.IOException
read
in class java.io.FilterInputStream
dataByteArray
- The array receiving the new data bytes.offset
- The offset in the data byte array to start writing the data
bytes.length
- The maximum number of bytes to read the stream.java.io.IOException
- If reading from the underlaying stream fails.public void on(boolean macingActive)
macingActive
- True, to MAC all data before writing to the underlying
stream.public java.lang.String toString()
toString
in class java.lang.Object