Package com.ibm.fhir.bucket.scanner
Class Sha256InputStreamDecorator
- java.lang.Object
 - 
- java.io.InputStream
 - 
- com.ibm.fhir.bucket.scanner.Sha256InputStreamDecorator
 
 
 
- 
- All Implemented Interfaces:
 Closeable,AutoCloseable
public class Sha256InputStreamDecorator extends InputStream
Decorates an InputStream with the ability to compute a SHA-256 hash of the bytes read from the stream. Assumes that the entire stream is read. If buffering is done further up-stream, then obviously the digest may not represent what was actually read by the consumer, because the buffer may read bytes from this stream than were actually consumed. Caveat emptor. 
- 
- 
Constructor Summary
Constructors Constructor Description Sha256InputStreamDecorator(InputStream delegate)Public Constructor 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()StringgetBase64Hash()Compute the digest.intread()intread(byte[] b, int off, int len)- 
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
Sha256InputStreamDecorator
public Sha256InputStreamDecorator(InputStream delegate)
Public Constructor- Parameters:
 delegate- the delegate stream we are decorating
 
 - 
 
- 
Method Detail
- 
getBase64Hash
public String getBase64Hash()
Compute the digest. Resets the state- Returns:
 
 
- 
read
public int read() throws IOException- Specified by:
 readin classInputStream- Throws:
 IOException
 
- 
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
 readin classInputStream- Throws:
 IOException
 
- 
close
public void close() throws IOException- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Overrides:
 closein classInputStream- Throws:
 IOException
 
 - 
 
 -