XUnoTunnel->dynamic_cast in X509Certificate_MSCryptImpl

Change-Id: If61114df98f4096798281a28ffcdf58168ff7fdc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145475
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-01-13 15:52:33 +00:00
committed by Noel Grandin
parent 817dc69bb6
commit 1fd4e669a9
3 changed files with 3 additions and 15 deletions
@@ -584,8 +584,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
chainPara.cbSize = sizeof( CERT_CHAIN_PARA ) ;
chainPara.RequestedUsage = certUsage ;
uno::Reference< XUnoTunnel > xCertTunnel( begin, uno::UNO_QUERY_THROW ) ;
const auto* xcert = comphelper::getFromUnoTunnel<X509Certificate_MSCryptImpl>(xCertTunnel);
const auto* xcert = dynamic_cast<X509Certificate_MSCryptImpl*>(begin.get());
if( xcert == nullptr ) {
throw uno::RuntimeException() ;
}
@@ -805,11 +804,9 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate(
PCCERT_CHAIN_CONTEXT pChainContext = nullptr;
PCCERT_CONTEXT pCertContext = nullptr;
uno::Reference< XUnoTunnel > xCertTunnel( aCert, uno::UNO_QUERY_THROW ) ;
SAL_INFO("xmlsecurity.xmlsec", "Start verification of certificate: " << aCert->getSubjectName());
const auto* xcert = comphelper::getFromUnoTunnel<X509Certificate_MSCryptImpl>(xCertTunnel);
const auto* xcert = dynamic_cast<X509Certificate_MSCryptImpl*>(aCert.get());
if( xcert == nullptr ) {
throw uno::RuntimeException() ;
}
@@ -973,8 +970,7 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::getCertificateCharacters( const css::
sal_Int32 characters ;
PCCERT_CONTEXT pCertContext ;
uno::Reference< XUnoTunnel > xCertTunnel( aCert, uno::UNO_QUERY_THROW ) ;
const auto* xcert = comphelper::getFromUnoTunnel<X509Certificate_MSCryptImpl>(xCertTunnel);
const auto* xcert = dynamic_cast<X509Certificate_MSCryptImpl*>(aCert.get());
if( xcert == nullptr ) {
throw uno::RuntimeException() ;
}
@@ -457,9 +457,6 @@ void X509Certificate_MSCryptImpl::setRawCert( Sequence< sal_Int8 > const & rawCe
}
}
/* XUnoTunnel */
UNO3_GETIMPLEMENTATION_IMPL(X509Certificate_MSCryptImpl);
static OUString findOIDDescription(char const *oid)
{
OUString ouOID = OUString::createFromAscii( oid );
@@ -30,7 +30,6 @@
#include <cppuhelper/implbase.hxx>
#include <comphelper/servicehelper.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/SecurityException.hpp>
#include <com/sun/star/security/CertificateKind.hpp>
@@ -39,7 +38,6 @@
class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper<
css::security::XCertificate ,
css::lang::XUnoTunnel,
css::lang::XServiceInfo > , public xmlsecurity::Certificate
{
private:
@@ -72,9 +70,6 @@ class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper<
virtual sal_Int32 SAL_CALL getCertificateUsage( ) override;
//Methods from XUnoTunnel
UNO3_GETIMPLEMENTATION_DECL(X509Certificate_MSCryptImpl)
/// @see xmlsecurity::Certificate::getSHA256Thumbprint().
virtual css::uno::Sequence<sal_Int8> getSHA256Thumbprint() override;