summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-09-10 13:06:09 -0400
committerAshod Nakashian <ashnakash@gmail.com>2017-09-11 22:35:08 +0200
commitc43152a008961f78bce30c19b84810ed9472870d (patch)
treec5db48da9ab704669808143e99a81f1ddb7d2d95 /sw
parentb9f2f43a9b6724fa1a09ba3115ac9abb25d52c8a (diff)
sw: let user choose cert when inserting paragraph signature
Change-Id: I1dca4d66e0666e45216253ea92010810bab93edf Reviewed-on: https://gerrit.libreoffice.org/42170 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/edit/edfcol.cxx22
1 files changed, 10 insertions, 12 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 1b29cbedaf59..bc605825ea9e 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -36,6 +36,8 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/xml/crypto/SEInitializer.hpp>
#include <com/sun/star/rdf/XMetadatable.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/XCertificate.hpp>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <comphelper/propertysequence.hxx>
@@ -690,22 +692,18 @@ void SwEditShell::SignParagraph(SwPaM* pPaM)
if (utf8Text.isEmpty())
return;
- // 2. Get certificate and SignatureInformation (needed to show signer name).
- //FIXME: Temporary until the Paragraph Signing Dialog is available.
- uno::Reference<uno::XComponentContext> xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
- uno::Reference<xml::crypto::XSEInitializer> xSEInitializer = xml::crypto::SEInitializer::create(xComponentContext);
- uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext = xSEInitializer->createSecurityContext(OUString());
- uno::Reference<xml::crypto::XSecurityEnvironment> xSecurityEnvironment = xSecurityContext->getSecurityEnvironment();
- uno::Sequence<uno::Reference<security::XCertificate>> aCertificates = xSecurityEnvironment->getPersonalCertificates();
- if (!aCertificates.hasElements())
- return;
+ // 2. Get certificate.
+ uno::Reference<security::XDocumentDigitalSignatures> xSigner(
+ security::DocumentDigitalSignatures::createWithVersion(
+ comphelper::getProcessComponentContext(), "1.2" ) );
- uno::Reference<security::XCertificate> xCert = aCertificates[0];
- if (!xCert.is())
+ OUString aDescription;
+ uno::Reference<security::XCertificate> xCertificate = xSigner->chooseCertificate(aDescription);
+ if (!xCertificate.is())
return;
// 3. Sign it.
- svl::crypto::Signing signing(xCert);
+ svl::crypto::Signing signing(xCertificate);
signing.AddDataRange(utf8Text.getStr(), utf8Text.getLength());
OStringBuffer sigBuf;
if (!signing.Sign(sigBuf))