class MdInputStream extends InputStream
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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) |
mark, markSupported, read, reset
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
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 contentsNullPointerException
- if any of the arguments is nullpublic 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 interface AutoCloseable
close
in class InputStream
IOException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.