Changeset 78110 in vbox
- Timestamp:
- Apr 11, 2019 1:32:48 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r77901 r78110 684 684 src/wizards/exportappliance/UIWizardExportAppPageBasic3.h \ 685 685 src/wizards/exportappliance/UIWizardExportAppPageExpert.h \ 686 src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.h \ 686 687 src/wizards/importappliance/UIWizardImportApp.h \ 687 688 src/wizards/importappliance/UIWizardImportAppPageBasic1.h \ … … 1111 1112 src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp \ 1112 1113 src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp \ 1114 src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.cpp \ 1113 1115 src/wizards/importappliance/UIWizardImportApp.cpp \ 1114 1116 src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.cpp
r78109 r78110 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI WizardImportAppPageBasic2class implementation.3 * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class implementation. 4 4 */ 5 5 … … 18 18 /* Qt includes: */ 19 19 #include <QLabel> 20 #include <QPointer>21 20 #include <QPushButton> 22 21 #include <QTextBrowser> … … 25 24 /* GUI includes: */ 26 25 #include "QIDialogButtonBox.h" 27 #include "QIRichTextLabel.h" 28 #include "UIWizardImportApp.h" 29 #include "UIWizardImportAppPageBasic2.h" 26 #include "UIApplianceUnverifiedCertificateViewer.h" 30 27 31 28 /* COM includes: */ 32 #include "C Appliance.h"29 #include "COMEnums.h" 33 30 #include "CCertificate.h" 34 31 35 32 36 /********************************************************************************************************************************* 37 * Class UIWizardImportAppPage2 implementation. * 38 *********************************************************************************************************************************/ 39 40 UIWizardImportAppPage2::UIWizardImportAppPage2() 41 { 42 } 43 44 45 /********************************************************************************************************************************* 46 * Class UIWizardImportAppPageBasic2 implementation. * 47 *********************************************************************************************************************************/ 48 49 UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName) 50 : m_enmCertText(kCertText_Uninitialized) 51 { 52 /* Create main layout: */ 53 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 54 if (pMainLayout) 55 { 56 /* Create label: */ 57 m_pLabel = new QIRichTextLabel(this); 58 if (m_pLabel) 59 { 60 /* Add into layout: */ 61 pMainLayout->addWidget(m_pLabel); 62 } 63 64 /* Create appliance widget: */ 65 m_pApplianceWidget = new UIApplianceImportEditorWidget(this); 66 { 67 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); 68 m_pApplianceWidget->setFile(strFileName); 69 70 /* Add into layout: */ 71 pMainLayout->addWidget(m_pApplianceWidget); 72 } 73 74 /* Create certificate label: */ 75 m_pCertLabel = new QLabel("<cert label>", this); 76 if (m_pCertLabel) 77 { 78 /* Add into layout: */ 79 pMainLayout->addWidget(m_pCertLabel); 80 } 81 } 82 83 /* Register classes: */ 84 qRegisterMetaType<ImportAppliancePointer>(); 85 /* Register fields: */ 86 registerField("applianceWidget", this, "applianceWidget"); 87 } 88 89 void UIWizardImportAppPageBasic2::retranslateUi() 90 { 91 /* Translate page: */ 92 setTitle(UIWizardImportApp::tr("Appliance settings")); 93 94 /* Translate widgets: */ 95 m_pLabel->setText(UIWizardImportApp::tr("These are the virtual machines contained in the appliance " 96 "and the suggested settings of the imported VirtualBox machines. " 97 "You can change many of the properties shown by double-clicking " 98 "on the items and disable others using the check boxes below.")); 99 switch (m_enmCertText) 100 { 101 case kCertText_Unsigned: 102 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance is not signed")); 103 break; 104 case kCertText_IssuedTrusted: 105 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(m_strSignedBy)); 106 break; 107 case kCertText_IssuedExpired: 108 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(m_strSignedBy)); 109 break; 110 case kCertText_IssuedUnverified: 111 m_pCertLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(m_strSignedBy)); 112 break; 113 case kCertText_SelfSignedTrusted: 114 m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(m_strSignedBy)); 115 break; 116 case kCertText_SelfSignedExpired: 117 m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(m_strSignedBy)); 118 break; 119 case kCertText_SelfSignedUnverified: 120 m_pCertLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(m_strSignedBy)); 121 break; 122 default: 123 AssertFailed(); 124 RT_FALL_THRU(); 125 case kCertText_Uninitialized: 126 m_pCertLabel->setText("<uninitialized page>"); 127 break; 128 } 129 } 130 131 void UIWizardImportAppPageBasic2::initializePage() 132 { 133 /* Acquire appliance: */ 134 CAppliance *pAppliance = m_pApplianceWidget->appliance(); 135 136 /* Check if pAppliance is alive. If not just return here. 137 * This prevents crashes when an invalid ova file is supllied: */ 138 if (!pAppliance) 139 { 140 if (wizard()) 141 wizard()->reject(); 142 return; 143 } 144 145 /* Acquire certificate: */ 146 CCertificate comCertificate = pAppliance->GetCertificate(); 147 if (comCertificate.isNull()) 148 m_enmCertText = kCertText_Unsigned; 149 else 150 { 151 /* Pick a 'signed-by' name: */ 152 m_strSignedBy = comCertificate.GetFriendlyName(); 153 154 /* If trusted, just select the right message: */ 155 if (comCertificate.GetTrusted()) 156 { 157 if (comCertificate.GetSelfSigned()) 158 m_enmCertText = !comCertificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired; 159 else 160 m_enmCertText = !comCertificate.GetExpired() ? kCertText_IssuedTrusted : kCertText_IssuedExpired; 161 } 162 else 163 { 164 /* Not trusted! Must ask the user whether to continue in this case: */ 165 m_enmCertText = comCertificate.GetSelfSigned() ? kCertText_SelfSignedUnverified : kCertText_IssuedUnverified; 166 167 /* Translate page early: */ 168 retranslateUi(); 169 170 /* Instantiate the dialog: */ 171 QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, comCertificate); 172 AssertPtrReturnVoid(pDialog.data()); 173 174 /* Show viewer in modal mode: */ 175 const int iResultCode = pDialog->exec(); 176 177 /* Leave if viewer destroyed prematurely: */ 178 if (!pDialog) 179 return; 180 /* Delete viewer finally: */ 181 delete pDialog; 182 183 /* Dismiss the entire import-appliance wizard if user rejects certificate: */ 184 if (iResultCode == QDialog::Rejected) 185 wizard()->reject(); 186 } 187 } 188 189 /* Translate page: */ 190 retranslateUi(); 191 } 192 193 void UIWizardImportAppPageBasic2::cleanupPage() 194 { 195 /* Rollback settings: */ 196 m_pApplianceWidget->restoreDefaults(); 197 /* Call to base-class: */ 198 UIWizardPage::cleanupPage(); 199 } 200 201 bool UIWizardImportAppPageBasic2::validatePage() 202 { 203 /* Initial result: */ 204 bool fResult = true; 205 206 /* Lock finish button: */ 207 startProcessing(); 208 209 /* Try to import appliance: */ 210 if (fResult) 211 fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance(); 212 213 /* Unlock finish button: */ 214 endProcessing(); 215 216 /* Return result: */ 217 return fResult; 218 } 219 220 221 /********************************************************************************************************************************* 222 * Class UIApplianceUnverifiedCertificateViewer implementation. * 223 *********************************************************************************************************************************/ 224 225 UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate) 33 UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent, 34 const CCertificate &comCertificate) 226 35 : QIWithRetranslateUI<QIDialog>(pParent) 227 36 , m_comCertificate(comCertificate) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.h
r78109 r78110 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI WizardImportAppPageBasic2class declaration.3 * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_wizards_importappliance_UI WizardImportAppPageBasic2_h19 #define FEQT_INCLUDED_SRC_wizards_importappliance_UI WizardImportAppPageBasic2_h18 #ifndef FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h 19 #define FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 25 25 #include "QIDialog.h" 26 26 #include "QIWithRetranslateUI.h" 27 #include "UIWizardImportAppDefs.h"28 #include "UIWizardPage.h"29 27 30 28 /* Forward declarations: */ 31 29 class QLabel; 32 30 class QTextBrowser; 33 class QDialogButtonBox;34 class QIRichTextLabel;35 31 class CCertificate; 36 37 /** UIWizardPageBase extension for 2nd page of the Import Appliance wizard. */38 class UIWizardImportAppPage2 : public UIWizardPageBase39 {40 protected:41 42 /** Constructs 2nd page base. */43 UIWizardImportAppPage2();44 45 /** Returns appliance widget instance. */46 ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }47 48 /** Holds the appliance widget instance. */49 ImportAppliancePointer m_pApplianceWidget;50 };51 52 /** UIWizardPage extension for 2nd page of the Import Appliance wizard, extends UIWizardImportAppPage2 as well. */53 class UIWizardImportAppPageBasic2 : public UIWizardPage, public UIWizardImportAppPage254 {55 Q_OBJECT;56 Q_PROPERTY(ImportAppliancePointer applianceWidget READ applianceWidget);57 58 public:59 60 /** Constructs 2nd basic page.61 * @param strFileName Brings appliance file name. */62 UIWizardImportAppPageBasic2(const QString &strFileName);63 64 private:65 66 /** Handles translation event. */67 virtual void retranslateUi() /* override */;68 69 /** Performs page initialization. */70 virtual void initializePage() /* override */;71 /** Performs page cleanup. */72 virtual void cleanupPage() /* override */;73 74 /** Performs page validation. */75 virtual bool validatePage() /* override */;76 77 /** Holds the label instance. */78 QIRichTextLabel *m_pLabel;79 80 /** Holds the signature/certificate info label instance. */81 QLabel *m_pCertLabel;82 83 /** Holds the certificate text template type. */84 enum {85 kCertText_Uninitialized = 0, kCertText_Unsigned,86 kCertText_IssuedTrusted, kCertText_IssuedExpired, kCertText_IssuedUnverified,87 kCertText_SelfSignedTrusted, kCertText_SelfSignedExpired, kCertText_SelfSignedUnverified88 } m_enmCertText;89 90 /** Holds the "signed by" information. */91 QString m_strSignedBy;92 };93 32 94 33 /** QIDialog extension … … 100 39 public: 101 40 102 /** Constructs appliance @a c ertificate viewer for passed @a pParent. */41 /** Constructs appliance @a comCertificate viewer for passed @a pParent. */ 103 42 UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate); 104 43 … … 122 61 }; 123 62 124 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UI WizardImportAppPageBasic2_h */63 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp
r78037 r78110 19 19 #include <QLabel> 20 20 #include <QPointer> 21 #include <QPushButton>22 #include <QTextBrowser>23 21 #include <QVBoxLayout> 24 22 25 23 /* GUI includes: */ 26 #include "QIDialogButtonBox.h"27 24 #include "QIRichTextLabel.h" 25 #include "UIApplianceUnverifiedCertificateViewer.h" 28 26 #include "UIWizardImportApp.h" 29 27 #include "UIWizardImportAppPageBasic2.h" … … 217 215 return fResult; 218 216 } 219 220 221 /*********************************************************************************************************************************222 * Class UIApplianceUnverifiedCertificateViewer implementation. *223 *********************************************************************************************************************************/224 225 UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate)226 : QIWithRetranslateUI<QIDialog>(pParent)227 , m_comCertificate(comCertificate)228 , m_pTextLabel(0)229 , m_pTextBrowser(0)230 {231 prepare();232 }233 234 void UIApplianceUnverifiedCertificateViewer::prepare()235 {236 /* Create layout: */237 QVBoxLayout *pLayout = new QVBoxLayout(this);238 if (pLayout)239 {240 /* Create text-label: */241 m_pTextLabel = new QLabel;242 if (m_pTextLabel)243 {244 m_pTextLabel->setWordWrap(true);245 246 /* Add into layout: */247 pLayout->addWidget(m_pTextLabel);248 }249 250 /* Create text-browser: */251 m_pTextBrowser = new QTextBrowser;252 if (m_pTextBrowser)253 {254 m_pTextBrowser->setMinimumSize(500, 300);255 256 /* Add into layout: */257 pLayout->addWidget(m_pTextBrowser);258 }259 260 /* Create button-box: */261 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;262 if (pButtonBox)263 {264 pButtonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);265 pButtonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Enter);266 //pButtonBox->button(QDialogButtonBox::No)->setShortcut(Qt::Key_Esc);267 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIApplianceUnverifiedCertificateViewer::accept);268 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIApplianceUnverifiedCertificateViewer::reject);269 270 /* Add into layout: */271 pLayout->addWidget(pButtonBox);272 }273 }274 275 /* Translate UI: */276 retranslateUi();277 }278 279 void UIApplianceUnverifiedCertificateViewer::retranslateUi()280 {281 /* Translate dialog title: */282 setWindowTitle(tr("Unverifiable Certificate! Continue?"));283 284 /* Translate text-label caption: */285 if (m_comCertificate.GetSelfSigned())286 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified self signed certificate issued by '%1'. "287 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"288 ).arg(m_comCertificate.GetFriendlyName()));289 else290 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified certificate issued to '%1'. "291 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"292 ).arg(m_comCertificate.GetFriendlyName()));293 294 /* Translate text-browser contents: */295 const QString strTemplateRow = tr("<tr><td>%1:</td><td>%2</td></tr>", "key: value");296 QString strTableContent;297 strTableContent += strTemplateRow.arg(tr("Issuer"), QStringList(m_comCertificate.GetIssuerName().toList()).join(", "));298 strTableContent += strTemplateRow.arg(tr("Subject"), QStringList(m_comCertificate.GetSubjectName().toList()).join(", "));299 strTableContent += strTemplateRow.arg(tr("Not Valid Before"), m_comCertificate.GetValidityPeriodNotBefore());300 strTableContent += strTemplateRow.arg(tr("Not Valid After"), m_comCertificate.GetValidityPeriodNotAfter());301 strTableContent += strTemplateRow.arg(tr("Serial Number"), m_comCertificate.GetSerialNumber());302 strTableContent += strTemplateRow.arg(tr("Self-Signed"), m_comCertificate.GetSelfSigned() ? tr("True") : tr("False"));303 strTableContent += strTemplateRow.arg(tr("Authority (CA)"), m_comCertificate.GetCertificateAuthority() ? tr("True") : tr("False"));304 // strTableContent += strTemplateRow.arg(tr("Trusted"), m_comCertificate.GetTrusted() ? tr("True") : tr("False"));305 strTableContent += strTemplateRow.arg(tr("Public Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetPublicKeyAlgorithm()).arg(m_comCertificate.GetPublicKeyAlgorithmOID()));306 strTableContent += strTemplateRow.arg(tr("Signature Algorithm"), tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetSignatureAlgorithmName()).arg(m_comCertificate.GetSignatureAlgorithmOID()));307 strTableContent += strTemplateRow.arg(tr("X.509 Version Number"), QString::number(m_comCertificate.GetVersionNumber()));308 m_pTextBrowser->setText(QString("<table>%1</table>").arg(strTableContent));309 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h
r78037 r78110 23 23 24 24 /* GUI includes: */ 25 #include "QIDialog.h"26 #include "QIWithRetranslateUI.h"27 25 #include "UIWizardImportAppDefs.h" 28 26 #include "UIWizardPage.h" … … 30 28 /* Forward declarations: */ 31 29 class QLabel; 32 class QTextBrowser;33 class QDialogButtonBox;34 30 class QIRichTextLabel; 35 class CCertificate;36 31 37 32 /** UIWizardPageBase extension for 2nd page of the Import Appliance wizard. */ … … 92 87 }; 93 88 94 /** QIDialog extension95 * asking for consent to continue with unverifiable certificate. */96 class UIApplianceUnverifiedCertificateViewer : public QIWithRetranslateUI<QIDialog>97 {98 Q_OBJECT;99 100 public:101 102 /** Constructs appliance @a certificate viewer for passed @a pParent. */103 UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate);104 105 protected:106 107 /** Prepares all. */108 void prepare();109 110 /** Handles translation event. */111 virtual void retranslateUi() /* override */;112 113 private:114 115 /** Holds the certificate reference. */116 const CCertificate &m_comCertificate;117 118 /** Holds the text-label instance. */119 QLabel *m_pTextLabel;120 /** Holds the text-browser instance. */121 QTextBrowser *m_pTextBrowser;122 };123 124 89 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppPageBasic2_h */
Note:
See TracChangeset
for help on using the changeset viewer.