com.croftsoft.core.util.cache.secure
Class SecureInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.croftsoft.core.util.cache.secure.SecureInputStream
All Implemented Interfaces:
Closeable

public class SecureInputStream
extends FilterInputStream

A FilterInputStream which will throw a SecurityException if the stream content does not have the digest expected.

Version:
1999-04-13
See Also:
DigestInputStream, MessageDigest
Author:
David Wallace Croft

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
SecureInputStream(InputStream inputStream, String algorithm, byte[] digest)
           
 
Method Summary
 int read()
           
 int read(byte[] byteArray, int offset, int length)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureInputStream

public SecureInputStream(InputStream inputStream,
                         String algorithm,
                         byte[] digest)
                  throws NoSuchAlgorithmException
Parameters:
algorithm - The MessageDigest algorithm to use.
digest - The expected digest.
Throws:
NoSuchAlgorithmException
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
SecurityException - If the end of the stream is reached and the digest is not what is expected.
IOException

read

public int read(byte[] byteArray,
                int offset,
                int length)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
SecurityException - If the end of the stream is reached and the digest is not what is expected.
IOException

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)