summaryrefslogtreecommitdiff
path: root/cui/source/options/optgenrl.cxx
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@allotropia.de>2024-07-17 12:47:22 +0200
committerSarper Akdemir <sarper.akdemir@allotropia.de>2024-07-24 07:08:46 +0200
commit426c641976688e3e4d1ce66f76b27ccbd2dca55a (patch)
tree8a56790e284f7f586c1298959a58d61490a6d241 /cui/source/options/optgenrl.cxx
parent6ca02ef177df62edb124881248a1ebcd9876ff4c (diff)
tdf#159040: add sign with default certificate to save dialog
Include X.509 certificates under Tools->Options->UserData among the keys for signing. Add a new checkbox to Save file dialog, to sign with that selected key easily. The checkbox is disabled if there's no matching key found. Change-Id: I9fc16790c479819cd1f35bcad040d0ebc7c4bdef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170619 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akdemir@allotropia.de>
Diffstat (limited to 'cui/source/options/optgenrl.cxx')
-rw-r--r--cui/source/options/optgenrl.cxx44
1 files changed, 36 insertions, 8 deletions
diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx
index 54963bb86c97..ff2216b6e41c 100644
--- a/cui/source/options/optgenrl.cxx
+++ b/cui/source/options/optgenrl.cxx
@@ -25,6 +25,8 @@
# include <com/sun/star/xml/crypto/GPGSEInitializer.hpp>
# include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
#endif
+#include <com/sun/star/xml/crypto/SEInitializer.hpp>
+#include <comphelper/xmlsechelper.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
@@ -300,26 +302,52 @@ void SvxGeneralTabPage::InitCryptography()
#if HAVE_FEATURE_GPGME
m_xCryptoFrame->show();
- uno::Reference< xml::crypto::XSEInitializer > xSEInitializer;
try
{
- xSEInitializer = xml::crypto::GPGSEInitializer::create( comphelper::getProcessComponentContext() );
- uno::Reference<xml::crypto::XXMLSecurityContext> xSC = xSEInitializer->createSecurityContext( OUString() );
- if (xSC.is())
+ uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext
+ = xml::crypto::SEInitializer::create(comphelper::getProcessComponentContext())
+ ->createSecurityContext("");
+ uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContextGPG
+ = xml::crypto::GPGSEInitializer::create(comphelper::getProcessComponentContext())
+ ->createSecurityContext("");
+ if (xSecurityContextGPG.is())
{
- uno::Reference<xml::crypto::XSecurityEnvironment> xSE = xSC->getSecurityEnvironment();
+ uno::Reference<xml::crypto::XSecurityEnvironment> xSE = xSecurityContextGPG->getSecurityEnvironment();
uno::Sequence<uno::Reference<security::XCertificate>> xCertificates = xSE->getPersonalCertificates();
if (xCertificates.hasElements())
{
for (auto& xCert : asNonConstRange(xCertificates))
{
- m_xSigningKeyLB->append_text( xCert->getIssuerName());
- m_xEncryptionKeyLB->append_text( xCert->getIssuerName());
+ const auto aIssuer = comphelper::xmlsec::GetContentPart(
+ xCert->getSubjectName(), xCert->getCertificateKind());
+ m_xSigningKeyLB->append_text(aIssuer);
+ m_xEncryptionKeyLB->append_text(aIssuer);
}
}
+ }
+
+ if (xSecurityContext.is())
+ {
+ uno::Reference<xml::crypto::XSecurityEnvironment> xSE = xSecurityContext->getSecurityEnvironment();
+ uno::Sequence<uno::Reference<security::XCertificate>> xCertificates
+ = xSE->getPersonalCertificates();
+
+ if (xCertificates.hasElements())
+ {
+ for (auto& xCert : asNonConstRange(xCertificates))
+ {
+ const auto aIssuer
+ = comphelper::xmlsec::GetContentPart(xCert->getSubjectName(),
+ xCert->getCertificateKind());
+ m_xSigningKeyLB->append_text(aIssuer);
+ }
+ }
+ }
- //tdf#115015: wrap checkbox text and listboxes if necessary
+ if (xSecurityContext.is() || xSecurityContextGPG.is())
+ {
+ //tdf#115015: wrap checkbox text and listboxes if necessary
int nPrefWidth(m_xEncryptToSelfCB->get_preferred_size().Width());
int nMaxWidth = m_xEncryptToSelfCB->get_approximate_digit_width() * 40;
if (nPrefWidth > nMaxWidth)