Created
February 25, 2021 02:23
-
-
Save aspose-com-gists/57c273d387e5f608d1d958e21b08c68f to your computer and use it in GitHub Desktop.
Protect PowerPoint Presentations in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation("presentation.pptx"); | |
// 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 | |
presentation.getDigitalSignatures().add(signature); | |
// Save the PPTX | |
presentation.save("protected-presentation.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation("presentation.pptx"); | |
// Protect PPTX with password | |
presentation.getProtectionManager().encrypt("password"); | |
// Save the PPTX | |
presentation.save("protected-presentation.pptx", SaveFormat.Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Presentation object that represents a presentation file | |
Presentation presentation = new Presentation("presentation.pptx"); | |
// Check if digital signatures are available | |
if (presentation.getDigitalSignatures().size() > 0) { | |
boolean allSignaturesAreValid = true; | |
// Loop through digital signatures | |
for (IDigitalSignature signature : presentation.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."); | |
} | |
// Save the PPTX | |
presentation.save("protected-presentation.pptx", SaveFormat.Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment