XUnoTunnel->dynamic_cast in SecurityEnvironment_MSCryptImpl

Change-Id: Idb013bd71b2a90cd6fb8927b199eb36e9bfd9c06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145474
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-01-13 15:52:25 +00:00
committed by Noel Grandin
parent 9e30158611
commit 817dc69bb6
4 changed files with 4 additions and 15 deletions
@@ -174,9 +174,6 @@ uno::Sequence< OUString > SAL_CALL SecurityEnvironment_MSCryptImpl::getSupported
return { "com.sun.star.xml.crypto.SecurityEnvironment" };
}
/* XUnoTunnel */
UNO3_GETIMPLEMENTATION_IMPL(SecurityEnvironment_MSCryptImpl);
HCRYPTPROV SecurityEnvironment_MSCryptImpl::getCryptoProvider() {
return m_hProv ;
}
@@ -39,7 +39,6 @@
#include <com/sun/star/security/XCertificate.hpp>
#include <com/sun/star/security/CertificateCharacters.hpp>
#include <com/sun/star/security/CertificateValidity.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <vector>
#include <xmlsec-wrapper.h>
@@ -49,8 +48,7 @@
class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper<
css::xml::crypto::XSecurityEnvironment ,
css::lang::XServiceInfo,
css::lang::XUnoTunnel >
css::lang::XServiceInfo >
{
private:
//crypto provider and key container
@@ -123,9 +121,6 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper<
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
//Methods from XUnoTunnel
UNO3_GETIMPLEMENTATION_DECL(SecurityEnvironment_MSCryptImpl)
/// @throws css::uno::Exception
/// @throws css::uno::RuntimeException
HCRYPTPROV getCryptoProvider() ;
@@ -78,8 +78,7 @@ uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL
uno::Reference< cssxc::XSecurityEnvironment > xSecEnv = cssxc::SecurityEnvironment::create( mxContext );
/* Setup key slot and certDb */
uno::Reference< cssl::XUnoTunnel > xSecEnvTunnel( xSecEnv, uno::UNO_QUERY_THROW );
SecurityEnvironment_MSCryptImpl* pSecEnv = comphelper::getFromUnoTunnel<SecurityEnvironment_MSCryptImpl>(xSecEnvTunnel);
SecurityEnvironment_MSCryptImpl* pSecEnv = dynamic_cast<SecurityEnvironment_MSCryptImpl*>(xSecEnv.get());
if( pSecEnv == nullptr )
{
if( n_hStoreHandle != nullptr )
@@ -102,8 +102,7 @@ SAL_CALL XMLSignature_MSCryptImpl::generate(
throw RuntimeException() ;
//Get Keys Manager
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
SecurityEnvironment_MSCryptImpl* pSecEnv = comphelper::getFromUnoTunnel<SecurityEnvironment_MSCryptImpl>(xSecTunnel);
SecurityEnvironment_MSCryptImpl* pSecEnv = dynamic_cast<SecurityEnvironment_MSCryptImpl*>(aEnvironment.get());
if( pSecEnv == nullptr )
throw RuntimeException() ;
@@ -191,8 +190,7 @@ SAL_CALL XMLSignature_MSCryptImpl::validate(
Reference< XSecurityEnvironment > xSecEnv
= aSecurityCtx->getSecurityEnvironmentByIndex(
aSecurityCtx->getDefaultSecurityEnvironmentIndex());
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY_THROW ) ;
SecurityEnvironment_MSCryptImpl* pSecEnv = comphelper::getFromUnoTunnel<SecurityEnvironment_MSCryptImpl>(xSecTunnel);
SecurityEnvironment_MSCryptImpl* pSecEnv = dynamic_cast<SecurityEnvironment_MSCryptImpl*>(xSecEnv.get());
if( pSecEnv == nullptr )
throw RuntimeException() ;