|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--java.io.FilterInputStream | +--com.novell.java.security.DigestInputStream
Provides a transparent stream that updates the associated message digest using the bits going through the stream. To complete the message digest computation, call one of the digest methods on the associated message digest after calling one of this digest input stream's read() methods.
It is possible to turn this stream on or off by calling the on() method. When it is on, a call to read() results in an update on the message digest. But when it is off, the message digest is not updated. The default is for the stream to be on.
Note that digest objects can compute only one digest, so that in order to compute intermediate digests, you should retain a handle on the digest object and clone it for each digest to be computed, leaving the orignal digest untouched.
MessageDigest
,
DigestOutputStream
Constructor Summary | |
DigestInputStream(java.io.InputStream stream,
MessageDigest digest)
Creates a digest input stream using the specified input stream and message digest. |
Method Summary | |
MessageDigest |
getMessageDigest()
Returns the message digest associated with this stream. |
void |
on(boolean on)
Turns the digest function ON (default) or OFF. |
int |
read()
Reads a byte and updates the message digest if the digest function is on. |
int |
read(byte[] b,
int off,
int len)
Reads into a byte array and updates the message digest if the digest function is on. |
void |
setMessageDigest(MessageDigest digest)
Associates the specified message digest with this stream. |
java.lang.String |
toString()
Prints a String representation of this digest input stream and its associated message digest object. |
Methods inherited from class java.io.FilterInputStream |
available,
close,
mark,
markSupported,
read,
reset,
skip |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public DigestInputStream(java.io.InputStream stream, MessageDigest digest)
stream
- The input stream.digest
- The message digest to associate with this stream.Method Detail |
public MessageDigest getMessageDigest()
public void setMessageDigest(MessageDigest digest)
digest
- The message digest to be associated with this
stream.public int read() throws java.io.IOException
MessageDigest.update(byte)
public int read(byte[] b, int off, int len) throws java.io.IOException
b
- The array into which the data is read.off
- The starting offset into the byte array (b[])
where the data should be placed.len
- The maximum number of bytes to be read from the
input stream into the byte array (b[]), starting
at offset off.MessageDigest.update(byte[], int, int)
public void on(boolean on)
on
- A boolean set to TRUE to set the digest function ON,
or false to turn the digest function off.public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |