VirtualBox

Changeset 60276 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 31, 2016 4:21:19 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106317
Message:

FE/Qt: bugref:8249: Initial certificate information viewer implementation based on r106255, used only for guided wizard mode for now.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp

    r60221 r60276  
    55
    66/*
    7  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424# include <QTextBrowser>
    2525# include <QPushButton>
     26# include <QPointer>
    2627
    2728/* Local includes: */
     
    3839
    3940
     41/*********************************************************************************************************************************
     42*   Class UIApplianceCertificateViewer implementation.                                                                           *
     43*********************************************************************************************************************************/
     44
     45UIApplianceCertificateViewer::UIApplianceCertificateViewer(QWidget *pParent, const CCertificate &certificate)
     46    : QIWithRetranslateUI<QIDialog>(pParent)
     47    , m_certificate(certificate)
     48    , m_pTextLabel(0)
     49    , m_pTextBrowser(0)
     50{
     51    /* Prepare: */
     52    prepare();
     53}
     54
     55void UIApplianceCertificateViewer::prepare()
     56{
     57    /* Create layout: */
     58    QVBoxLayout *pLayout = new QVBoxLayout(this);
     59    AssertPtrReturnVoid(pLayout);
     60    {
     61        /* Create text-label: */
     62        m_pTextLabel = new QLabel;
     63        AssertPtrReturnVoid(m_pTextLabel);
     64        {
     65            /* Configure text-label: */
     66            m_pTextLabel->setWordWrap(true);
     67            /* Add text-label into layout: */
     68            pLayout->addWidget(m_pTextLabel);
     69        }
     70        /* Create text-browser: */
     71        m_pTextBrowser = new QTextBrowser;
     72        AssertPtrReturnVoid(m_pTextBrowser);
     73        {
     74            /* Configure text-browser: */
     75            m_pTextBrowser->setMinimumSize(500, 300);
     76            /* Add text-browser into layout: */
     77            pLayout->addWidget(m_pTextBrowser);
     78        }
     79        /* Create button-box: */
     80        QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
     81        AssertPtrReturnVoid(pButtonBox);
     82        {
     83            /* Configure button-box: */
     84            pButtonBox->setStandardButtons(QDialogButtonBox::Ok);
     85            pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Enter);
     86            connect(pButtonBox, SIGNAL(accepted()), this, SLOT(close()));
     87            /* Add button-box into layout: */
     88            pLayout->addWidget(pButtonBox);
     89        }
     90    }
     91    /* Translate UI: */
     92    retranslateUi();
     93}
     94
     95void UIApplianceCertificateViewer::retranslateUi()
     96{
     97    /* Translate dialog title: */
     98    setWindowTitle(tr("Certificate Information"));
     99    /* Translate text-label caption: */
     100    m_pTextLabel->setText(tr("<b>The X509 certificate exists but hasn't been verified or trusted. "
     101                             "You can proceed with the importing but should understand the risks. "
     102                             "If you are not sure - just stop here and interrupt the importing process.</b>"));
     103    /* Translate text-browser contents: */
     104    QStringList info;
     105    info << tr("Certificate Version Number: %1").arg(m_certificate.GetVersionNumber());
     106    info << tr("Certificate Serial Number: 0x%1").arg(m_certificate.GetSerialNumber());
     107    info << tr("Certificate Authority (CA): %1").arg(m_certificate.GetCertificateAuthority() ? tr("True") : tr("False"));
     108    info << tr("Certificate Self-Signed: %1").arg(m_certificate.GetSelfSigned() ? tr("True") : tr("False"));
     109    info << tr("Certificate Trusted: %1").arg(m_certificate.GetTrusted() ? tr("True") : tr("False"));
     110    info << tr("Certificate Issuer: %1").arg(QStringList(m_certificate.GetIssuerName().toList()).join(", "));
     111    info << tr("Certificate Subject: %1").arg(QStringList(m_certificate.GetSubjectName().toList()).join(", "));
     112    info << tr("Certificate Public Algorithm: %1").arg(m_certificate.GetPublicKeyAlgorithm());
     113    info << tr("Certificate Signature Algorithm: %1").arg(m_certificate.GetSignatureAlgorithmName());
     114    info << tr("Certificate Signature Algorithm OID: %1").arg(m_certificate.GetSignatureAlgorithmOID());
     115    info << tr("Certificate Validity Period Not Before: %1").arg(m_certificate.GetValidityPeriodNotBefore());
     116    info << tr("Certificate Validity Period Not After: %1").arg(m_certificate.GetValidityPeriodNotAfter());
     117    m_pTextBrowser->setText(info.join("<br><br>"));
     118}
     119
     120
     121/*********************************************************************************************************************************
     122*   Class UIWizardImportAppPage2 implementation.                                                                                 *
     123*********************************************************************************************************************************/
     124
    40125UIWizardImportAppPage2::UIWizardImportAppPage2()
    41126{
    42127}
     128
     129
     130/*********************************************************************************************************************************
     131*   Class UIWizardImportAppPageBasic2 implementation.                                                                            *
     132*********************************************************************************************************************************/
    43133
    44134UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName)
     
    79169    /* Translate page: */
    80170    retranslateUi();
    81     /* Create dialog: */
    82     QDialog *pDialog = new QDialog(this, Qt::Dialog);
    83     AssertPtrReturnVoid(pDialog);
    84 
    85     CAppliance* l_appl = m_pApplianceWidget->appliance();
    86     CCertificate aCertificateInfo = l_appl->GetCertificate();
    87     /* check emptyness of certificate. object exists but hasn't fullfilled */
    88     BOOL fExisting = false;
    89     BOOL fVerified = false;
    90     fExisting = aCertificateInfo.CheckExistence();
    91     fVerified = aCertificateInfo.IsVerified();
    92     if (fExisting && !fVerified)
     171
     172    /* Acquire appliance and certificate: */
     173    CAppliance *pAppliance = m_pApplianceWidget->appliance();
     174    CCertificate certificate = pAppliance->GetCertificate();
     175    /* Check whether certificate exists and verified: */
     176    if (certificate.CheckExistence() && !certificate.IsVerified())
    93177    {
    94         /* Create layout: */
    95         QVBoxLayout *pLayout = new QVBoxLayout(pDialog);
    96         AssertPtrReturnVoid(pLayout);
    97         {
    98             /* Prepare dialog: */
    99             pDialog->resize(500, 500);
    100             /* Create text-field: */
    101             QTextBrowser *pTextBrowser = new QTextBrowser;
    102             AssertPtrReturnVoid(pTextBrowser);
    103 
    104             QString fullCertInfo("");
    105 
    106             {
    107                 /* Configure text-field: */
    108                 // TODO: Load text to text-browser here:
    109                 QString data = aCertificateInfo.GetVersionNumber();
    110                 fullCertInfo.append("Certificate version number: ").append(data).append("\n\n");
    111 
    112                 data = aCertificateInfo.GetSerialNumber();
    113                 fullCertInfo.append("Certificate serial number: 0x").append(data).append("\n\n");
    114 
    115                 bool flag = aCertificateInfo.GetCertificateAuthority();
    116                 data = (flag == true) ? "True":"False";
    117                 fullCertInfo.append("Certificate Authority (CA): ").append(data).append("\n\n");
    118 
    119                 flag = aCertificateInfo.GetSelfSigned();
    120                 data = (flag == true) ? "True":"False";
    121                 fullCertInfo.append("Certificate Self-Signed : ").append(data).append("\n\n");
    122 
    123                 flag = aCertificateInfo.GetTrusted();
    124                 data = (flag == true) ? "True":"False";
    125                 fullCertInfo.append("Certificate Trusted: ").append(data).append("\n\n");
    126 
    127                 QVector<QString> name = aCertificateInfo.GetIssuerName();
    128                 fullCertInfo.append("Certificate Issuer: ").append("\n");
    129                 if (!name.isEmpty())
    130                 {
    131                     for (int i = 0; i < name.size()-1; ++i)
    132                     {
    133                         fullCertInfo.append(name.at(i)).append(", ");
    134                     }
    135 
    136                     QString field = name.at(name.size()-1);
    137                     fullCertInfo.append(field).append("\n\n");
    138                 }
    139                 name.clear();
    140                 name = aCertificateInfo.GetSubjectName();
    141                 fullCertInfo.append("Certificate Subject: ").append("\n");
    142                 if (!name.isEmpty())
    143                 {
    144                     for (int i = 0; i < name.size()-1; ++i)
    145                     {
    146                         fullCertInfo.append(name.at(i)).append(", ");
    147                     }
    148 
    149                     QString field = name.at(name.size()-1);
    150                     fullCertInfo.append(field).append("\n\n");
    151                 }
    152 
    153                 data = aCertificateInfo.GetPublicKeyAlgorithm();
    154                 fullCertInfo.append("Certificate Public Algorithm: ").append(data).append("\n\n");
    155 
    156                 data = aCertificateInfo.GetSignatureAlgorithmName();
    157                 fullCertInfo.append("Certificate Signature Algorithm: ").append(data).append("\n\n");
    158 
    159                 data = aCertificateInfo.GetSignatureAlgorithmOID();
    160                 fullCertInfo.append("Certificate Signature Algorithm OID: ").append(data).append("\n\n");
    161 
    162                 data = aCertificateInfo.GetValidityPeriodNotBefore();
    163                 fullCertInfo.append("Certificate Validity Period Not Before: ").append(data).append("\n\n");
    164 
    165                 data = aCertificateInfo.GetValidityPeriodNotAfter();
    166                 fullCertInfo.append("Certificate Validity Period Not After: ").append(data).append("\n\n");
    167 
    168                 pTextBrowser->setText(fullCertInfo);
    169                 /* Add text-browser into layout: */
    170                 pLayout->addWidget(pTextBrowser);
    171             }
    172             /* Create button-box: */
    173             QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
    174             AssertPtrReturnVoid(pButtonBox);
    175             {
    176                 /* Configure button-box: */
    177                 pButtonBox->setStandardButtons(QDialogButtonBox::Ok);
    178                 pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Enter);
    179                 connect(pButtonBox, SIGNAL(accepted()), pDialog, SLOT(close()));
    180                 /* Add button-box into layout: */
    181                 pLayout->addWidget(pButtonBox);
    182             }
    183         }
    184         /* Show dialog in modal mode: */
    185         pDialog->exec();
    186         /* Delete dialog finally: */
    187         delete pDialog;
    188         pDialog = 0;
     178        /* Create certificate viewer to notify user about it is not verified: */
     179        QPointer<UIApplianceCertificateViewer> pDialog =
     180            new UIApplianceCertificateViewer(this, certificate);
     181        AssertPtrReturnVoid(pDialog.data());
     182        {
     183            /* Show viewer in modal mode: */
     184            pDialog->exec();
     185            /* Leave if destroyed prematurely: */
     186            if (!pDialog)
     187                return;
     188            /* Delete viewer finally: */
     189            delete pDialog;
     190            pDialog = 0;
     191        }
    189192    }
    190193}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h

    r55401 r60276  
    55
    66/*
    7  * Copyright (C) 2009-2012 Oracle Corporation
     7 * Copyright (C) 2009-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#define __UIWizardImportAppPageBasic2_h__
    2020
    21 /* Local includes: */
     21/* GUI includes: */
     22#include "QIDialog.h"
     23#include "QIWithRetranslateUI.h"
    2224#include "UIWizardPage.h"
    2325#include "UIWizardImportAppDefs.h"
    2426
    2527/* Forward declarations: */
     28class QLabel;
     29class QTextBrowser;
    2630class QDialogButtonBox;
    2731class QIRichTextLabel;
     32class CCertificate;
     33
     34
     35/** QIDialog extension providing user with the information
     36  * about the appliance certificate which validation failed. */
     37class UIApplianceCertificateViewer : public QIWithRetranslateUI<QIDialog>
     38{
     39    Q_OBJECT;
     40
     41public:
     42
     43    /** Constructs appliance @a certificate viewer for passed @a pParent. */
     44    UIApplianceCertificateViewer(QWidget *pParent, const CCertificate &certificate);
     45
     46protected:
     47
     48    /** Prepares all. */
     49    void prepare();
     50
     51    /** Handles translation event. */
     52    virtual void retranslateUi() /* override */;
     53
     54private:
     55
     56    /** Holds the certificate reference. */
     57    const CCertificate &m_certificate;
     58
     59    /** Holds the text-label instance. */
     60    QLabel *m_pTextLabel;
     61    /** Holds the text-browser instance. */
     62    QTextBrowser *m_pTextBrowser;
     63};
     64
    2865
    2966/* 2nd page of the Import Appliance wizard (base part): */
Note: See TracChangeset for help on using the changeset viewer.

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