Some simplifications, using UNO_QUERY_THROW
Change-Id: I6e7555472da6b23af4c64b299182339a5b324ee9 Reviewed-on: https://gerrit.libreoffice.org/34250 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
fb5113dc16
commit
8ca2d453e3
7 changed files with 23 additions and 113 deletions
|
@ -638,11 +638,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer
|
|||
chainPara.cbSize = sizeof( CERT_CHAIN_PARA ) ;
|
||||
chainPara.RequestedUsage = certUsage ;
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY_THROW ) ;
|
||||
xcert = reinterpret_cast<X509Certificate_MSCryptImpl*>(xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( xcert == nullptr ) {
|
||||
throw RuntimeException() ;
|
||||
|
@ -814,10 +810,7 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate(
|
|||
PCCERT_CONTEXT pCertContext = nullptr;
|
||||
const X509Certificate_MSCryptImpl* xcert = nullptr;
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY_THROW ) ;
|
||||
|
||||
SAL_INFO("xmlsecurity.xmlsec", "Start verification of certificate: " << aCert->getSubjectName());
|
||||
|
||||
|
@ -981,11 +974,7 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::getCertificateCharacters( const css::
|
|||
PCCERT_CONTEXT pCertContext ;
|
||||
const X509Certificate_MSCryptImpl* xcert ;
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY_THROW ) ;
|
||||
xcert = reinterpret_cast<X509Certificate_MSCryptImpl*>(xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( xcert == nullptr ) {
|
||||
throw RuntimeException() ;
|
||||
|
|
|
@ -74,11 +74,7 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt(
|
|||
throw RuntimeException() ;
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( pSecEnv == nullptr )
|
||||
throw RuntimeException() ;
|
||||
|
@ -89,11 +85,7 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ;
|
||||
if( !xTplTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pTemplate = reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ));
|
||||
if( pTemplate == nullptr ) {
|
||||
throw RuntimeException() ;
|
||||
|
@ -210,11 +202,7 @@ XMLEncryption_MSCryptImpl::decrypt(
|
|||
Reference< XSecurityEnvironment > xSecEnv
|
||||
= aSecurityCtx->getSecurityEnvironmentByIndex(
|
||||
aSecurityCtx->getDefaultSecurityEnvironmentIndex());
|
||||
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( pSecEnv == nullptr )
|
||||
throw RuntimeException() ;
|
||||
|
@ -225,11 +213,7 @@ XMLEncryption_MSCryptImpl::decrypt(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ;
|
||||
if( !xTplTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pTemplate = reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ));
|
||||
if( pTemplate == nullptr ) {
|
||||
throw RuntimeException() ;
|
||||
|
|
|
@ -66,11 +66,7 @@ SAL_CALL XMLSignature_MSCryptImpl::generate(
|
|||
throw RuntimeException() ;
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( pSecEnv == nullptr )
|
||||
throw RuntimeException() ;
|
||||
|
@ -81,11 +77,7 @@ SAL_CALL XMLSignature_MSCryptImpl::generate(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ;
|
||||
if( !xNodTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pElement = reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ));
|
||||
if( pElement == nullptr ) {
|
||||
throw RuntimeException() ;
|
||||
|
@ -163,11 +155,7 @@ SAL_CALL XMLSignature_MSCryptImpl::validate(
|
|||
Reference< XSecurityEnvironment > xSecEnv
|
||||
= aSecurityCtx->getSecurityEnvironmentByIndex(
|
||||
aSecurityCtx->getDefaultSecurityEnvironmentIndex());
|
||||
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ));
|
||||
if( pSecEnv == nullptr )
|
||||
throw RuntimeException() ;
|
||||
|
@ -177,11 +165,7 @@ SAL_CALL XMLSignature_MSCryptImpl::validate(
|
|||
if( !xElement.is() )
|
||||
throw RuntimeException() ;
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ;
|
||||
if( !xNodTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pElement = reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(xNodTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ));
|
||||
if( pElement == nullptr )
|
||||
throw RuntimeException() ;
|
||||
|
|
|
@ -478,11 +478,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi
|
|||
const CERTCertificate* cert ;
|
||||
CERTCertList* certChain ;
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( begin, UNO_QUERY_THROW ) ;
|
||||
xcert = reinterpret_cast<X509Certificate_NssImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(xCertTunnel->getSomething( X509Certificate_NssImpl::getUnoTunnelId() ))) ;
|
||||
if( xcert == nullptr ) {
|
||||
|
@ -574,10 +570,7 @@ verifyCertificate( const Reference< csss::XCertificate >& aCert,
|
|||
const X509Certificate_NssImpl* xcert ;
|
||||
const CERTCertificate* cert ;
|
||||
::std::vector<CERTCertificate*> vecTmpNSSCertificates;
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY_THROW ) ;
|
||||
|
||||
SAL_INFO("xmlsecurity.xmlsec", "Start verification of certificate: " << aCert->getSubjectName());
|
||||
|
||||
|
@ -798,11 +791,7 @@ sal_Int32 SecurityEnvironment_NssImpl::getCertificateCharacters(
|
|||
const X509Certificate_NssImpl* xcert ;
|
||||
const CERTCertificate* cert ;
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY ) ;
|
||||
if( !xCertTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY_THROW ) ;
|
||||
xcert = reinterpret_cast<X509Certificate_NssImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(xCertTunnel->getSomething( X509Certificate_NssImpl::getUnoTunnelId() ))) ;
|
||||
if( xcert == nullptr ) {
|
||||
|
|
|
@ -70,11 +70,7 @@ SAL_CALL XMLEncryption_NssImpl::encrypt(
|
|||
throw RuntimeException() ;
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_NssImpl* pSecEnv =
|
||||
reinterpret_cast<SecurityEnvironment_NssImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(xSecTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ))) ;
|
||||
|
@ -87,11 +83,7 @@ SAL_CALL XMLEncryption_NssImpl::encrypt(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ;
|
||||
if( !xTplTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pTemplate =
|
||||
reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
@ -211,11 +203,7 @@ SAL_CALL XMLEncryption_NssImpl::decrypt(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY ) ;
|
||||
if( !xTplTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xTplTunnel( xTemplate , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pTemplate =
|
||||
reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
@ -251,11 +239,7 @@ SAL_CALL XMLEncryption_NssImpl::decrypt(
|
|||
Reference< XSecurityEnvironment > aEnvironment = aSecurityCtx->getSecurityEnvironmentByIndex(i);
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !aEnvironment.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_NssImpl* pSecEnv =
|
||||
reinterpret_cast<SecurityEnvironment_NssImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
|
|
@ -75,11 +75,7 @@ SAL_CALL XMLSignature_NssImpl::generate(
|
|||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ;
|
||||
if( !xNodTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pElement =
|
||||
reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
@ -99,10 +95,7 @@ SAL_CALL XMLSignature_NssImpl::generate(
|
|||
}
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
|
||||
// the key manager should be retrieved from SecurityEnvironment, instead of SecurityContext
|
||||
|
||||
|
@ -177,11 +170,7 @@ SAL_CALL XMLSignature_NssImpl::validate(
|
|||
if( !xElement.is() )
|
||||
throw RuntimeException() ;
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY ) ;
|
||||
if( !xNodTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xNodTunnel( xElement , UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pElement =
|
||||
reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
@ -209,11 +198,7 @@ SAL_CALL XMLSignature_NssImpl::validate(
|
|||
Reference< XSecurityEnvironment > aEnvironment = aSecurityCtx->getSecurityEnvironmentByIndex(i);
|
||||
|
||||
//Get Keys Manager
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
|
||||
if( !xSecTunnel.is() ) {
|
||||
throw RuntimeException() ;
|
||||
}
|
||||
|
||||
Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY_THROW ) ;
|
||||
SecurityEnvironment_NssImpl* pSecEnv =
|
||||
reinterpret_cast<SecurityEnvironment_NssImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
|
|
@ -384,12 +384,7 @@ xmlNodePtr XMLDocumentWrapper_XmlSecImpl::checkElement( const cssu::Reference< c
|
|||
|
||||
if (xXMLElement.is())
|
||||
{
|
||||
cssu::Reference< cssl::XUnoTunnel > xNodTunnel( xXMLElement, cssu::UNO_QUERY ) ;
|
||||
if( !xNodTunnel.is() )
|
||||
{
|
||||
throw cssu::RuntimeException() ;
|
||||
}
|
||||
|
||||
cssu::Reference< cssl::XUnoTunnel > xNodTunnel( xXMLElement, cssu::UNO_QUERY_THROW ) ;
|
||||
XMLElementWrapper_XmlSecImpl* pElement
|
||||
= reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
|
||||
sal::static_int_cast<sal_uIntPtr>(
|
||||
|
|
Loading…
Reference in a new issue