diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-12-11 10:24:37 +0100 |
---|---|---|
committer | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2021-04-15 13:11:45 +0300 |
commit | d1c3a935a6f7fbbbdc5dbecd8dcb80db8375d682 (patch) | |
tree | 22253b4e1e7ebb35b407630d49a7f15877b74a08 | |
parent | fbde1006a233422f9ab66b5f2a8354957d50392e (diff) |
Fix macro security UI usability problems
* Don't hide the option dialogs "Macro security" push button.
I don't see any reason, why these settings should be hidden, if
macros are disabled or settings locked. At least a user can now
check, what is going on (still nothing shows disabled macros for
a document in the UI AFAIK).
* Don't scale the lock icons of the trusted list boxes.
This just uses the same alignments, which the macro security
level lock image uses, otherwise the image is scaled to fit the
whole space of its layout cell.
* Don't disable the trusted list boxes.
If the setting is locked, it's sufficient to disable all the
buttons, which allow modification (so View can stay enabled).
This way you can still scroll the list. Correct button handling
is already implemented and works for me.
* Catch exceptions of broken certificate data.
If your config contains certificates, which can't be correctly
decoded, the NSS backend will throw an exception, which kills
the dialog, but not the nested loop, resulting in a locked LO.
Since we don't want a string change in LTS, this drops the whole
"broken certificate" warning dialog. There already are SAL_WARNs,
which log the same warning, and are considered sufficient for
debugging broken configurations.
Reviewed-on: https://gerrit.libreoffice.org/85056
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
(cherry picked from commit b3348ce498b3d54b3e5e6518954ad9d5e917b8f2)
Reviewed-on: https://gerrit.libreoffice.org/85282
(cherry picked from commit ad1a41032054991cfb8b9e821c1dd25ec21d0aec)
Conflicts:
xmlsecurity/source/dialogs/macrosecurity.cxx
Change-Id: I79002e0ce85cf9a9017caf858407f2f635a3a074
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85756
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | cui/source/options/optinet2.cxx | 14 | ||||
-rw-r--r-- | uui/source/secmacrowarnings.cxx | 2 | ||||
-rw-r--r-- | xmlsecurity/inc/macrosecurity.hxx | 2 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/macrosecurity.cxx | 62 | ||||
-rw-r--r-- | xmlsecurity/uiconfig/ui/securitytrustpage.ui | 4 |
5 files changed, 47 insertions, 37 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 4d32aea2ebb4..a8982fb095a2 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -835,20 +835,6 @@ IMPL_STATIC_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl, Button*, void) void SvxSecurityTabPage::InitControls() { - // Hide all controls which belong to the macro security button in case the macro - // security settings managed by the macro security dialog opened via the button - // are all readonly or if the macros are disabled in general. - // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing - // macro security dialog implementations here, which is bad. - if ( mpSecOptions->IsMacroDisabled() - || ( mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::MacroSecLevel ) - && mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors ) - && mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::SecureUrls ) ) ) - { - //Hide these - m_pMacroSecFrame->Hide(); - } - #ifndef UNX m_pCertFrame->Hide(); #endif diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index d92e9f3bcf0a..a20a7e222378 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -133,7 +133,7 @@ void MacroWarning::InitControls() if (mbShowSignatures) { mxViewSignsBtn->connect_clicked(LINK(this, MacroWarning, ViewSignsBtnHdl)); - mxViewSignsBtn->set_sensitive(false); // default + mxViewSignsBtn->set_sensitive(false); mxAlwaysTrustCB->connect_clicked(LINK(this, MacroWarning, AlwaysTrustCheckHdl)); mnActSecLevel = SvtSecurityOptions().GetMacroSecurityLevel(); diff --git a/xmlsecurity/inc/macrosecurity.hxx b/xmlsecurity/inc/macrosecurity.hxx index 9f402ba45e74..7b1c6288679f 100644 --- a/xmlsecurity/inc/macrosecurity.hxx +++ b/xmlsecurity/inc/macrosecurity.hxx @@ -128,7 +128,7 @@ private: DECL_LINK( TrustCertLBSelectHdl, SvTreeListBox*, void ); DECL_LINK( TrustFileLocLBSelectHdl, ListBox&, void ); - void FillCertLB(); + void FillCertLB(const bool bShowWarnings = false); void ImplCheckButtons(); public: diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx index cef75f57d665..e57d9bfb500b 100644 --- a/xmlsecurity/source/dialogs/macrosecurity.cxx +++ b/xmlsecurity/source/dialogs/macrosecurity.cxx @@ -27,7 +27,6 @@ #include <vcl/help.hxx> #include <vcl/layout.hxx> - #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <comphelper/sequence.hxx> #include <comphelper/processfactory.hxx> @@ -207,20 +206,33 @@ void MacroSecurityTrustedSourcesTP::ImplCheckButtons() m_pRemoveLocPB->Enable( bLocationSelected && !mbURLsReadonly); } - IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl, Button*, void) { if( m_pTrustCertLB->FirstSelected() ) { - sal_uInt16 nSelected = sal_uInt16( sal_uIntPtr( m_pTrustCertLB->FirstSelected()->GetUserData() ) ); - - uno::Reference< css::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( maTrustedAuthors[nSelected][0], xmlsecurity::numericStringToBigInteger( maTrustedAuthors[nSelected][1] ) ); - - // If we don't get it, create it from signature data: - if ( !xCert.is() ) - xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( maTrustedAuthors[nSelected][2] ) ; + const sal_uInt16 nSelected = sal_uInt16(sal_uIntPtr(m_pTrustCertLB->FirstSelected()->GetUserData())); + uno::Reference< css::security::XCertificate > xCert; + try + { + xCert = mpDlg->mxSecurityEnvironment->getCertificate(maTrustedAuthors[nSelected][0], + xmlsecurity::numericStringToBigInteger(maTrustedAuthors[nSelected][1])); + } + catch (...) + { + SAL_WARN("xmlsecurity.dialogs", "matching certificate not found for: " << maTrustedAuthors[nSelected][0]); + } - SAL_WARN_IF( !xCert.is(), "xmlsecurity.dialogs", "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" ); + if (!xCert.is()) + { + try + { + xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii(maTrustedAuthors[nSelected][2]); + } + catch (...) + { + SAL_WARN("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << maTrustedAuthors[nSelected][2]); + } + } if ( xCert.is() ) { @@ -309,7 +321,7 @@ IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl, ListBox& ImplCheckButtons(); } -void MacroSecurityTrustedSourcesTP::FillCertLB() +void MacroSecurityTrustedSourcesTP::FillCertLB(const bool bShowWarnings) { m_pTrustCertLB->Clear(); @@ -322,13 +334,23 @@ void MacroSecurityTrustedSourcesTP::FillCertLB() css::uno::Sequence< OUString >& rEntry = maTrustedAuthors[ nEntry ]; uno::Reference< css::security::XCertificate > xCert; - // create from RawData - xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] ); - - SvTreeListEntry* pLBEntry = m_pTrustCertLB->InsertEntry( xmlsec::GetContentPart( xCert->getSubjectName() ) ); - m_pTrustCertLB->SetEntryText( xmlsec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 ); - m_pTrustCertLB->SetEntryText( utl::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 ); - pLBEntry->SetUserData( reinterpret_cast<void*>(nEntry) ); // misuse user data as index + try + { + // create from RawData + xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] ); + + SvTreeListEntry* pLBEntry = m_pTrustCertLB->InsertEntry( xmlsec::GetContentPart( xCert->getSubjectName() ) ); + m_pTrustCertLB->SetEntryText( xmlsec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 ); + m_pTrustCertLB->SetEntryText( utl::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 ); + pLBEntry->SetUserData( reinterpret_cast<void*>(nEntry) ); // misuse user data as index + } + catch (...) + { + if (bShowWarnings) + { + SAL_WARN("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << rEntry[2]); + } + } } } } @@ -386,14 +408,12 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP(vcl::Window* _pPare maTrustedAuthors = mpDlg->maSecOptions.GetTrustedAuthors(); mbAuthorsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors ); m_pTrustCertROFI->Show( mbAuthorsReadonly ); - mbAuthorsReadonly ? m_pTrustCertLB->DisableTable() : m_pTrustCertLB->EnableTable(); - FillCertLB(); + FillCertLB(true); css::uno::Sequence< OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs(); mbURLsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::EOption::SecureUrls ); m_pTrustFileROFI->Show( mbURLsReadonly ); - m_pTrustFileLocLB->Enable( !mbURLsReadonly ); m_pAddLocPB->Enable( !mbURLsReadonly ); sal_Int32 nEntryCnt = aSecureURLs.getLength(); diff --git a/xmlsecurity/uiconfig/ui/securitytrustpage.ui b/xmlsecurity/uiconfig/ui/securitytrustpage.ui index c6c13f87f87e..30a1280c6c02 100644 --- a/xmlsecurity/uiconfig/ui/securitytrustpage.ui +++ b/xmlsecurity/uiconfig/ui/securitytrustpage.ui @@ -155,6 +155,8 @@ <property name="can_focus">False</property> <property name="no_show_all">True</property> <property name="pixbuf">res/lock.png</property> + <property name="halign">center</property> + <property name="valign">center</property> </object> <packing> <property name="left_attach">0</property> @@ -299,6 +301,8 @@ <property name="can_focus">False</property> <property name="no_show_all">True</property> <property name="pixbuf">res/lock.png</property> + <property name="halign">center</property> + <property name="valign">center</property> </object> <packing> <property name="left_attach">0</property> |