summaryrefslogtreecommitdiffstats
path: root/pica-client/dialogs/forgedcertdialog.cpp
blob: 7a530037faebafa6b682e33791d3786f5cb90ea6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
	(c) Copyright  2012 - 2018 Anton Sviridenko
	https://picapica.im

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/
#include "forgedcertdialog.h"
#include "viewcertdialog.h"
#include <QGridLayout>
#include <QLabel>

ForgedCertDialog::ForgedCertDialog(QByteArray peer_id, QString received_cert, QString stored_cert, QWidget *parent) :
	QDialog(parent),
	received_cert_(received_cert),
	stored_cert_(stored_cert)
{
	QGridLayout *grid = new QGridLayout(this);

	QLabel *scary_text = new QLabel(tr(
	                                    "Previously stored and currently present certificates for user %1 do not match.\n\
This means that probably someone is trying to eavesdrop your communication\n\
using man-in-the-middle attack or impersonate the user.\n\
Connection aborted.").arg(peer_id.toBase64().constData()));

	btOK = new QPushButton(tr("OK"));
	btShow_stored_cert = new QPushButton(tr("View Stored Certificate..."));
	btShow_received_cert = new QPushButton(tr("View Received Certificate..."));

	grid->addWidget(scary_text, 0, 0, 1, 3, Qt::AlignCenter);
	grid->addWidget(btShow_stored_cert, 1, 0, Qt::AlignCenter);
	grid->addWidget(btShow_received_cert, 1, 2, Qt::AlignCenter);
	grid->addWidget(btOK, 2, 1, Qt::AlignCenter);


	setLayout(grid);

	connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
	connect(btShow_stored_cert, SIGNAL(clicked()), this, SLOT(StoredCert()));
	connect(btShow_received_cert, SIGNAL(clicked()), this, SLOT(ReceivedCert()));
}

void ForgedCertDialog::OK()
{
	done(0);
}

void ForgedCertDialog::ReceivedCert()
{
	ViewCertDialog vcd;
	vcd.SetCert(received_cert_);
	vcd.exec();
}

void ForgedCertDialog::StoredCert()
{
	ViewCertDialog vcd;
	vcd.SetCert(stored_cert_);
	vcd.exec();
}