diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-26 12:47:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-27 09:06:10 +0200 |
commit | 595309903211ed5986ba0d2ef4d3b21bdfad10d9 (patch) | |
tree | cfcf597d2008a974be1365ad9e9ca9da1d188f07 /xmlsecurity | |
parent | cdd211d0a3f8bf977ecca67e72afbc63d53a72ee (diff) |
loplugin:flatten in vcl..xmlsecurity
Change-Id: I730fc0b3b6b7ac1803d75b5d9e007b15395888c6
Reviewed-on: https://gerrit.libreoffice.org/42826
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
3 files changed, 25 insertions, 35 deletions
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 073ac07d44d4..10f7d0779d2b 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -87,21 +87,18 @@ namespace { OUString sDef("ODF/DefaultVersion"); Sequence< css::uno::Any > aValues = GetProperties( Sequence<OUString>(&sDef,1) ); - if ( aValues.getLength() == 1) - { - sal_Int16 nTmp = 0; - if ( aValues[0] >>= nTmp ) - m_nODF = nTmp; - else - throw uno::RuntimeException( - "[xmlsecurity]SaveODFItem::SaveODFItem(): Wrong Type!", - nullptr ); - - } - else + if ( aValues.getLength() != 1) throw uno::RuntimeException( "[xmlsecurity] Could not open property Office.Common/Save/ODF/DefaultVersion", nullptr); + + sal_Int16 nTmp = 0; + if ( !(aValues[0] >>= nTmp) ) + throw uno::RuntimeException( + "[xmlsecurity]SaveODFItem::SaveODFItem(): Wrong Type!", + nullptr ); + + m_nODF = nTmp; } } diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx index a996ce5d43f4..dd6336578ea4 100644 --- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx +++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx @@ -441,19 +441,17 @@ css::uno::Reference< css::xml::crypto::XCipherContext > SAL_CALL ONSSInitializer { CK_MECHANISM_TYPE nNSSCipherID = 0; bool bW3CPadding = false; - if ( nCipherID == css::xml::crypto::CipherID::AES_CBC_W3C_PADDING ) - { - nNSSCipherID = CKM_AES_CBC; - bW3CPadding = true; + if ( nCipherID != css::xml::crypto::CipherID::AES_CBC_W3C_PADDING ) + throw css::lang::IllegalArgumentException("Unexpected cipher requested.", css::uno::Reference< css::uno::XInterface >(), 1 ); - if ( aKey.getLength() != 16 && aKey.getLength() != 24 && aKey.getLength() != 32 ) - throw css::lang::IllegalArgumentException("Unexpected key length.", css::uno::Reference< css::uno::XInterface >(), 2 ); + nNSSCipherID = CKM_AES_CBC; + bW3CPadding = true; - if ( aParams.getLength() ) - throw css::lang::IllegalArgumentException("Unexpected arguments provided for cipher creation.", css::uno::Reference< css::uno::XInterface >(), 5 ); - } - else - throw css::lang::IllegalArgumentException("Unexpected cipher requested.", css::uno::Reference< css::uno::XInterface >(), 1 ); + if ( aKey.getLength() != 16 && aKey.getLength() != 24 && aKey.getLength() != 32 ) + throw css::lang::IllegalArgumentException("Unexpected key length.", css::uno::Reference< css::uno::XInterface >(), 2 ); + + if ( aParams.getLength() ) + throw css::lang::IllegalArgumentException("Unexpected arguments provided for cipher creation.", css::uno::Reference< css::uno::XInterface >(), 5 ); css::uno::Reference< css::xml::crypto::XCipherContext > xResult; if( initNSS( m_xContext ) ) diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx index 371a27f3d090..d01eb3ffa692 100644 --- a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx @@ -62,25 +62,20 @@ sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironmentNumber( ) css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironmentByIndex( sal_Int32 index ) { - css::uno::Reference< css::xml::crypto::XSecurityEnvironment > xSecurityEnvironment; - - if (index >= 0 && index < ( sal_Int32 )m_vSecurityEnvironments.size()) - { - xSecurityEnvironment = m_vSecurityEnvironments[index]; - } - else - throw RuntimeException() ; + if (index < 0 || index >= ( sal_Int32 )m_vSecurityEnvironments.size()) + throw RuntimeException(); + css::uno::Reference< css::xml::crypto::XSecurityEnvironment > xSecurityEnvironment = m_vSecurityEnvironments[index]; return xSecurityEnvironment; } css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironment( ) { - if (m_nDefaultEnvIndex >= 0 && m_nDefaultEnvIndex < ( sal_Int32 )m_vSecurityEnvironments.size()) - return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex); - else - throw RuntimeException() ; + if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= ( sal_Int32 )m_vSecurityEnvironments.size()) + throw RuntimeException(); + + return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex); } sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getDefaultSecurityEnvironmentIndex( ) |