翻譯|使用教程|編輯:胡濤|2022-10-27 10:21:34.853|閱讀 219 次
概述:本文主要介紹如何使用Java在PPT中添加數字簽名,歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Slides for .NET是一款.NET PowerPoint管理API,用于讀取,編寫,操作和轉換PowerPoint幻燈片的獨立API,可將PowerPoint轉換為PDF,PDF/A,XPS,TIFF,HTML,ODP和其他PowerPoint格式。
數字簽名驗證電子文檔的真實性和完整性,就像簽名或印章(手工制作)一樣。但是,數字簽名比手寫簽名安全得多。
閱讀完本文后,您將了解如何使用 Java 將數字簽名添加到 PowerPoint 演示文稿中。
如果您想用幾行 Java 代碼為 PPT 演示文稿添加數字簽名,那么您需要:
數字簽名必須滿足以下標準:使用有效的簽名,與之關聯的證書必須是最新的(未過期)并且(理想情況下)它應該來自有信譽的或知名的證書頒發機構,并且簽名者或簽名組織必須是信任。
有了您的數字證書并在您的系統上安裝了 Aspose.Slides,您必須按照以下說明將數字簽名添加到 Java 中的 PowerPoint 演示文稿:
此 Java 代碼向您展示如何將數字簽名添加到 PowerPoint:
// Opens the presentation file Presentation pres = new Presentation(); try { // Creates a DigitalSignature object with the PFX file and PFX password DigitalSignature signature = new DigitalSignature("testsignature1.pfx", "testpass1"); // Comments new digital signature signature.setComments("Aspose.Slides digital signing test."); // Adds a digital signature to presentation pres.getDigitalSignatures().add(signature); // Saves the presentation pres.save("SomePresentationSigned.pptx", SaveFormat.Pptx); } finally { pres.dispose(); }
如果您收到帶有數字簽名的 PowerPoint,您將運行驗證操作以檢查并確認您手中的文件在簽名后沒有被修改。這個過程本質上是對PPT或PPTX演示文稿真實性和完整性的測試。
請按照以下說明驗證已使用數字簽名簽名的 PowerPoint:
運行此 Java 代碼以驗證數字簽名的 PowerPoint 文檔:
// Opens the presentation Presentation pres = new Presentation("SomePresentationSigned.pptx"); try { if (pres.getDigitalSignatures().size() > 0) { boolean allSignaturesAreValid = true; System.out.println("Signatures used to sign the presentation: "); // Checks whether all the digital signatures are valid for (IDigitalSignature signature : pres.getDigitalSignatures()) { System.out.println(signature.getComments() + ", " + 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(); }
以上便是使用Java在PPT中添加數字簽名教程,如您還有關于產品相關方面的疑問,可以繼續瀏覽本系列其他內容,也歡迎您加入我們的交流群發表您遇到的問題。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn