diff options
-rw-r--r-- | include/vcl/pdfwriter.hxx | 3 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 16 | ||||
-rw-r--r-- | xmlsecurity/inc/pdfio/pdfdocument.hxx | 2 | ||||
-rw-r--r-- | xmlsecurity/source/helper/pdfsignaturehelper.cxx | 2 | ||||
-rw-r--r-- | xmlsecurity/source/pdfio/pdfdocument.cxx | 10 | ||||
-rw-r--r-- | xmlsecurity/source/pdfio/pdfverify.cxx | 2 |
6 files changed, 23 insertions, 12 deletions
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 6b9c52920a53..79ac5db594a5 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -1267,6 +1267,9 @@ The following structure describes the permissions used in PDF security /// Fill a PDF signature template. static bool Sign(PDFSignContext& rContext); + + /// Write rString as a PDF hex string into rBuffer. + static void AppendUnicodeTextString(const OUString& rString, OStringBuffer& rBuffer); }; } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index b246263d76d6..c20446f6d136 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -663,7 +663,7 @@ static void appendDestinationName( const OUString& rString, OStringBuffer& rBuff } //<--- i56629 -static void appendUnicodeTextString( const OUString& rString, OStringBuffer& rBuffer ) +void PDFWriter::AppendUnicodeTextString(const OUString& rString, OStringBuffer& rBuffer) { rBuffer.append( "FEFF" ); const sal_Unicode* pStr = rString.getStr(); @@ -1872,17 +1872,17 @@ void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIden OString aInfoValuesOut; OStringBuffer aID( 1024 ); if( !i_rDocInfo.Title.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Title, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Title, aID); if( !i_rDocInfo.Author.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Author, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Author, aID); if( !i_rDocInfo.Subject.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Subject, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Subject, aID); if( !i_rDocInfo.Keywords.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Keywords, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Keywords, aID); if( !i_rDocInfo.Creator.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Creator, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Creator, aID); if( !i_rDocInfo.Producer.isEmpty() ) - appendUnicodeTextString( i_rDocInfo.Producer, aID ); + PDFWriter::AppendUnicodeTextString(i_rDocInfo.Producer, aID); TimeValue aTVal, aGMT; oslDateTime aDT; @@ -2025,7 +2025,7 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt } } else - appendUnicodeTextString( rInString, rOutBuffer ); + PDFWriter::AppendUnicodeTextString(rInString, rOutBuffer); rOutBuffer.append( ">" ); } 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; |