summaryrefslogtreecommitdiff
path: root/xmlsecurity/workben/pdfverify.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity/workben/pdfverify.cxx')
-rw-r--r--xmlsecurity/workben/pdfverify.cxx61
1 files changed, 28 insertions, 33 deletions
diff --git a/xmlsecurity/workben/pdfverify.cxx b/xmlsecurity/workben/pdfverify.cxx
index b5052502573f..78595bae0ef9 100644
--- a/xmlsecurity/workben/pdfverify.cxx
+++ b/xmlsecurity/workben/pdfverify.cxx
@@ -24,11 +24,10 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/filter/pdfdocument.hxx>
#include <comphelper/scopeguard.hxx>
-
-#include <pdfio/pdfdocument.hxx>
-
#include <svl/sigstruct.hxx>
+#include <pdfsignaturehelper.hxx>
+
using namespace com::sun::star;
namespace
@@ -114,6 +113,32 @@ int pdfVerify(int nArgc, char** pArgv)
bRemoveSignature = true;
SvFileStream aStream(aInURL, StreamMode::READ);
+ if (aOutURL.isEmpty() && !bRemoveSignature)
+ {
+ std::cerr << "verifying signatures" << std::endl;
+ PDFSignatureHelper aHelper;
+ aStream.Seek(0);
+ aHelper.ReadAndVerifySignatureSvStream(aStream);
+ if (aHelper.GetSignatureInformations().empty())
+ std::cerr << "found no signatures" << std::endl;
+ else
+ {
+ std::cerr << "found " << aHelper.GetSignatureInformations().size() << " signatures"
+ << std::endl;
+ for (size_t i = 0; i < aHelper.GetSignatureInformations().size(); ++i)
+ {
+ const SignatureInformation& rInfo = aHelper.GetSignatureInformations()[i];
+ bool bSuccess
+ = rInfo.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
+ std::cerr << "signature #" << i << ": digest match? " << bSuccess << std::endl;
+ std::cerr << "signature #" << i << ": partial? " << rInfo.bPartialDocumentSignature
+ << std::endl;
+ }
+ }
+
+ return 0;
+ }
+
vcl::filter::PDFDocument aDocument;
if (!aDocument.Read(aStream))
{
@@ -148,36 +173,6 @@ int pdfVerify(int nArgc, char** pArgv)
return 0;
}
- if (aOutURL.isEmpty())
- {
- std::cerr << "verifying signatures" << std::endl;
- std::vector<vcl::filter::PDFObjectElement*> aSignatures = aDocument.GetSignatureWidgets();
- if (aSignatures.empty())
- std::cerr << "found no signatures" << std::endl;
- else
- {
- std::cerr << "found " << aSignatures.size() << " signatures" << std::endl;
- for (size_t i = 0; i < aSignatures.size(); ++i)
- {
- SignatureInformation aInfo(i);
- if (!xmlsecurity::pdfio::ValidateSignature(aStream, aSignatures[i], aInfo,
- aDocument))
- {
- SAL_WARN("xmlsecurity.pdfio", "failed to determine digest match");
- return 1;
- }
-
- bool bSuccess
- = aInfo.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
- std::cerr << "signature #" << i << ": digest match? " << bSuccess << std::endl;
- std::cerr << "signature #" << i << ": partial? " << aInfo.bPartialDocumentSignature
- << std::endl;
- }
- }
-
- return 0;
- }
-
std::cerr << "adding a new signature" << std::endl;
uno::Reference<xml::crypto::XSecurityEnvironment> xSecurityEnvironment
= xSecurityContext->getSecurityEnvironment();