Class PdfSignature


public class PdfSignature extends PdfObjectWrapper<PdfDictionary>
Represents the signature dictionary.
  • Constructor Details

    • PdfSignature

      public PdfSignature()
      Creates new PdfSignature.
    • PdfSignature

      public PdfSignature (PdfName filter, PdfName subFilter)
      Creates new PdfSignature.
      Parameters:
      filter - PdfName of the signature handler to use when validating this signature
      subFilter - PdfName that describes the encoding of the signature
    • PdfSignature

      public PdfSignature (PdfDictionary sigDictionary)
  • Method Details

    • getSubFilter

      public PdfName getSubFilter()
      A name that describes the encoding of the signature value and key information in the signature dictionary.
      Returns:
      a PdfName which usually has a value either PdfName.Adbe_pkcs7_detached or PdfName.ETSI_CAdES_DETACHED.
    • getType

      public PdfName getType()
      The type of PDF object that the wrapped dictionary describes; if present, shall be PdfName.Sig for a signature dictionary or PdfName.DocTimeStamp for a timestamp signature dictionary. Shall be not null if it's value is PdfName.DocTimeStamp. The default value is: PdfName.Sig.
      Returns:
      a PdfName that identifies type of the wrapped dictionary, returns null if it is not explicitly specified.
    • setByteRange

      public void setByteRange (int[] range)
      Sets the /ByteRange.
      Parameters:
      range - an array of pairs of integers that specifies the byte range used in the digest calculation. A pair consists of the starting byte offset and the length
    • getByteRange

      public PdfArray getByteRange()
      Gets the /ByteRange.
      Returns:
      an array of pairs of integers that specifies the byte range used in the digest calculation. A pair consists of the starting byte offset and the length.
    • setContents

      public void setContents (byte[] contents)
      Sets the /Contents value to the specified byte[].
      Parameters:
      contents - a byte[] representing the digest
    • getContents

      public PdfString getContents()
      Gets the /Contents entry value. See ISO 32000-1 12.8.1, Table 252 – Entries in a signature dictionary.
      Returns:
      the signature content
    • setCert

      public void setCert (byte[] cert)
      Sets the /Cert value of this signature.
      Parameters:
      cert - the byte[] representing the certificate chain
    • getCert

      public PdfString getCert()
      Gets the /Cert entry value of this signature. See ISO 32000-1 12.8.1, Table 252 – Entries in a signature dictionary.
      Returns:
      the signature cert
    • getCertObject

      public PdfObject getCertObject()
      Gets the /Cert entry value of this signature. /Cert entry required when SubFilter is adbe.x509.rsa_sha1. May be array or byte string.
      Returns:
      the signature cert value
    • setName

      public void setName (String name)
      Sets the /Name of the person signing the document.
      Parameters:
      name - name of the person signing the document
    • getName

      public String getName()
      gets the /Name of the person signing the document.
      Returns:
      name of the person signing the document.
    • setDate

      public void setDate (PdfDate date)
      Sets the /M value. Should only be used if the time of signing is not available in the signature.
      Parameters:
      date - time of signing
    • getDate

      public PdfString getDate()
      Gets the /M value. Should only be used if the time of signing is not available in the signature.
      Returns:
      PdfString which denotes time of signing.
    • setLocation

      public void setLocation (String location)
      Sets the /Location value.
      Parameters:
      location - physical location of signing
    • getLocation

      public String getLocation()
      Gets the /Location entry value.
      Returns:
      physical location of signing.
    • setReason

      public void setReason (String reason)
      Sets the /Reason value.
      Parameters:
      reason - reason for signing
    • getReason

      public String getReason()
    • setSignatureCreator

      public void setSignatureCreator (String signatureCreator)
      Sets the signature creator name in the PdfSignatureBuildProperties dictionary.
      Parameters:
      signatureCreator - name of the signature creator
    • setContact

      public void setContact (String contactInfo)
      Sets the /ContactInfo value.
      Parameters:
      contactInfo - information to contact the person who signed this document
    • put

      public PdfSignature put (PdfName key, PdfObject value)
    • isWrappedObjectMustBeIndirect

      protected boolean isWrappedObjectMustBeIndirect()
      Description copied from class: PdfObjectWrapper
      Defines if the object behind this wrapper must be an indirect object in the resultant document.

      If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

      Return value of this method shouldn't depend on any logic, it should return always true or false.
      Specified by:
      isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfDictionary>
      Returns:
      true if in the resultant document the object behind the wrapper must be indirect, otherwise false.