VirtualBox

Ignore:
Timestamp:
Mar 28, 2016 1:45:41 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106255
Message:

bugref:8249. Example of usage ICertificate interface during OVF import.

File:
1 edited

Legend:

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

    r52730 r60221  
    2222/* Global includes: */
    2323# include <QVBoxLayout>
     24# include <QTextBrowser>
     25# include <QPushButton>
    2426
    2527/* Local includes: */
     
    2729# include "UIWizardImportApp.h"
    2830# include "QIRichTextLabel.h"
     31# include "QIDialogButtonBox.h"
     32
     33/* COM includes: */
     34# include "CAppliance.h"
     35# include "CCertificate.h"
    2936
    3037#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    7279    /* Translate page: */
    7380    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)
     93    {
     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;
     189    }
    74190}
    75191
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