Package org.bouncycastle.tsp.ers
Class ERSCachingData
- java.lang.Object
-
- org.bouncycastle.tsp.ers.ERSCachingData
-
- All Implemented Interfaces:
ERSData
- Direct Known Subclasses:
ERSByteData,ERSDataGroup,ERSFileData,ERSInputStreamData
public abstract class ERSCachingData extends java.lang.Object implements ERSData
BaseERSDataimplementation that caches calculated hashes, keyed by digest algorithm and previous-chain hash, so the (potentially expensive) hash of a data object is computed only once per combination. Subclasses supply the actual hash incalculateHash(DigestCalculator, byte[]).
-
-
Constructor Summary
Constructors Constructor Description ERSCachingData()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte[]calculateHash(DigestCalculator digestCalculator, byte[] previousChainHash)Compute the hash for this data object.byte[]getHash(DigestCalculator digestCalculator, byte[] previousChainHash)Return the hash for this data object, computing it (via the subclass) on first request and returning the cached value thereafter.
-
-
-
Method Detail
-
getHash
public byte[] getHash(DigestCalculator digestCalculator, byte[] previousChainHash)
Return the hash for this data object, computing it (via the subclass) on first request and returning the cached value thereafter.- Specified by:
getHashin interfaceERSData- Parameters:
digestCalculator- theDigestCalculatorto use for computing the hash.previousChainHash- hash from an earlier chain to fold in, or null.- Returns:
- the calculated hash for this data object.
-
calculateHash
protected abstract byte[] calculateHash(DigestCalculator digestCalculator, byte[] previousChainHash)
Compute the hash for this data object. Implemented by subclasses; the result is cached bygetHash(DigestCalculator, byte[]).- Parameters:
digestCalculator- the digest calculator to use.previousChainHash- hash from an earlier chain to fold in, or null.- Returns:
- the calculated hash.
-
-