Skip to content

Commit ddcbae4

Browse files
metsmaiannaska
authored andcommitted
Don't filter with same CN (#540)
IB-5906 Signed-off-by: Raul Metsma <[email protected]>
1 parent b95b646 commit ddcbae4

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

client/dialogs/AddRecipients.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void AddRecipients::addAllRecipientToRightPane()
123123

124124
for(auto it = leftList.begin(); it != leftList.end(); ++it)
125125
{
126-
if(!rightList.contains(it.key()))
126+
if(!rightList.contains(it.value()->getKey().cert))
127127
{
128128
addRecipientToRightPane(it.value());
129129
history << toHistory(it.value()->getKey().cert);
@@ -187,14 +187,13 @@ void AddRecipients::addRecipientFromHistory()
187187

188188
AddressItem * AddRecipients::addRecipientToLeftPane(const QSslCertificate& cert)
189189
{
190-
QString friendlyName = SslCertificate(cert).friendlyName();
191-
if(leftList.contains(friendlyName))
190+
if(leftList.contains(cert))
192191
return nullptr;
193192

194193
AddressItem *leftItem = new AddressItem(CKey(cert), ui->leftPane);
195-
leftList.insert(friendlyName, leftItem);
194+
leftList.insert(cert, leftItem);
196195
ui->leftPane->addWidget(leftItem);
197-
bool contains = rightList.contains(friendlyName);
196+
bool contains = rightList.contains(cert);
198197
leftItem->disable(contains);
199198
leftItem->showButton(contains ? AddressItem::Added : AddressItem::Add);
200199

@@ -212,7 +211,7 @@ void AddRecipients::addRecipientToRightPane(Item *toAdd, bool update)
212211
{
213212
AddressItem *leftItem = qobject_cast<AddressItem *>(toAdd);
214213

215-
if (rightList.contains(SslCertificate(leftItem->getKey().cert).friendlyName()))
214+
if (rightList.contains(leftItem->getKey().cert))
216215
return;
217216

218217
if(update)
@@ -229,7 +228,7 @@ void AddRecipients::addRecipientToRightPane(Item *toAdd, bool update)
229228
if(dlg.result() != QMessageBox::Yes)
230229
return;
231230
}
232-
QList<QSslError> errors = QSslCertificate::verify(QList<QSslCertificate>() << leftItem->getKey().cert);
231+
QList<QSslError> errors = QSslCertificate::verify({ leftItem->getKey().cert });
233232
errors.removeAll(QSslError(QSslError::CertificateExpired, leftItem->getKey().cert));
234233
if(!errors.isEmpty())
235234
{
@@ -243,7 +242,7 @@ void AddRecipients::addRecipientToRightPane(Item *toAdd, bool update)
243242
}
244243
updated = update;
245244

246-
rightList.append(SslCertificate(leftItem->getKey().cert).friendlyName());
245+
rightList.append(leftItem->getKey().cert);
247246

248247
AddressItem *rightItem = new AddressItem(leftItem->getKey(), ui->leftPane);
249248
ui->rightPane->addWidget(rightItem);
@@ -288,10 +287,9 @@ void AddRecipients::initAddressItems(const std::vector<Item *> &items)
288287
for(Item *item: items)
289288
{
290289
AddressItem *leftItem = new AddressItem((qobject_cast<AddressItem *>(item))->getKey(), ui->leftPane);
291-
QString friendlyName = SslCertificate(leftItem->getKey().cert).friendlyName();
292290

293291
// Add to left pane
294-
leftList.insert(friendlyName, leftItem);
292+
leftList.insert(leftItem->getKey().cert, leftItem);
295293
ui->leftPane->addWidget(leftItem);
296294

297295
leftItem->disable(true);
@@ -347,15 +345,13 @@ void AddRecipients::rememberCerts(const QList<HistoryCertData>& selectedCertData
347345
void AddRecipients::removeRecipientFromRightPane(Item *toRemove)
348346
{
349347
AddressItem *rightItem = static_cast<AddressItem *>(toRemove);
350-
QString friendlyName = SslCertificate(rightItem->getKey().cert).friendlyName();
351-
352-
auto it = leftList.find(friendlyName);
348+
auto it = leftList.find(rightItem->getKey().cert);
353349
if(it != leftList.end())
354350
{
355351
it.value()->disable(false);
356352
it.value()->showButton(AddressItem::Add);
357353
}
358-
rightList.removeAll(friendlyName);
354+
rightList.removeAll(rightItem->getKey().cert);
359355
updated = true;
360356
ui->confirm->setDisabled(rightList.isEmpty());
361357
}
@@ -444,7 +440,6 @@ void AddRecipients::showResult(const QList<QSslCertificate> &result)
444440
for(const QSslCertificate &k: result)
445441
{
446442
SslCertificate c(k);
447-
448443
if((c.keyUsage().contains(SslCertificate::KeyEncipherment) ||
449444
c.keyUsage().contains(SslCertificate::KeyAgreement)) &&
450445
!c.enhancedKeyUsage().contains(SslCertificate::ServerAuth) &&

client/dialogs/AddRecipients.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "widgets/ItemList.h"
2525

2626
#include <QDialog>
27-
#include <QMap>
27+
#include <QHash>
2828

2929

3030
namespace Ui {
@@ -71,8 +71,8 @@ class AddRecipients : public QDialog
7171
HistoryCertData toHistory(const QSslCertificate& cert) const;
7272

7373
Ui::AddRecipients *ui;
74-
QMap<QString, AddressItem *> leftList;
75-
QStringList rightList;
74+
QHash<QSslCertificate, AddressItem *> leftList;
75+
QList<QSslCertificate> rightList;
7676
LdapSearch *ldap_person, *ldap_corp;
7777
bool personSearch = false;
7878
bool select = false;

0 commit comments

Comments
 (0)