[Libreoffice-commits] core.git: xmlsecurity/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Oct 14 10:25:17 UTC 2016
xmlsecurity/source/pdfio/pdfdocument.cxx | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
New commits:
commit 876fcb5461bb1fdb151a4457ccacaed6904238a2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 14 10:41:34 2016 +0200
xmlsecurity: expose date of PDF signatures
It's a UTC UNIX timestamp, in microseconds.
Change-Id: I1dad7fd6b7e68e85275219208affc890f48975d1
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index 22731db..225c588 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -15,12 +15,16 @@
#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/scopeguard.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
#include <sax/tools/converter.hxx>
+#include <unotools/calendarwrapper.hxx>
+#include <unotools/datetime.hxx>
+#include <xmloff/xmluconv.hxx>
#ifdef XMLSEC_CRYPTO_NSS
#include <cert.h>
@@ -860,6 +864,28 @@ bool PDFDocument::ValidateSignature(SvStream& rStream, PDFObjectElement* pSignat
rInformation.ouX509Certificate = aBuffer.makeStringAndClear();
}
+ PRTime nSigningTime;
+ if (NSS_CMSSignerInfo_GetSigningTime(pCMSSignerInfo, &nSigningTime) != SECSuccess)
+ {
+ SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ValidateSignature: NSS_CMSSignerInfo_GetSigningTime() failed");
+ return false;
+ }
+ else
+ {
+ // First convert the UNIX timestamp to an ISO8601 string.
+ OUStringBuffer aBuffer;
+ uno::Reference<uno::XComponentContext> xComponentContext = comphelper::getProcessComponentContext();
+ CalendarWrapper aCalendarWrapper(xComponentContext);
+ // nSigningTime is in microseconds.
+ SvXMLUnitConverter::convertDateTime(aBuffer, static_cast<double>(nSigningTime) / 1000000 / tools::Time::secondPerDay, aCalendarWrapper.getEpochStart().GetUNODate());
+
+ // Then convert this string to a local UNO DateTime.
+ util::DateTime aUNODateTime;
+ utl::ISO8601parseDateTime(aBuffer.toString(), aUNODateTime);
+ DateTime aDateTime(aUNODateTime);
+ aDateTime.ConvertToLocalTime();
+ rInformation.stDateTime = aDateTime.GetUNODateTime();
+ }
SECItem* pContentInfoContentData = pCMSSignedData->contentInfo.content.data;
if (pContentInfoContentData && pContentInfoContentData->data)
More information about the Libreoffice-commits
mailing list