diff options
author | TokieSan <eltokhy@aucegypt.edu> | 2023-08-05 18:26:55 +0300 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2023-08-26 00:59:48 +0200 |
commit | fb9874231fb242b4a6a7d1ce097e66dd4ed8f32e (patch) | |
tree | fc3b69b97247bcaf5b4f318e6e61a4c6eb4e60ec /xmlsecurity/source | |
parent | 6e042b1e26bedcc8d8bdcf105ec750b03665c7b0 (diff) |
Caching Certificates in the CertificateChooser dialog session-wise
Added the functionality of caching certificates per session using a
single instance with internal memoization. Added Reload Certificates
button in case of certificate changes in-session. Updated all instances
of certifcate chooser in the codebase to work with the new change.
Change-Id: Icb25a2b2e9787b029fa6189f70bd4ba3b6806f60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155373
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.cxx | 10 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificatechooser.cxx | 14 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 8 |
3 files changed, 23 insertions, 9 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 0fd029fc2d81..4ad63b36ed0b 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -709,14 +709,14 @@ DocumentDigitalSignatures::chooseCertificatesImpl(std::map<OUString, OUString>& xSecContexts.push_back(aSignatureManager.getGpgSecurityContext()); } - CertificateChooser aChooser(Application::GetFrameWeld(mxParentWindow), std::move(xSecContexts), eAction); + CertificateChooser* aChooser = CertificateChooser::getInstance(Application::GetFrameWeld(mxParentWindow), std::move(xSecContexts), eAction); - if (aChooser.run() != RET_OK) + if (aChooser->run() != RET_OK) return { Reference< css::security::XCertificate >(nullptr) }; - uno::Sequence< Reference< css::security::XCertificate > > xCerts = aChooser.GetSelectedCertificates(); - rProperties["Description"] = aChooser.GetDescription(); - rProperties["Usage"] = aChooser.GetUsageText(); + uno::Sequence< Reference< css::security::XCertificate > > xCerts = aChooser->GetSelectedCertificates(); + rProperties["Description"] = aChooser->GetDescription(); + rProperties["Usage"] = aChooser->GetUsageText(); return xCerts; } diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx index be3e88f9d453..a7ff02f1a583 100644 --- a/xmlsecurity/source/dialogs/certificatechooser.cxx +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -52,6 +52,7 @@ CertificateChooser::CertificateChooser(weld::Window* _pParent, , m_xFTDescription(m_xBuilder->weld_label("description-label")) , m_xDescriptionED(m_xBuilder->weld_entry("description")) , m_xSearchBox(m_xBuilder->weld_entry("searchbox")) + , m_xReloadBtn(m_xBuilder->weld_button("reloadcert")) { auto nControlWidth = m_xCertLB->get_approximate_digit_width() * 105; m_xCertLB->set_size_request(nControlWidth, m_xCertLB->get_height_rows(12)); @@ -61,6 +62,7 @@ CertificateChooser::CertificateChooser(weld::Window* _pParent, m_xCertLB->connect_row_activated( LINK( this, CertificateChooser, CertificateSelectHdl ) ); m_xViewBtn->connect_clicked( LINK( this, CertificateChooser, ViewButtonHdl ) ); m_xSearchBox->connect_changed(LINK(this, CertificateChooser, SearchModifyHdl)); + m_xReloadBtn->connect_clicked( LINK( this, CertificateChooser, ReloadButtonHdl ) ); mxSecurityContexts = std::move(rxSecurityContexts); mbInitialized = false; @@ -313,6 +315,18 @@ OUString CertificateChooser::GetUsageText() UsageInClearText(xCerts[0]->getCertificateUsage()) : OUString(); } +void CertificateChooser::ImplReloadCertificates() +{ + xMemCerts.clear(); +} + +IMPL_LINK_NOARG(CertificateChooser, ReloadButtonHdl, weld::Button&, void) +{ + ImplReloadCertificates(); + mbInitialized = false; + ImplInitialize(); +} + IMPL_LINK_NOARG(CertificateChooser, SearchModifyHdl, weld::Entry&, void) { ImplInitialize(true); diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 4e29cbf836d2..5a7f16faf64b 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -412,12 +412,12 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, weld::Button&, void) if (DocumentSignatureHelper::CanSignWithGPG(maSignatureManager.getStore(), m_sODFVersion)) xSecContexts.push_back(maSignatureManager.getGpgSecurityContext()); - CertificateChooser aChooser(m_xDialog.get(), std::move(xSecContexts), UserAction::Sign); - if (aChooser.run() == RET_OK) + CertificateChooser* aChooser = CertificateChooser::getInstance(m_xDialog.get(), std::move(xSecContexts), UserAction::Sign); + if (aChooser->run() == RET_OK) { sal_Int32 nSecurityId; - if (!maSignatureManager.add(aChooser.GetSelectedCertificates()[0], aChooser.GetSelectedSecurityContext(), - aChooser.GetDescription(), nSecurityId, m_bAdESCompliant)) + if (!maSignatureManager.add(aChooser->GetSelectedCertificates()[0], aChooser->GetSelectedSecurityContext(), + aChooser->GetDescription(), nSecurityId, m_bAdESCompliant)) return; mbSignaturesChanged = true; |