summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-14 16:09:20 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-15 14:16:26 +0000
commit8ca2d453e3008c265c8968529991d01579ff8f3a (patch)
tree56a75ebbbb9bbf86b8e3e8f53befb2b415bbab63 /xmlsecurity
parentfb5113dc1656920ec8a17ef3faef6ad07ad73e7c (diff)
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>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx17
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx24
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx24
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx17
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx24
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx23
-rw-r--r--xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx7
7 files changed, 23 insertions, 113 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index f383046aa5d3..710191cf4ab1 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -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() ;
diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx
index 38a329ab4cf6..14d21e1ef98f 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx
@@ -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() ;
diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx
index 746dd766f8e6..010743509469 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx
@@ -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() ;
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 915b4b6346b0..959e62cc34e0 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -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 ) {
diff --git a/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx
index 9fa3b3166f1d..804e69bc4226 100644
--- a/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/xmlencryption_nssimpl.cxx
@@ -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>(
diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx
index 8d2e9b40fc95..3271b5408ade 100644
--- a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx
@@ -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>(
diff --git a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
index fafa81d30e42..d97c9d906da7 100644
--- a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
+++ b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
@@ -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>(