From 24e14afd1bfcaed6c200ab081973fba7e47267ca Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 21 Dec 2022 16:01:08 +0100 Subject: [PATCH] loplugin:unocast (SignatureVerifierImpl) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I3c2f1eae3d9b2b5ecb6a05c9e7149946b63bb11f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144697 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- xmlsecurity/inc/framework/signatureverifierimpl.hxx | 7 ++++++- xmlsecurity/source/framework/signatureverifierimpl.cxx | 10 ++++++++++ xmlsecurity/source/helper/xsecverify.cxx | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/xmlsecurity/inc/framework/signatureverifierimpl.hxx b/xmlsecurity/inc/framework/signatureverifierimpl.hxx index 15c79643e0aa..29d286d7ee57 100644 --- a/xmlsecurity/inc/framework/signatureverifierimpl.hxx +++ b/xmlsecurity/inc/framework/signatureverifierimpl.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -35,7 +36,8 @@ typedef cppu::ImplInheritanceHelper SignatureEngine, css::xml::crypto::sax::XSignatureVerifyResultBroadcaster, css::lang::XInitialization, - css::lang::XServiceInfo + css::lang::XServiceInfo, + css::lang::XUnoTunnel > SignatureVerifierImpl_Base; class SignatureVerifierImpl final : public SignatureVerifierImpl_Base @@ -74,6 +76,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence const & aIdentifier) override; + static css::uno::Sequence const & getUnoTunnelId(); + void updateSignature( const css::uno::Reference< css::xml::crypto::XXMLSignature >& xSignature, const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& xContext ) { m_xXMLSignature = xSignature; m_xXMLSecurityContext = xContext; } }; diff --git a/xmlsecurity/source/framework/signatureverifierimpl.cxx b/xmlsecurity/source/framework/signatureverifierimpl.cxx index 44e9e4c0a46c..3489dab31bed 100644 --- a/xmlsecurity/source/framework/signatureverifierimpl.cxx +++ b/xmlsecurity/source/framework/signatureverifierimpl.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -127,4 +128,13 @@ css::uno::Sequence< OUString > SAL_CALL SignatureVerifierImpl::getSupportedServi return SignatureVerifierImpl_getSupportedServiceNames(); } +sal_Int64 SignatureVerifierImpl::getSomething(css::uno::Sequence const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence const & SignatureVerifierImpl::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx index c45bece5fed9..e2d3fc8b5050 100644 --- a/xmlsecurity/source/helper/xsecverify.cxx +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -42,6 +42,7 @@ #include #include #include +#include namespace com::sun::star::graphic { class XGraphic; } @@ -133,8 +134,8 @@ void XSecController::switchGpgSignature() return; SignatureVerifierImpl* pImpl= - dynamic_cast( - m_vInternalSignatureInformations.back().xReferenceResolvedListener.get()); + comphelper::getFromUnoTunnel( + m_vInternalSignatureInformations.back().xReferenceResolvedListener); if (pImpl) { css::uno::Reference xGpgSEInitializer(