public class DigitalSignature extends java.lang.Object implements IDigitalSignature
Digital signature in signed file.
The following example demonstrates how to add digital signature from a PFX certificate in PowerPoint Presentation.// Initialize Presentation instance Presentation pres = new Presentation(); try { // Create DigitalSignature object with PFX file and PFX password DigitalSignature signature = new DigitalSignature("testsignature1.pfx", "testpass1"); // Comment new digital signature signature.setComments("Aspose.Slides digital signing test."); // Add digital signature to presentation pres.getDigitalSignatures().add(signature); // Save presentation pres.save("SomePresentationSigned.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }The following sample code demonstrates how to validate digital signature of PowerPoint Presentation.// Initialize Presentation instance Presentation pres = new Presentation("SomePresentationSigned.pptx"); try { if (pres.getDigitalSignatures().size() > 0) { boolean allSignaturesAreValid = true; System.out.println("Signatures used to sign the presentation: "); // Check if all digital signatures are valid for (IDigitalSignature signature : pres.getDigitalSignatures()) { System.out.println(signature.getSignTime().toString() + " -- " + (signature.isValid() ? "VALID" : "INVALID")); allSignaturesAreValid &= signature.isValid(); } if (allSignaturesAreValid) System.out.println("Presentation is genuine, all signatures are valid."); else System.out.println("Presentation has been modified since signing."); } } finally { if (pres != null) pres.dispose(); }
| Constructor and Description |
|---|
DigitalSignature(byte[] certData,
java.lang.String password)
Creates a new DigitalSignature object with the specified certificate.
|
DigitalSignature(java.lang.String filePath,
java.lang.String password)
Creates a new DigitalSignature object with the specified certificate file path and password.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getCertificate()
Certificate object that was used to sign the document.
|
java.lang.String |
getComments()
The purpose of signature.
|
java.util.Date |
getSignTime()
The time when the document was signed.
|
boolean |
isValid()
If this digital signature is valid and the document has not been tampered with, this value will be true.
|
void |
setComments(java.lang.String value)
The purpose of signature.
|
public DigitalSignature(byte[] certData,
java.lang.String password)
Creates a new DigitalSignature object with the specified certificate.
certData - a byte array containing the certificatepassword - Password required to access certificate.public DigitalSignature(java.lang.String filePath,
java.lang.String password)
Creates a new DigitalSignature object with the specified certificate file path and password.
filePath - Path to the file with certificate.password - Password required to access certificate.public final byte[] getCertificate()
Certificate object that was used to sign the document.
Read-only byte[].
getCertificate in interface IDigitalSignaturepublic final boolean isValid()
If this digital signature is valid and the document has not been tampered with, this value will be true.
Read-only boolean.
Presentation pres = new Presentation("SomePresentationSigned.pptx"); try { for (IDigitalSignature signature : pres.getDigitalSignatures()) System.out.println("Signature check: " + (signature.isValid() ? "VALID" : "INVALID")); } finally { if (pres != null) pres.dispose(); }
isValid in interface IDigitalSignaturepublic final java.util.Date getSignTime()
The time when the document was signed.
Read-only Date.
Presentation pres = new Presentation("SomePresentationSigned.pptx"); try { for (IDigitalSignature signature : pres.getDigitalSignatures()) System.out.println("Signature check: " + (signature.isValid() ? "VALID" : "INVALID") + ", Signing time: " + signature.getSignTime()); } finally { if (pres != null) pres.dispose(); }
getSignTime in interface IDigitalSignaturepublic final java.lang.String getComments()
The purpose of signature.
Read/write String.
getComments in interface IDigitalSignaturepublic final void setComments(java.lang.String value)
The purpose of signature.
Read/write String.
setComments in interface IDigitalSignatureCopyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.