diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-17 09:50:25 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-17 11:17:22 +0000 |
commit | 302f25890b5ec409a003db5ed412a3b9fdbfb430 (patch) | |
tree | af88373ddbe9a54c6b058a9a6920ac897a37ba81 /xmlsecurity | |
parent | 707f59b224fda6a0377960476fe35bab32fa4bc1 (diff) |
xmlsecurity: hold SAXEventKeeperImpl by rtl::Reference in XSecController
SAXEventKeeperImpl is the only implementation of the
css::xml::crypto::sax::XSecuritySAXEventKeeper interface, and this way
it's not necessary to cast to various interfaces explicitly at a lot of
places.
Change-Id: I25f76c88d5fefef42a6e8394a9d6de98c52b12c0
Reviewed-on: https://gerrit.libreoffice.org/35317
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/inc/xsecctl.hxx | 3 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecctl.cxx | 20 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecsign.cxx | 16 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecverify.cxx | 17 |
4 files changed, 18 insertions, 38 deletions
diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx index 322b1ddb801e..731004e5ddf2 100644 --- a/xmlsecurity/inc/xsecctl.hxx +++ b/xmlsecurity/inc/xsecctl.hxx @@ -61,6 +61,7 @@ class XSecParser; class XMLDocumentWrapper_XmlSecImpl; +class SAXEventKeeperImpl; class InternalSignatureInformation { @@ -118,7 +119,7 @@ private: /* * the SAX events keeper */ - css::uno::Reference< css::xml::crypto::sax::XSecuritySAXEventKeeper > m_xSAXEventKeeper; + rtl::Reference<SAXEventKeeperImpl> m_xSAXEventKeeper; /* * the bridge component which creates/verifies signature diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index 578a3a6db713..e28f8bd8f901 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -146,19 +146,14 @@ void XSecController::createXSecComponent( ) * SAXEventKeeper created successfully. */ { - cssu::Reference< cssl::XInitialization > xInitialization(m_xSAXEventKeeper, cssu::UNO_QUERY); - cssu::Sequence <cssu::Any> arg(1); arg[0] <<= uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper.get()); - xInitialization->initialize(arg); + m_xSAXEventKeeper->initialize(arg); - cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster> - xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); cssu::Reference< cssxc::sax::XSAXEventKeeperStatusChangeListener > xStatusChangeListener = this; - xSAXEventKeeperStatusChangeBroadcaster - ->addSAXEventKeeperStatusChangeListener( xStatusChangeListener ); + m_xSAXEventKeeper->addSAXEventKeeperStatusChangeListener( xStatusChangeListener ); m_eStatusOfSecurityComponents = InitializationState::INITIALIZED; } @@ -222,7 +217,7 @@ bool XSecController::chainOn( bool bRetrievingLastEvent ) */ m_xSAXEventKeeper->setNextHandler( nullptr ); - cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), cssu::UNO_QUERY); /* * connects the previous document handler on the SAX chain @@ -485,7 +480,7 @@ void XSecController::clearSAXChainConnector() */ if (m_xElementStackKeeper.is() && m_xSAXEventKeeper.is()) { - cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), cssu::UNO_QUERY); m_xElementStackKeeper->retrieve(xSEKHandler, true); } @@ -533,12 +528,7 @@ void XSecController::endMission() * free the status change listener reference to this object */ if (m_xSAXEventKeeper.is()) - { - cssu::Reference<cssxc::sax::XSAXEventKeeperStatusChangeBroadcaster> - xSAXEventKeeperStatusChangeBroadcaster(m_xSAXEventKeeper, cssu::UNO_QUERY); - xSAXEventKeeperStatusChangeBroadcaster - ->addSAXEventKeeperStatusChangeListener( nullptr ); - } + m_xSAXEventKeeper->addSAXEventKeeperStatusChangeListener( nullptr ); } namespace diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index 40e6f1b28c52..1b2d81b62c2f 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -31,6 +31,7 @@ #include <rtl/uuid.h> #include "framework/signaturecreatorimpl.hxx" +#include "framework/saxeventkeeperimpl.hxx" using namespace com::sun::star; namespace cssu = com::sun::star::uno; @@ -75,7 +76,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar cssu::Sequence<cssu::Any> args(5); args[0] <<= OUString::number(nSecurityId); - args[1] <<= m_xSAXEventKeeper; + args[1] <<= uno::Reference<xml::crypto::sax::XSecuritySAXEventKeeper>(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), uno::UNO_QUERY); args[2] <<= OUString::number(nIdOfSignatureElementCollector); //for nss, the internal module is used for signing, which needs to be improved later @@ -95,12 +96,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar xSignatureCreationResultBroadcaster->addSignatureCreationResultListener( this ); - cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> - xReferenceResolvedBroadcaster - (m_xSAXEventKeeper, - cssu::UNO_QUERY); - - xReferenceResolvedBroadcaster->addReferenceResolvedListener( + m_xSAXEventKeeper->addReferenceResolvedListener( nIdOfSignatureElementCollector, xReferenceResolvedListener); @@ -118,7 +114,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar if ( keeperId != -1) { m_xSAXEventKeeper->setSecurityId(keeperId, nSecurityId); - xReferenceResolvedBroadcaster->addReferenceResolvedListener( keeperId, xReferenceResolvedListener); + m_xSAXEventKeeper->addReferenceResolvedListener( keeperId, xReferenceResolvedListener); xReferenceCollector->setReferenceId( keeperId ); nReferenceCount++; } @@ -307,7 +303,7 @@ bool XSecController::WriteSignature( /* * export the signature template */ - cssu::Reference<cssxs::XDocumentHandler> xSEKHandler( m_xSAXEventKeeper,cssu::UNO_QUERY); + cssu::Reference<cssxs::XDocumentHandler> xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()),cssu::UNO_QUERY); int i; int sigNum = m_vInternalSignatureInformations.size(); @@ -356,7 +352,7 @@ bool XSecController::WriteOOXMLSignature(const uno::Reference<embed::XStorage>& try { // Export the signature template. - cssu::Reference<xml::sax::XDocumentHandler> xSEKHandler(m_xSAXEventKeeper, uno::UNO_QUERY); + cssu::Reference<xml::sax::XDocumentHandler> xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), uno::UNO_QUERY); for (InternalSignatureInformation & rInformation : m_vInternalSignatureInformations) { diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx index 1646552c40f1..d5eab0e1a630 100644 --- a/xmlsecurity/source/helper/xsecverify.cxx +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -22,6 +22,7 @@ #include "xsecparser.hxx" #include "ooxmlsecparser.hxx" #include "framework/signatureverifierimpl.hxx" +#include "framework/saxeventkeeperimpl.hxx" #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp> #include <com/sun/star/xml/crypto/sax/ElementMarkPriority.hpp> @@ -66,7 +67,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar cssu::Sequence<cssu::Any> args(5); args[0] <<= OUString::number(nSecurityId); - args[1] <<= m_xSAXEventKeeper; + args[1] <<= uno::Reference<xml::crypto::sax::XSecuritySAXEventKeeper>(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), uno::UNO_QUERY); args[2] <<= OUString::number(nIdOfSignatureElementCollector); args[3] <<= m_xSecurityContext; args[4] <<= m_xXMLSignature; @@ -77,11 +78,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar signatureVerifyResultBroadcaster->addSignatureVerifyResultListener( this ); - cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster - (m_xSAXEventKeeper, - cssu::UNO_QUERY); - - xReferenceResolvedBroadcaster->addReferenceResolvedListener( + m_xSAXEventKeeper->addReferenceResolvedListener( nIdOfSignatureElementCollector, xReferenceResolvedListener); @@ -370,15 +367,11 @@ void XSecController::collectToVerify( const OUString& referenceId ) sal_Int32 nKeeperId = m_xSAXEventKeeper->addSecurityElementCollector( cssxc::sax::ElementMarkPriority_BEFOREMODIFY, false ); - cssu::Reference<cssxc::sax::XReferenceResolvedBroadcaster> xReferenceResolvedBroadcaster - (m_xSAXEventKeeper, - cssu::UNO_QUERY ); - cssu::Reference<cssxc::sax::XReferenceCollector> xReferenceCollector ( isi.xReferenceResolvedListener, cssu::UNO_QUERY ); m_xSAXEventKeeper->setSecurityId(nKeeperId, isi.signatureInfor.nSecurityId); - xReferenceResolvedBroadcaster->addReferenceResolvedListener( nKeeperId, isi.xReferenceResolvedListener); + m_xSAXEventKeeper->addReferenceResolvedListener( nKeeperId, isi.xReferenceResolvedListener); xReferenceCollector->setReferenceId( nKeeperId ); isi.vKeeperIds[j] = nKeeperId; @@ -389,7 +382,7 @@ void XSecController::collectToVerify( const OUString& referenceId ) if ( bJustChainingOn ) { - cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(m_xSAXEventKeeper, cssu::UNO_QUERY); + cssu::Reference< cssxs::XDocumentHandler > xSEKHandler(static_cast<cppu::OWeakObject*>(m_xSAXEventKeeper.get()), cssu::UNO_QUERY); if (m_xElementStackKeeper.is()) { m_xElementStackKeeper->retrieve(xSEKHandler, true); |