VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.cpp

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: UIApplianceUnverifiedCertificateViewer.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class implementation.
4 */
5
6/*
7 * Copyright (C) 2009-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QLabel>
30#include <QPushButton>
31#include <QTextBrowser>
32#include <QVBoxLayout>
33
34/* GUI includes: */
35#include "QIDialogButtonBox.h"
36#include "UIApplianceUnverifiedCertificateViewer.h"
37#include "UITranslationEventListener.h"
38
39/* COM includes: */
40#include "CCertificate.h"
41
42
43UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent,
44 const CCertificate &comCertificate)
45 : QIDialog(pParent)
46 , m_comCertificate(comCertificate)
47 , m_pTextLabel(0)
48 , m_pTextBrowser(0)
49{
50 prepare();
51}
52
53void UIApplianceUnverifiedCertificateViewer::prepare()
54{
55 /* Create layout: */
56 QVBoxLayout *pLayout = new QVBoxLayout(this);
57 if (pLayout)
58 {
59 /* Create text-label: */
60 m_pTextLabel = new QLabel;
61 if (m_pTextLabel)
62 {
63 m_pTextLabel->setWordWrap(true);
64
65 /* Add into layout: */
66 pLayout->addWidget(m_pTextLabel);
67 }
68
69 /* Create text-browser: */
70 m_pTextBrowser = new QTextBrowser;
71 if (m_pTextBrowser)
72 {
73 m_pTextBrowser->setMinimumSize(500, 300);
74
75 /* Add into layout: */
76 pLayout->addWidget(m_pTextBrowser);
77 }
78
79 /* Create button-box: */
80 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
81 if (pButtonBox)
82 {
83 pButtonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
84 pButtonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Enter);
85 //pButtonBox->button(QDialogButtonBox::No)->setShortcut(Qt::Key_Esc);
86 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIApplianceUnverifiedCertificateViewer::accept);
87 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIApplianceUnverifiedCertificateViewer::reject);
88
89 /* Add into layout: */
90 pLayout->addWidget(pButtonBox);
91 }
92 }
93
94 /* Translate UI: */
95 sltRetranslateUI();
96 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
97 this, &UIApplianceUnverifiedCertificateViewer::sltRetranslateUI);
98}
99
100void UIApplianceUnverifiedCertificateViewer::sltRetranslateUI()
101{
102 /* Translate dialog title: */
103 setWindowTitle(tr("Unverifiable Certificate! Continue?"));
104
105 /* Translate text-label caption: */
106 if (m_comCertificate.GetSelfSigned())
107 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified self signed certificate issued by '%1'. "
108 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
109 ).arg(m_comCertificate.GetFriendlyName()));
110 else
111 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified certificate issued to '%1'. "
112 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
113 ).arg(m_comCertificate.GetFriendlyName()));
114
115 /* Translate text-browser contents: */
116 const QString strTemplateRow = tr("<tr><td>%1:</td><td>%2</td></tr>", "key: value");
117 QString strTableContent;
118 strTableContent += strTemplateRow.arg(tr("Issuer"), QStringList(m_comCertificate.GetIssuerName().toList()).join(", "));
119 strTableContent += strTemplateRow.arg(tr("Subject"), QStringList(m_comCertificate.GetSubjectName().toList()).join(", "));
120 strTableContent += strTemplateRow.arg(tr("Not Valid Before"), m_comCertificate.GetValidityPeriodNotBefore());
121 strTableContent += strTemplateRow.arg(tr("Not Valid After"), m_comCertificate.GetValidityPeriodNotAfter());
122 strTableContent += strTemplateRow.arg(tr("Serial Number"), m_comCertificate.GetSerialNumber());
123 strTableContent += strTemplateRow.arg(tr("Self-Signed"), m_comCertificate.GetSelfSigned() ? tr("True") : tr("False"));
124 strTableContent += strTemplateRow.arg(tr("Authority (CA)"), m_comCertificate.GetCertificateAuthority() ? tr("True") : tr("False"));
125// strTableContent += strTemplateRow.arg(tr("Trusted"), m_comCertificate.GetTrusted() ? tr("True") : tr("False"));
126 strTableContent += strTemplateRow.arg(tr("Public Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetPublicKeyAlgorithm()).arg(m_comCertificate.GetPublicKeyAlgorithmOID()));
127 strTableContent += strTemplateRow.arg(tr("Signature Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetSignatureAlgorithmName()).arg(m_comCertificate.GetSignatureAlgorithmOID()));
128 strTableContent += strTemplateRow.arg(tr("X.509 Version Number"), QString::number(m_comCertificate.GetVersionNumber()));
129 m_pTextBrowser->setText(QString("<table>%1</table>").arg(strTableContent));
130}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette