summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-10-20 17:09:04 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-10-21 06:05:13 +0000
commitf7a6867d6ae88cd6ca9001c61880fc1511370b16 (patch)
treeb3e5b13411f4582389af668d0cce32212d27511c /xmlsecurity
parentda8357463ca088c81774ab6c3ffc6f8b3903ffe7 (diff)
xmlsecurity: export description in PDF signature
Extract appendUnicodeTextString() from the PDF writer impl, and reuse it in xmlsecurity, to share code. Change-Id: Icdc2f89132cd29e07280001e30bad97e0a644654 Reviewed-on: https://gerrit.libreoffice.org/30110 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/pdfio/pdfdocument.hxx2
-rw-r--r--xmlsecurity/source/helper/pdfsignaturehelper.cxx2
-rw-r--r--xmlsecurity/source/pdfio/pdfdocument.cxx10
-rw-r--r--xmlsecurity/source/pdfio/pdfverify.cxx2
4 files changed, 12 insertions, 4 deletions
diff --git a/xmlsecurity/inc/pdfio/pdfdocument.hxx b/xmlsecurity/inc/pdfio/pdfdocument.hxx
index 2f95b7dfce48..bb132a6959ff 100644
--- a/xmlsecurity/inc/pdfio/pdfdocument.hxx
+++ b/xmlsecurity/inc/pdfio/pdfdocument.hxx
@@ -66,7 +66,7 @@ public:
bool Read(SvStream& rStream);
/// Sign the read document with xCertificate in the edit buffer.
- bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate);
+ bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate, const OUString& rDescription);
/// Serializes the contents of the edit buffer.
bool Write(SvStream& rStream);
std::vector<PDFObjectElement*> GetSignatureWidgets();
diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
index 9529eefaaaea..fdd4ed8ef571 100644
--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx
@@ -131,7 +131,7 @@ bool PDFSignatureHelper::Sign(const uno::Reference<io::XInputStream>& xInputStre
return false;
}
- if (!aDocument.Sign(m_xCertificate))
+ if (!aDocument.Sign(m_xCertificate, m_aDescription))
{
SAL_WARN("xmlsecurity.helper", "failed to sign");
return false;
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index fa5674c610b4..57361f9fd96b 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -233,7 +233,7 @@ PDFDocument::PDFDocument()
{
}
-bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificate)
+bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificate, const OUString& rDescription)
{
m_aEditBuffer.WriteCharPtr("\n");
@@ -268,6 +268,14 @@ bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificat
aSigBuffer.append(aByteRangeFiller.makeStringAndClear());
// Finish the Sig obj.
aSigBuffer.append(" /Filter/Adobe.PPKMS");
+
+ if (!rDescription.isEmpty())
+ {
+ aSigBuffer.append("/Reason<");
+ vcl::PDFWriter::AppendUnicodeTextString(rDescription, aSigBuffer);
+ aSigBuffer.append(">");
+ }
+
aSigBuffer.append(" >>\nendobj\n\n");
m_aEditBuffer.WriteOString(aSigBuffer.toString());
diff --git a/xmlsecurity/source/pdfio/pdfverify.cxx b/xmlsecurity/source/pdfio/pdfverify.cxx
index c751f20fcd19..5787aff41c2e 100644
--- a/xmlsecurity/source/pdfio/pdfverify.cxx
+++ b/xmlsecurity/source/pdfio/pdfverify.cxx
@@ -104,7 +104,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(nArgc, pArgv)
SAL_WARN("xmlsecurity.pdfio", "no signing certificates found");
return 1;
}
- if (!aDocument.Sign(aCertificates[0]))
+ if (!aDocument.Sign(aCertificates[0], "pdfverify"))
{
SAL_WARN("xmlsecurity.pdfio", "failed to sign");
return 1;