Class DigestDocument

java.lang.Object
eu.europa.esig.dss.model.CommonDocument
eu.europa.esig.dss.model.DigestDocument
All Implemented Interfaces:
DSSDocument, Serializable

public class DigestDocument extends CommonDocument
Digest representation of a DSSDocument. It can be used to handle a large file to be signed. The computation of the digest associated to the file can be done externally.
See Also:
  • Field Summary

    Fields inherited from class eu.europa.esig.dss.model.CommonDocument

    digestMap, mimeType, name
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates DigestDocument with an empty digest map.
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue)
    Creates DigestDocument with a digest provided in a form of byte array
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue, String name)
    Creates DigestDocument with a digest provided in a form of byte array with a specified document name
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
    Creates DigestDocument with a digest provided in a form of byte array with a specified name and mimeType of the document
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest)
    Creates DigestDocument with a digest provided in a form of base64-encoded String
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest, String name)
    Creates DigestDocument with a digest provided in a form of base64-encoded String with a specified document name
    DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
    Creates DigestDocument with a digest provided in a form of base64-encoded String with a specified name and mimeType of the document
    Creates DigestDocument with an initial Digest
    DigestDocument(Digest digest, String name)
    Creates DigestDocument with an initial Digest and a specified document name
    DigestDocument(Digest digest, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
    Creates DigestDocument with an initial Digest, a specified name and mimeType of the document
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDigest(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue)
    This method allows to add a pair: DigestAlgorithm and the corresponding digest value calculated externally on the encapsulated file.
    void
    addDigest(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest)
    This method allows to add a pair: DigestAlgorithm and the corresponding digest value calculated externally on the encapsulated file.
    void
    addDigest(Digest digest)
    This method allows to add a Digest with a new digest algorithm to the current DigestDocument.
    boolean
     
    byte[]
    getDigestValue(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm)
    This method returns digest value of the current document's content using the provided digestAlgorithm
    Gets the defined digest value for the DigestDocument
    int
     
    Opens a InputStream on the DSSDocument contents.
    void
    save(String filePath)
    Save the content of the DSSDocument to the file.

    Methods inherited from class eu.europa.esig.dss.model.CommonDocument

    getDigest, getMimeType, getName, setMimeType, setName, toString, writeTo

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DigestDocument

      public DigestDocument()
      Creates DigestDocument with an empty digest map. Initial algorithm and digest must be specified in order to use the object
    • DigestDocument

      public DigestDocument(Digest digest)
      Creates DigestDocument with an initial Digest
      Parameters:
      digest - Digest for the new DigestDocument
    • DigestDocument

      public DigestDocument(Digest digest, String name)
      Creates DigestDocument with an initial Digest and a specified document name
      Parameters:
      digest - Digest for the new DigestDocument
      name - String name of the document
    • DigestDocument

      public DigestDocument(Digest digest, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
      Creates DigestDocument with an initial Digest, a specified name and mimeType of the document
      Parameters:
      digest - Digest for the new DigestDocument
      name - String name of the document
      mimeType - MimeType of the document
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue)
      Creates DigestDocument with a digest provided in a form of byte array
      Parameters:
      digestAlgorithm - DigestAlgorithm
      digestValue - byte array representing the corresponding digest value
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest)
      Creates DigestDocument with a digest provided in a form of base64-encoded String
      Parameters:
      digestAlgorithm - DigestAlgorithm
      base64EncodeDigest - the corresponding base 64 encoded digest value
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue, String name)
      Creates DigestDocument with a digest provided in a form of byte array with a specified document name
      Parameters:
      digestAlgorithm - DigestAlgorithm
      digestValue - byte array representing the corresponding digest value
      name - the name of the document
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
      Creates DigestDocument with a digest provided in a form of byte array with a specified name and mimeType of the document
      Parameters:
      digestAlgorithm - DigestAlgorithm
      digestValue - byte array representing the corresponding digest value
      name - the name of the document
      mimeType - the mymetype of the document
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest, String name)
      Creates DigestDocument with a digest provided in a form of base64-encoded String with a specified document name
      Parameters:
      digestAlgorithm - DigestAlgorithm
      base64EncodeDigest - the corresponding base 64 encoded digest value
      name - the name of the document
    • DigestDocument

      public DigestDocument(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest, String name, eu.europa.esig.dss.enumerations.MimeType mimeType)
      Creates DigestDocument with a digest provided in a form of base64-encoded String with a specified name and mimeType of the document
      Parameters:
      digestAlgorithm - DigestAlgorithm
      base64EncodeDigest - the corresponding base 64 encoded digest value
      name - the name of the document
      mimeType - the mimetype of the document
  • Method Details

    • addDigest

      public void addDigest(Digest digest)
      This method allows to add a Digest with a new digest algorithm to the current DigestDocument. Overwrites the previous digest if the same DigestAlgorithm is provided.
      Parameters:
      digest - Digest for the current document
    • addDigest

      public void addDigest(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, byte[] digestValue)
      This method allows to add a pair: DigestAlgorithm and the corresponding digest value calculated externally on the encapsulated file.
      Parameters:
      digestAlgorithm - DigestAlgorithm used ot compute the digest value
      digestValue - byte array representing the corresponding digest value
    • addDigest

      public void addDigest(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm, String base64EncodeDigest)
      This method allows to add a pair: DigestAlgorithm and the corresponding digest value calculated externally on the encapsulated file. The digest value is base 64 encoded.
      Parameters:
      digestAlgorithm - DigestAlgorithm
      base64EncodeDigest - the corresponding base 64 encoded digest value
    • getDigestValue

      public byte[] getDigestValue(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm)
      Description copied from interface: DSSDocument
      This method returns digest value of the current document's content using the provided digestAlgorithm
      Specified by:
      getDigestValue in interface DSSDocument
      Overrides:
      getDigestValue in class CommonDocument
      Parameters:
      digestAlgorithm - DigestAlgorithm to get digest for
      Returns:
      byte array representing digest of the document
    • getExistingDigest

      public Digest getExistingDigest()
      Gets the defined digest value for the DigestDocument
      Returns:
      Digest
    • openStream

      public InputStream openStream()
      Description copied from interface: DSSDocument
      Opens a InputStream on the DSSDocument contents. The type of the InputStream depends on the type of the DSSDocument.
      Returns:
      an InputStream
    • save

      public void save(String filePath) throws IOException
      Description copied from interface: DSSDocument
      Save the content of the DSSDocument to the file.
      Specified by:
      save in interface DSSDocument
      Overrides:
      save in class CommonDocument
      Parameters:
      filePath - the path to the file to be created
      Throws:
      IOException - if any IO error happens
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class CommonDocument
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class CommonDocument