summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-08-15 21:32:27 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-20 17:12:11 +0200
commit0787ce8814e37972a0c968f60008d4e8722b6e27 (patch)
tree9d2803ebda8813e6b3f2bc2e6f8a74953b2931c1 /xmlsecurity
parentd2c9c60fefb9687adbde4be61ed66a5123a2587f (diff)
Simplify containers iterations, tdf#96099 follow-up
Use range-based loop or replace with std::any_of, std::find and std::find_if where applicable. Change-Id: I2f80788c49d56094c29b102eb96a7a7c079567c6 Reviewed-on: https://gerrit.libreoffice.org/59143 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/dialogs/resourcemanager.cxx12
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx14
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx22
3 files changed, 19 insertions, 29 deletions
diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx
index a47cedc3d260..3b2db2a800eb 100644
--- a/xmlsecurity/source/dialogs/resourcemanager.cxx
+++ b/xmlsecurity/source/dialogs/resourcemanager.cxx
@@ -311,14 +311,10 @@ vector< pair< OUString, OUString> > parseDN(const OUString& rRawString)
while ( aIDs[i] )
{
OUString sPartId = OUString::createFromAscii( aIDs[i++] );
- for (auto idn = vecAttrValueOfDN.cbegin(); idn != vecAttrValueOfDN.cend(); ++idn)
- {
- if (idn->first == sPartId)
- {
- retVal = idn->second;
- break;
- }
- }
+ auto idn = std::find_if(vecAttrValueOfDN.cbegin(), vecAttrValueOfDN.cend(),
+ [&sPartId](const pair< OUString, OUString >& dn) { return dn.first == sPartId; });
+ if (idn != vecAttrValueOfDN.cend())
+ retVal = idn->second;
if (!retVal.isEmpty())
break;
}
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index a567b90aa6da..db05059b31df 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -142,17 +142,9 @@ bool DocumentSignatureHelper::isODFPre_1_2(const OUString & sVersion)
bool DocumentSignatureHelper::isOOo3_2_Signature(const SignatureInformation & sigInfo)
{
- bool bOOo3_2 = false;
- for (auto i = sigInfo.vSignatureReferenceInfors.cbegin();
- i < sigInfo.vSignatureReferenceInfors.cend(); ++i)
- {
- if (i->ouURI == "META-INF/manifest.xml")
- {
- bOOo3_2 = true;
- break;
- }
- }
- return bOOo3_2;
+ return std::any_of(sigInfo.vSignatureReferenceInfors.cbegin(),
+ sigInfo.vSignatureReferenceInfors.cend(),
+ [](const SignatureReferenceInformation& info) { return info.ouURI == "META-INF/manifest.xml"; });
}
DocumentSignatureAlgorithm
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 7fb84e177dfa..3f928b05bcc8 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -113,9 +113,9 @@ SecurityEnvironment_NssImpl::~SecurityEnvironment_NssImpl() {
PK11_SetPasswordFunc( nullptr ) ;
- for (auto i = m_Slots.cbegin(); i != m_Slots.cend(); i++)
+ for (auto& slot : m_Slots)
{
- PK11_FreeSlot(*i);
+ PK11_FreeSlot(slot);
}
if( !m_tSymKeyList.empty() ) {
@@ -185,9 +185,9 @@ const Sequence< sal_Int8>& SecurityEnvironment_NssImpl::getUnoTunnelId() {
OUString SecurityEnvironment_NssImpl::getSecurityEnvironmentInformation()
{
OUStringBuffer buff;
- for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is)
+ for (auto& slot : m_Slots)
{
- buff.append(OUString::createFromAscii(PK11_GetTokenName(*is)));
+ buff.append(OUString::createFromAscii(PK11_GetTokenName(slot)));
buff.append("\n");
}
return buff.makeStringAndClear();
@@ -291,9 +291,8 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
updateSlots();
//firstly, we try to find private keys in slot
- for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is)
+ for (auto& slot : m_Slots)
{
- PK11SlotInfo *slot = *is;
SECKEYPrivateKeyList* priKeyList ;
if( PK11_NeedLogin(slot ) ) {
@@ -765,9 +764,9 @@ sal_Int32 SecurityEnvironment_NssImpl::getCertificateCharacters(
}
if(priKey == nullptr)
{
- for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is)
+ for (auto& slot : m_Slots)
{
- priKey = PK11_FindPrivateKeyFromCert(*is, const_cast<CERTCertificate*>(cert), nullptr);
+ priKey = PK11_FindPrivateKeyFromCert(slot, const_cast<CERTCertificate*>(cert), nullptr);
if (priKey)
break;
}
@@ -832,8 +831,11 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() {
std::unique_ptr<PK11SlotInfo*[]> sarSlots(new PK11SlotInfo*[cSlots]);
PK11SlotInfo** slots = sarSlots.get();
int count = 0;
- for (auto islots = m_Slots.cbegin();islots != m_Slots.cend(); ++islots, ++count)
- slots[count] = *islots;
+ for (auto& slot : m_Slots)
+ {
+ slots[count] = slot;
+ ++count;
+ }
xmlSecKeysMngrPtr pKeysMngr = xmlSecKeysMngrCreate();
if (!pKeysMngr)