com.aspose.words

Class DigitalSignature

  • java.lang.Object
    • com.aspose.words.DigitalSignature
public class DigitalSignature 
extends java.lang.Object

Represents a digital signature on a document and the result of its verification.

Example:

Shows how to validate each signature in a document and display basic information about the signature.
// Load the document which contains signature.
Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");

for (DigitalSignature signature : doc.getDigitalSignatures())
{
    System.out.println("*** Signature Found ***");
    System.out.println("Is valid: " + signature.isValid());
    System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
    System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
    System.out.println("Time of signing: " + signature.getSignTime());
    System.out.println("Subject name: " + signature.getSubjectName());
    System.out.println("Issuer name: " + signature.getIssuerName());
    System.out.println();
}

Property Getters/Setters Summary
System.Security.Cryptography.X509Certificates.X509Certificate2getCertificate()
Returns the certificate object that was used to sign the document.
CertificateHoldergetCertificateHolder()
Returns the certificate holder object that contains the certificate was used to sign the document.
java.lang.StringgetComments()
Gets the signing purpose comment.
java.lang.StringgetIssuerName()
Returns the subject distinguished name of the certificate isuuer.
booleanisValid()
Returns true if this digital signature is valid and the document has not been tampered with.
intgetSignatureType()
Gets the type of the digital signature. The value of the property is DigitalSignatureType integer constant.
java.util.DategetSignTime()
Gets the time the document was signed.
java.lang.StringgetSubjectName()
Returns the subject distinguished name of the certificate that was used to sign the document.
 
Method Summary
java.lang.StringtoString()
 

    • Property Getters/Setters Detail

      • getCertificate

        public System.Security.Cryptography.X509Certificates.X509Certificate2 getCertificate()
        
        Returns the certificate object that was used to sign the document.

        Example:

        Shows how to validate each signature in a document and display basic information about the signature.
        // Load the document which contains signature.
        Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");
        
        for (DigitalSignature signature : doc.getDigitalSignatures())
        {
            System.out.println("*** Signature Found ***");
            System.out.println("Is valid: " + signature.isValid());
            System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
            System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
            System.out.println("Time of signing: " + signature.getSignTime());
            System.out.println("Subject name: " + signature.getSubjectName());
            System.out.println("Issuer name: " + signature.getIssuerName());
            System.out.println();
        }
      • getCertificateHolder

        public CertificateHolder getCertificateHolder()
        
        Returns the certificate holder object that contains the certificate was used to sign the document.
      • getComments

        public java.lang.String getComments()
        
        Gets the signing purpose comment.

        Example:

        Shows how to validate each signature in a document and display basic information about the signature.
        // Load the document which contains signature.
        Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");
        
        for (DigitalSignature signature : doc.getDigitalSignatures())
        {
            System.out.println("*** Signature Found ***");
            System.out.println("Is valid: " + signature.isValid());
            System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
            System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
            System.out.println("Time of signing: " + signature.getSignTime());
            System.out.println("Subject name: " + signature.getSubjectName());
            System.out.println("Issuer name: " + signature.getIssuerName());
            System.out.println();
        }
      • getIssuerName

        public java.lang.String getIssuerName()
        
        Returns the subject distinguished name of the certificate isuuer.
      • isValid

        public boolean isValid()
        
        Returns true if this digital signature is valid and the document has not been tampered with.

        Example:

        Shows how to validate each signature in a document and display basic information about the signature.
        // Load the document which contains signature.
        Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");
        
        for (DigitalSignature signature : doc.getDigitalSignatures())
        {
            System.out.println("*** Signature Found ***");
            System.out.println("Is valid: " + signature.isValid());
            System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
            System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
            System.out.println("Time of signing: " + signature.getSignTime());
            System.out.println("Subject name: " + signature.getSubjectName());
            System.out.println("Issuer name: " + signature.getIssuerName());
            System.out.println();
        }
      • getSignatureType

        public int getSignatureType()
        
        Gets the type of the digital signature. The value of the property is DigitalSignatureType integer constant.

        Example:

        Shows how to validate each signature in a document and display basic information about the signature.
        // Load the document which contains signature.
        Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");
        
        for (DigitalSignature signature : doc.getDigitalSignatures())
        {
            System.out.println("*** Signature Found ***");
            System.out.println("Is valid: " + signature.isValid());
            System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
            System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
            System.out.println("Time of signing: " + signature.getSignTime());
            System.out.println("Subject name: " + signature.getSubjectName());
            System.out.println("Issuer name: " + signature.getIssuerName());
            System.out.println();
        }
      • getSignTime

        public java.util.Date getSignTime()
        
        Gets the time the document was signed.

        Example:

        Shows how to validate each signature in a document and display basic information about the signature.
        // Load the document which contains signature.
        Document doc = new Document(getMyDir() + "Document.DigitalSignature.docx");
        
        for (DigitalSignature signature : doc.getDigitalSignatures())
        {
            System.out.println("*** Signature Found ***");
            System.out.println("Is valid: " + signature.isValid());
            System.out.println("Reason for signing: " + signature.getComments()); // This property is available in MS Word documents only.
            System.out.println("Signature type: " + DigitalSignatureType.toString(signature.getSignatureType()));
            System.out.println("Time of signing: " + signature.getSignTime());
            System.out.println("Subject name: " + signature.getSubjectName());
            System.out.println("Issuer name: " + signature.getIssuerName());
            System.out.println();
        }
      • getSubjectName

        public java.lang.String getSubjectName()
        
        Returns the subject distinguished name of the certificate that was used to sign the document.
    • Method Detail

      • toString

        public java.lang.String toString()