Package org.fcrepo.persistence.common
Class MultiDigestInputStreamWrapper
- java.lang.Object
-
- org.fcrepo.persistence.common.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 Summary
Constructors Constructor Description MultiDigestInputStreamWrapper(InputStream sourceStream, Collection<URI> digests, Collection<DigestAlgorithm> wantDigests)
Construct a MultiDigestInputStreamWrapper
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkFixity()
After consuming the inputstream, verify that all of the computed digests matched the provided digests.String
getDigest(DigestAlgorithm alg)
Get the digest calculated for the provided algorithmList<URI>
getDigests()
Returns the list of digests calculated for the wrapped InputStream Note: the wrapped InputStream will be consumed if it has not already been read.InputStream
getInputStream()
Get the InputStream wrapped to produce the requested digests
-
-
-
Constructor Detail
-
MultiDigestInputStreamWrapper
public MultiDigestInputStreamWrapper(InputStream sourceStream, Collection<URI> digests, Collection<DigestAlgorithm> wantDigests)
Construct a MultiDigestInputStreamWrapper- Parameters:
sourceStream
- the original source input streamdigests
- collection of digests for the input streamwantDigests
- 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<URI> getDigests()
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
-
-