From 1cfcbf3573206c2e9c435f276ba8d7431c75665c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 21 Sep 2017 08:21:35 +0200 Subject: xmlsecurity: hold SignatureCreatorImpl by rtl::Reference Not going via UNO means explicit interface casting can be avoided. Change-Id: I4fa2db810cade787913bca222530405d8d2eb6a9 Reviewed-on: https://gerrit.libreoffice.org/42573 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- xmlsecurity/inc/framework/securityengine.hxx | 4 ++- xmlsecurity/source/helper/xsecsign.cxx | 47 +++++++++------------------- 2 files changed, 17 insertions(+), 34 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/inc/framework/securityengine.hxx b/xmlsecurity/inc/framework/securityengine.hxx index b0cb842d5e56..b0d0a361324e 100644 --- a/xmlsecurity/inc/framework/securityengine.hxx +++ b/xmlsecurity/inc/framework/securityengine.hxx @@ -29,7 +29,9 @@ #include -class SAL_DLLPUBLIC_RTTI SecurityEngine : public cppu::WeakImplHelper +#include + +class XSECFW_DLLPUBLIC SecurityEngine : public cppu::WeakImplHelper < css::xml::crypto::sax::XReferenceResolvedListener, css::xml::crypto::sax::XKeyCollector, diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index cd173e2fb956..f55c57910443 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -20,7 +20,6 @@ #include "xsecctl.hxx" -#include #include #include #include @@ -70,9 +69,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar m_xSAXEventKeeper->setSecurityId(nIdOfSignatureElementCollector, nSecurityId); - uno::Reference xReferenceResolvedListener(new SignatureCreatorImpl); - - cssu::Reference xInitialization(xReferenceResolvedListener, cssu::UNO_QUERY); + rtl::Reference xSignatureCreator(new SignatureCreatorImpl); cssu::Sequence args(5); args[0] <<= OUString::number(nSecurityId); @@ -83,52 +80,39 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar args[3] <<= m_xSecurityContext->getSecurityEnvironment(); args[4] <<= m_xXMLSignature; - xInitialization->initialize(args); + xSignatureCreator->initialize(args); sal_Int32 nBlockerId = m_xSAXEventKeeper->addBlocker(); m_xSAXEventKeeper->setSecurityId(nBlockerId, nSecurityId); - cssu::Reference xBlockerMonitor(xReferenceResolvedListener, cssu::UNO_QUERY); - xBlockerMonitor->setBlockerId(nBlockerId); - - cssu::Reference< cssxc::sax::XSignatureCreationResultBroadcaster > - xSignatureCreationResultBroadcaster(xReferenceResolvedListener, cssu::UNO_QUERY); - - xSignatureCreationResultBroadcaster->addSignatureCreationResultListener( this ); + xSignatureCreator->setBlockerId(nBlockerId); - m_xSAXEventKeeper->addReferenceResolvedListener( - nIdOfSignatureElementCollector, - xReferenceResolvedListener); + xSignatureCreator->addSignatureCreationResultListener(this); - cssu::Reference xReferenceCollector - (xReferenceResolvedListener, cssu::UNO_QUERY); + m_xSAXEventKeeper->addReferenceResolvedListener(nIdOfSignatureElementCollector, xSignatureCreator.get()); - int i; int size = vReferenceInfors.size(); sal_Int32 nReferenceCount = 0; - for(i=0; isetSecurityId(keeperId, nSecurityId); - m_xSAXEventKeeper->addReferenceResolvedListener( keeperId, xReferenceResolvedListener); - xReferenceCollector->setReferenceId( keeperId ); + m_xSAXEventKeeper->addReferenceResolvedListener( keeperId, xSignatureCreator.get()); + xSignatureCreator->setReferenceId( keeperId ); nReferenceCount++; } } - xReferenceCollector->setReferenceCount( nReferenceCount ); + xSignatureCreator->setReferenceCount( nReferenceCount ); /* * adds all URI binding */ - cssu::Reference xUriBinding - (xReferenceResolvedListener, cssu::UNO_QUERY); - - for(i=0; i XSecController::prepar = getObjectInputStream( refInfor.ouURI ); if (xInputStream.is()) - { - xUriBinding->setUriBinding(refInfor.ouURI,xInputStream); - } + xSignatureCreator->setUriBinding(refInfor.ouURI,xInputStream); } - cssu::Reference keyCollector (xReferenceResolvedListener, cssu::UNO_QUERY); - keyCollector->setKeyId(0); + xSignatureCreator->setKeyId(0); // use sha512 for gpg signing unconditionally const sal_Int32 digestID = !internalSignatureInfor.signatureInfor.ouGpgCertificate.isEmpty()? @@ -182,7 +163,7 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar /* * replace both digestValues and signatureValue to " " */ - for(i=0; i XSecController::prepar internalSignatureInfor.signatureInfor.ouSignatureValue = " "; - return xReferenceResolvedListener; + return xSignatureCreator.get(); } void XSecController::signAStream( sal_Int32 securityId, const OUString& uri, bool isBinary, bool bXAdESCompliantIfODF) -- cgit