|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
net.jini.url.httpmd.MdInputStream
class MdInputStream
An input stream that checks the contents of another input stream against a message digest. The stream throws WrongMessageDigestException if the end of the other input stream is reached and the contents did not have the expected message digest. The message digest is not checked unless the end of the input stream is reached.
Field Summary | |
---|---|
private boolean |
checked
Set to true when the contents have been checked against the message digest. |
private byte[] |
expectedDigest
The expected digest. |
private String |
failed
The exception message if the message digest was incorrect, or null if no exception should be thrown. |
private InputStream |
in
The input stream whose contents should be checked. |
private static Logger |
logger
Logger. |
private MessageDigest |
messageDigest
The object to use to compute the message digest of the stream contents. |
private static int |
SKIP_BUFFER_SIZE
The size buffer to use when skipping input. |
private byte[] |
skipBuffer
Set to the buffer to use when skipping input. |
private URL |
url
The HTTPMD URL associated with the input stream being checked. |
Constructor Summary | |
---|---|
MdInputStream(URL url,
InputStream in,
MessageDigest messageDigest,
byte[] expectedDigest)
Creates an input stream that checks the contents of another input stream against a message digest. |
Method Summary | |
---|---|
int |
available()
|
private void |
checkDigest()
Checks the message digest. |
private void |
checkFailed()
Throws an exception if the message digest was found to be incorrect. |
void |
close()
|
int |
read()
|
int |
read(byte[] b,
int off,
int len)
|
long |
skip(long n)
|
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger logger
private static final int SKIP_BUFFER_SIZE
private final URL url
private final InputStream in
private final MessageDigest messageDigest
private final byte[] expectedDigest
private byte[] skipBuffer
private boolean checked
private String failed
Constructor Detail |
---|
MdInputStream(URL url, InputStream in, MessageDigest messageDigest, byte[] expectedDigest)
url
- the HTTPMD URL associated with the input stream being checkedin
- the input stream whose contents should be checkedmessageDigest
- the object to use for computing the message digest
of the stream contentsexpectedDigest
- the expected message digest of the stream contents
NullPointerException
- if any of the arguments is nullMethod Detail |
---|
public int read() throws IOException
read
in class InputStream
IOException
private void checkFailed() throws WrongMessageDigestException
WrongMessageDigestException
private void checkDigest() throws WrongMessageDigestException
WrongMessageDigestException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |