Class MultiDigestInputStreamWrapper


  • public class MultiDigestInputStreamWrapper
    extends Object
    Wrapper for an InputStream that allows for the computation and evaluation of multiple digests at once
    Author:
    bbpennel
    • Constructor Detail

      • MultiDigestInputStreamWrapper

        public MultiDigestInputStreamWrapper​(InputStream sourceStream,
                                             Collection<URI> digests,
                                             Collection<DigestAlgorithm> wantDigests)
        Construct a MultiDigestInputStreamWrapper
        Parameters:
        sourceStream - the original source input stream
        digests - collection of digests for the input stream
        wantDigests - list of additional digest algorithms to compute for the input stream
    • Method Detail

      • getInputStream

        public InputStream getInputStream()
        Get the InputStream wrapped to produce the requested digests
        Returns:
        wrapped input stream
      • checkFixity

        public void checkFixity()
                         throws InvalidChecksumException
        After consuming the inputstream, verify that all of the computed digests matched the provided digests. Note: the wrapped InputStream will be consumed if it has not already been read.
        Throws:
        InvalidChecksumException - thrown if any of the digests did not match
      • getDigests

        public List<URIgetDigests()
        Returns the list of digests calculated for the wrapped InputStream Note: the wrapped InputStream will be consumed if it has not already been read.
        Returns:
        list of digests calculated from the wrapped InputStream, in URN format.
      • getDigest

        public String getDigest​(DigestAlgorithm alg)
        Get the digest calculated for the provided algorithm
        Parameters:
        alg - algorithm of the digest to retrieve
        Returns:
        the calculated digest, or null if no digest of that type was calculated