Class DSSMessageDigestCalculator

java.lang.Object
eu.europa.esig.dss.spi.DSSMessageDigestCalculator

public class DSSMessageDigestCalculator extends Object
This class is used to compute DSSMessageDigest based on the provided input
  • Constructor Details

    • DSSMessageDigestCalculator

      public DSSMessageDigestCalculator(DigestAlgorithm digestAlgorithm)
      Default constructor with a single digest algorithm
      Parameters:
      digestAlgorithm - DigestAlgorithm to be used for message-digest computation
    • DSSMessageDigestCalculator

      public DSSMessageDigestCalculator(Collection<DigestAlgorithm> digestAlgorithms)
      Constructor with multiple digest algorithms
      Parameters:
      digestAlgorithms - DigestAlgorithm to be used for message-digest computation
  • Method Details

    • update

      public void update(byte byteToAdd)
      Updates the digest using the provided byte
      Parameters:
      byteToAdd - byte to be added for digest computation
    • update

      public void update(byte[] bytes)
      Updates the digest using the provided array of bytes
      Parameters:
      bytes - array of bytes
    • update

      public void update(byte[] bytes, int offset, int length)
      Updates the bytes starting from the offset and a specified length
      Parameters:
      bytes - array of bytes
      offset - to start bytes update from
      length - the length of bytes array to be updated
    • update

      public void update(InputStream inputStream) throws IOException
      Updates the digest by reading the provided InputStream. NOTE: the method consumes the InputStream, and closes it after.
      Parameters:
      inputStream - InputStream
      Throws:
      IOException - if an error is thrown on InputStream reading
    • getMessageDigest

      @Deprecated public DSSMessageDigest getMessageDigest()
      Deprecated.
      since DSS 6.3. Please use #getMessageDigest(DigestAlgorithm) method instead.
      Returns the DSSMessageDigest accordingly to the current state. This method resets the state of message-digest.
      Returns:
      DSSMessageDigest
    • getMessageDigest

      public DSSMessageDigest getMessageDigest(DigestAlgorithm digestAlgorithm)
      Returns the DSSMessageDigest accordingly to the given digestAlgorithm This method resets the state of message-digest.
      Parameters:
      digestAlgorithm - DigestAlgorithm to get a corresponding DSSMessageDigest for
      Returns:
      DSSMessageDigest
    • getOutputStream

      public OutputStream getOutputStream()
      Gets OutputStream that can be used to calculate digest on the fly. This method will update the digest within the current instance of DSSMessageDigestCalculator, when the returned OutputStream is being updated.
      Returns:
      OutputStream
    • getOutputStream

      public OutputStream getOutputStream(OutputStream outputStream)
      Gets OutputStream that can be used to calculate digest on the fly. This method will write the binaries into the provided outputStream as well as will update the digest within the current instance of DSSMessageDigestCalculator
      Parameters:
      outputStream - to be embedded into
      Returns:
      OutputStream