1 | /* $Id: UIApplianceUnverifiedCertificateViewer.cpp 78110 2019-04-11 13:32:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* Qt includes: */
|
---|
19 | #include <QLabel>
|
---|
20 | #include <QPushButton>
|
---|
21 | #include <QTextBrowser>
|
---|
22 | #include <QVBoxLayout>
|
---|
23 |
|
---|
24 | /* GUI includes: */
|
---|
25 | #include "QIDialogButtonBox.h"
|
---|
26 | #include "UIApplianceUnverifiedCertificateViewer.h"
|
---|
27 |
|
---|
28 | /* COM includes: */
|
---|
29 | #include "COMEnums.h"
|
---|
30 | #include "CCertificate.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent,
|
---|
34 | const CCertificate &comCertificate)
|
---|
35 | : QIWithRetranslateUI<QIDialog>(pParent)
|
---|
36 | , m_comCertificate(comCertificate)
|
---|
37 | , m_pTextLabel(0)
|
---|
38 | , m_pTextBrowser(0)
|
---|
39 | {
|
---|
40 | prepare();
|
---|
41 | }
|
---|
42 |
|
---|
43 | void UIApplianceUnverifiedCertificateViewer::prepare()
|
---|
44 | {
|
---|
45 | /* Create layout: */
|
---|
46 | QVBoxLayout *pLayout = new QVBoxLayout(this);
|
---|
47 | if (pLayout)
|
---|
48 | {
|
---|
49 | /* Create text-label: */
|
---|
50 | m_pTextLabel = new QLabel;
|
---|
51 | if (m_pTextLabel)
|
---|
52 | {
|
---|
53 | m_pTextLabel->setWordWrap(true);
|
---|
54 |
|
---|
55 | /* Add into layout: */
|
---|
56 | pLayout->addWidget(m_pTextLabel);
|
---|
57 | }
|
---|
58 |
|
---|
59 | /* Create text-browser: */
|
---|
60 | m_pTextBrowser = new QTextBrowser;
|
---|
61 | if (m_pTextBrowser)
|
---|
62 | {
|
---|
63 | m_pTextBrowser->setMinimumSize(500, 300);
|
---|
64 |
|
---|
65 | /* Add into layout: */
|
---|
66 | pLayout->addWidget(m_pTextBrowser);
|
---|
67 | }
|
---|
68 |
|
---|
69 | /* Create button-box: */
|
---|
70 | QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
|
---|
71 | if (pButtonBox)
|
---|
72 | {
|
---|
73 | pButtonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
|
---|
74 | pButtonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Enter);
|
---|
75 | //pButtonBox->button(QDialogButtonBox::No)->setShortcut(Qt::Key_Esc);
|
---|
76 | connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIApplianceUnverifiedCertificateViewer::accept);
|
---|
77 | connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIApplianceUnverifiedCertificateViewer::reject);
|
---|
78 |
|
---|
79 | /* Add into layout: */
|
---|
80 | pLayout->addWidget(pButtonBox);
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | /* Translate UI: */
|
---|
85 | retranslateUi();
|
---|
86 | }
|
---|
87 |
|
---|
88 | void UIApplianceUnverifiedCertificateViewer::retranslateUi()
|
---|
89 | {
|
---|
90 | /* Translate dialog title: */
|
---|
91 | setWindowTitle(tr("Unverifiable Certificate! Continue?"));
|
---|
92 |
|
---|
93 | /* Translate text-label caption: */
|
---|
94 | if (m_comCertificate.GetSelfSigned())
|
---|
95 | m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified self signed certificate issued by '%1'. "
|
---|
96 | "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
|
---|
97 | ).arg(m_comCertificate.GetFriendlyName()));
|
---|
98 | else
|
---|
99 | m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified certificate issued to '%1'. "
|
---|
100 | "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
|
---|
101 | ).arg(m_comCertificate.GetFriendlyName()));
|
---|
102 |
|
---|
103 | /* Translate text-browser contents: */
|
---|
104 | const QString strTemplateRow = tr("<tr><td>%1:</td><td>%2</td></tr>", "key: value");
|
---|
105 | QString strTableContent;
|
---|
106 | strTableContent += strTemplateRow.arg(tr("Issuer"), QStringList(m_comCertificate.GetIssuerName().toList()).join(", "));
|
---|
107 | strTableContent += strTemplateRow.arg(tr("Subject"), QStringList(m_comCertificate.GetSubjectName().toList()).join(", "));
|
---|
108 | strTableContent += strTemplateRow.arg(tr("Not Valid Before"), m_comCertificate.GetValidityPeriodNotBefore());
|
---|
109 | strTableContent += strTemplateRow.arg(tr("Not Valid After"), m_comCertificate.GetValidityPeriodNotAfter());
|
---|
110 | strTableContent += strTemplateRow.arg(tr("Serial Number"), m_comCertificate.GetSerialNumber());
|
---|
111 | strTableContent += strTemplateRow.arg(tr("Self-Signed"), m_comCertificate.GetSelfSigned() ? tr("True") : tr("False"));
|
---|
112 | strTableContent += strTemplateRow.arg(tr("Authority (CA)"), m_comCertificate.GetCertificateAuthority() ? tr("True") : tr("False"));
|
---|
113 | // strTableContent += strTemplateRow.arg(tr("Trusted"), m_comCertificate.GetTrusted() ? tr("True") : tr("False"));
|
---|
114 | strTableContent += strTemplateRow.arg(tr("Public Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetPublicKeyAlgorithm()).arg(m_comCertificate.GetPublicKeyAlgorithmOID()));
|
---|
115 | strTableContent += strTemplateRow.arg(tr("Signature Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetSignatureAlgorithmName()).arg(m_comCertificate.GetSignatureAlgorithmOID()));
|
---|
116 | strTableContent += strTemplateRow.arg(tr("X.509 Version Number"), QString::number(m_comCertificate.GetVersionNumber()));
|
---|
117 | m_pTextBrowser->setText(QString("<table>%1</table>").arg(strTableContent));
|
---|
118 | }
|
---|