From 6ed8c5a0f19901ab413c6610649326b2475c3a8c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 25 Jul 2021 21:35:05 +0200 Subject: use officecfg for security options Change-Id: I9d91fd5b260b82e05aac6567143386742953ecf6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119486 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmlsecurity/inc/macrosecurity.hxx | 1 - .../source/component/documentdigitalsignatures.cxx | 20 +++++++----------- xmlsecurity/source/dialogs/macrosecurity.cxx | 24 +++++++++++----------- 3 files changed, 19 insertions(+), 26 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/inc/macrosecurity.hxx b/xmlsecurity/inc/macrosecurity.hxx index 690c5b05fcaf..233ef2c1dca1 100644 --- a/xmlsecurity/inc/macrosecurity.hxx +++ b/xmlsecurity/inc/macrosecurity.hxx @@ -32,7 +32,6 @@ private: friend class MacroSecurityTrustedSourcesTP; css::uno::Reference m_xSecurityEnvironment; - SvtSecurityOptions m_aSecOptions; std::unique_ptr m_xTabCtrl; std::unique_ptr m_xOkBtn; diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 5a353c39924b..625bbbd0d4be 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -663,7 +663,7 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted( } OUString sSerialNum = xmlsecurity::bigIntegerToNumericString(xAuthor->getSerialNumber()); - std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors(); + std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions::GetTrustedAuthors(); return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(), [&xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { @@ -764,14 +764,12 @@ css::uno::Reference< css::security::XCertificate > DocumentDigitalSignatures::ch sal_Bool DocumentDigitalSignatures::isLocationTrusted( const OUString& Location ) { - return SvtSecurityOptions().isTrustedLocationUri(Location); + return SvtSecurityOptions::isTrustedLocationUri(Location); } void DocumentDigitalSignatures::addAuthorToTrustedSources( const Reference< css::security::XCertificate >& Author ) { - SvtSecurityOptions aSecOpts; - SvtSecurityOptions::Certificate aNewCert; aNewCert.SubjectName = Author->getIssuerName(); aNewCert.SerialNumber = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() ); @@ -780,21 +778,17 @@ void DocumentDigitalSignatures::addAuthorToTrustedSources( ::comphelper::Base64::encode(aStrBuffer, Author->getEncoded()); aNewCert.RawData = aStrBuffer.makeStringAndClear(); - std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = aSecOpts.GetTrustedAuthors(); + std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions::GetTrustedAuthors(); aTrustedAuthors.push_back( aNewCert ); - aSecOpts.SetTrustedAuthors( aTrustedAuthors ); + SvtSecurityOptions::SetTrustedAuthors( aTrustedAuthors ); } void DocumentDigitalSignatures::addLocationToTrustedSources( const OUString& Location ) { - SvtSecurityOptions aSecOpt; - - Sequence< OUString > aSecURLs = aSecOpt.GetSecureURLs(); - sal_Int32 nCnt = aSecURLs.getLength(); - aSecURLs.realloc( nCnt + 1 ); - aSecURLs[ nCnt ] = Location; + std::vector< OUString > aSecURLs = SvtSecurityOptions::GetSecureURLs(); + aSecURLs.push_back(Location); - aSecOpt.SetSecureURLs( aSecURLs ); + SvtSecurityOptions::SetSecureURLs( aSecURLs ); } sal_Bool DocumentDigitalSignatures::signDocumentWithCertificate( diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx index 2cb08df9cd9f..dbfa41e96d58 100644 --- a/xmlsecurity/source/dialogs/macrosecurity.cxx +++ b/xmlsecurity/source/dialogs/macrosecurity.cxx @@ -126,8 +126,8 @@ MacroSecurityLevelTP::MacroSecurityLevelTP(weld::Container* pParent, MacroSecuri m_xVeryHighRB->set_size_request(nMaxWidth, -1); } - mnCurLevel = static_cast(m_pDlg->m_aSecOptions.GetMacroSecurityLevel()); - bool bReadonly = m_pDlg->m_aSecOptions.IsReadOnly( SvtSecurityOptions::EOption::MacroSecLevel ); + mnCurLevel = static_cast(SvtSecurityOptions::GetMacroSecurityLevel()); + bool bReadonly = SvtSecurityOptions::IsReadOnly( SvtSecurityOptions::EOption::MacroSecLevel ); weld::RadioButton* pCheck = nullptr; weld::Widget* pImage = nullptr; @@ -185,7 +185,7 @@ IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl, weld::Toggleable&, void) void MacroSecurityLevelTP::ClosePage() { - m_pDlg->m_aSecOptions.SetMacroSecurityLevel( mnCurLevel ); + SvtSecurityOptions::SetMacroSecurityLevel( mnCurLevel ); } void MacroSecurityTrustedSourcesTP::ImplCheckButtons() @@ -392,14 +392,14 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP(weld::Container* pP m_xRemoveLocPB->connect_clicked( LINK( this, MacroSecurityTrustedSourcesTP, RemoveLocPBHdl ) ); m_xRemoveLocPB->set_sensitive(false); - m_aTrustedAuthors = m_pDlg->m_aSecOptions.GetTrustedAuthors(); - mbAuthorsReadonly = m_pDlg->m_aSecOptions.IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors ); + m_aTrustedAuthors = SvtSecurityOptions::GetTrustedAuthors(); + mbAuthorsReadonly = SvtSecurityOptions::IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors ); m_xTrustCertROFI->set_visible(mbAuthorsReadonly); FillCertLB(true); - const css::uno::Sequence< OUString > aSecureURLs = m_pDlg->m_aSecOptions.GetSecureURLs(); - mbURLsReadonly = m_pDlg->m_aSecOptions.IsReadOnly( SvtSecurityOptions::EOption::SecureUrls ); + std::vector< OUString > aSecureURLs = SvtSecurityOptions::GetSecureURLs(); + mbURLsReadonly = SvtSecurityOptions::IsReadOnly( SvtSecurityOptions::EOption::SecureUrls ); m_xTrustFileROFI->set_visible(mbURLsReadonly); m_xAddLocPB->set_sensitive(!mbURLsReadonly); @@ -422,22 +422,22 @@ void MacroSecurityTrustedSourcesTP::ClosePage() sal_Int32 nEntryCnt = m_xTrustFileLocLB->n_children(); if( nEntryCnt ) { - css::uno::Sequence< OUString > aSecureURLs( nEntryCnt ); + std::vector< OUString > aSecureURLs; for (sal_Int32 i = 0; i < nEntryCnt; ++i) { OUString aURL(m_xTrustFileLocLB->get_text(i)); osl::FileBase::getFileURLFromSystemPath( aURL, aURL ); - aSecureURLs[ i ] = aURL; + aSecureURLs.push_back(aURL); } - m_pDlg->m_aSecOptions.SetSecureURLs( aSecureURLs ); + SvtSecurityOptions::SetSecureURLs( aSecureURLs ); } // Trusted Path could not be removed (#i33584#) // don't forget to remove the old saved SecureURLs else - m_pDlg->m_aSecOptions.SetSecureURLs( css::uno::Sequence< OUString >() ); + SvtSecurityOptions::SetSecureURLs( std::vector< OUString >() ); - m_pDlg->m_aSecOptions.SetTrustedAuthors( m_aTrustedAuthors ); + SvtSecurityOptions::SetTrustedAuthors( m_aTrustedAuthors ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit