Commit 3ed119f1 authored by Pawel Polanski's avatar Pawel Polanski
Browse files

'Certificate details' dialog added to SymbianOS

parent 993771f0
......@@ -41,8 +41,10 @@ CertificatePathChooser::CertificatePathChooser(QWidget *parent) :
bool CertificatePathChooser::validatePath(const QString &path, QString *errorMessage)
{
if (Utils::PathChooser::validatePath(path, errorMessage)) {
QScopedPointer<S60CertificateInfo> certInfoPtr(new S60CertificateInfo(path));
if (certInfoPtr.data()->validateCertificate() == S60CertificateInfo::CertificateValid) {
QScopedPointer<Qt4ProjectManager::Internal::S60CertificateInfo>
certInfoPtr(new Qt4ProjectManager::Internal::S60CertificateInfo(path));
if (certInfoPtr.data()->validateCertificate()
== Qt4ProjectManager::Internal::S60CertificateInfo::CertificateValid) {
if (errorMessage)
*errorMessage = certInfoPtr.data()->toHtml();
return true;
......
......@@ -24,7 +24,8 @@ SOURCES += $$PWD/s60devices.cpp \
$$PWD/s60deployconfigurationwidget.cpp \
$$PWD/s60certificateinfo.cpp \
$$PWD/certificatepathchooser.cpp \
$$PWD/s60symbiancertificate.cpp
$$PWD/s60symbiancertificate.cpp \
$$PWD/s60certificatedetailsdialog.cpp
HEADERS += $$PWD/s60devices.h \
$$PWD/s60devicespreferencepane.h \
$$PWD/s60manager.h \
......@@ -48,6 +49,8 @@ HEADERS += $$PWD/s60devices.h \
$$PWD/s60deployconfigurationwidget.h \
$$PWD/s60certificateinfo.h \
$$PWD/certificatepathchooser.h \
$$PWD/s60symbiancertificate.h
$$PWD/s60symbiancertificate.h \
$$PWD/s60certificatedetailsdialog.h
FORMS += $$PWD/s60devicespreferencepane.ui \
$$PWD/s60createpackagestep.ui
$$PWD/s60createpackagestep.ui \
$$PWD/s60certificatedetailsdialog.ui
......@@ -36,6 +36,9 @@
#include "s60symbiancertificate.h"
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
namespace {
const char * const SIMPLE_DATE_FORMAT = "dd.MM.yyyy";
}
......@@ -84,6 +87,13 @@ S60CertificateInfo::S60CertificateInfo(const QString &filePath, QObject* parent)
m_certificate(new S60SymbianCertificate(filePath)),
m_filePath(filePath)
{
m_imeiList = m_certificate->subjectInfo(QLatin1String("1.2.826.0.1.1796587.1.1.1.1"));
const QStringList capabilityList(m_certificate->subjectInfo(QLatin1String("1.2.826.0.1.1796587.1.1.1.6")));
if (capabilityList.isEmpty())
m_capabilities = 0;
else
m_capabilities = capabilityList.at(0).toLong();
}
S60CertificateInfo::~S60CertificateInfo()
......@@ -123,21 +133,29 @@ QString S60CertificateInfo::errorString() const
return m_errorString.isEmpty()?m_certificate->errorString():m_errorString;
}
quint32 S60CertificateInfo::capabilitiesSupported()
QStringList S60CertificateInfo::devicesSupported() const
{
return NoInformation;
return m_imeiList;
}
QString S60CertificateInfo::toHtml()
quint32 S60CertificateInfo::capabilitiesSupported() const
{
const QStringList capabilityList(m_certificate->subjectInfo(QLatin1String("1.2.826.0.1.1796587.1.1.1.6")));
return m_capabilities;
}
bool S60CertificateInfo::isDeveloperCertificate() const
{
return !devicesSupported().isEmpty() || capabilitiesSupported();
}
QString S60CertificateInfo::toHtml(bool keepShort)
{
QString htmlString;
QTextStream str(&htmlString);
str << "<html><body><table>"
<< "<tr><td><b>" << tr("Type: ") << "</b></td>";
if (!capabilityList.isEmpty())
if (isDeveloperCertificate())
str << "<td>" << tr("Developer certificate") << "</td>";
if (m_certificate->isSelfSigned())
str << "<td>" << tr("Self signed certificate") << "</td>";
......@@ -165,21 +183,17 @@ QString S60CertificateInfo::toHtml()
<< "<tr><td><b>" << tr("Valid to: ")
<< "</b></td><td>" << endDate.toString(QLatin1String(SIMPLE_DATE_FORMAT)) << "</td></tr>";
if (!capabilityList.isEmpty()) {
bool isOk(false);
quint32 capabilities = capabilityList.at(0).toLong(&isOk);
if (isOk) {
if (capabilitiesSupported()) {
str << "<tr><td><b>" << tr("Capabilities: ")
<< "</b></td><td>" << createCapabilityList(capabilities).join(" ") << "</td></tr>";
}
<< "</b></td><td>" << createCapabilityList(capabilitiesSupported()).join(" ") << "</td></tr>";
}
const QStringList imeiList(m_certificate->subjectInfo(QLatin1String("1.2.826.0.1.1796587.1.1.1.1")));
const QStringList &imeiList(devicesSupported());
if (!imeiList.isEmpty()) {
QString imeiListString;
QString space(" ");
int MAX_DISPLAYED_IMEI_COUNT = 30;
if (imeiList.count() > MAX_DISPLAYED_IMEI_COUNT) {//1000 items would be too much :)
if (imeiList.count() > MAX_DISPLAYED_IMEI_COUNT && keepShort) {//1000 items would be too much :)
for (int i = 0; i < MAX_DISPLAYED_IMEI_COUNT; ++i)
imeiListString += imeiList.at(i) + space;
imeiListString.replace(imeiListString.length()-1, 1, QString("..."));
......
......@@ -36,6 +36,9 @@
QT_FORWARD_DECLARE_CLASS(QString)
QT_FORWARD_DECLARE_CLASS(S60SymbianCertificate)
namespace Qt4ProjectManager {
namespace Internal {
class S60CertificateInfo : public QObject
{
Q_OBJECT
......@@ -76,14 +79,21 @@ public:
~S60CertificateInfo();
CertificateState validateCertificate();
quint32 capabilitiesSupported();
QString toHtml();
QStringList devicesSupported() const;
quint32 capabilitiesSupported() const;
QString toHtml(bool keepShort = true);
QString errorString() const;
bool isDeveloperCertificate() const;
private:
S60SymbianCertificate *m_certificate;
QString m_filePath;
QString m_errorString;
QStringList m_imeiList;
quint32 m_capabilities;
};
} // namespace Internal
} // namespace Qt4ProjectExplorer
#endif // S60CERTIFICATEINFO_H
......@@ -38,6 +38,7 @@
#include "sbsv2parser.h"
#include "passphraseforkeydialog.h"
#include "s60certificateinfo.h"
#include "s60certificatedetailsdialog.h"
#include <coreplugin/coreconstants.h>
......@@ -784,6 +785,11 @@ S60CreatePackageStepConfigWidget::S60CreatePackageStepConfigWidget(S60CreatePack
m_ui.signaturePath->setPromptDialogFilter(QLatin1String("*.cer *.crt *.der *.pem"));
m_ui.keyFilePath->setExpectedKind(Utils::PathChooser::File);
updateUi();
m_ui.certificateDetails->setEnabled(m_ui.signaturePath->isValid());
connect(m_ui.certificateDetails, SIGNAL(clicked()),
this, SLOT(displayCertificateDetails()));
connect(m_ui.customCertificateButton, SIGNAL(clicked()),
this, SLOT(updateFromUi()));
connect(m_ui.selfSignedButton, SIGNAL(clicked()),
......@@ -802,6 +808,8 @@ S60CreatePackageStepConfigWidget::S60CreatePackageStepConfigWidget(S60CreatePack
void S60CreatePackageStepConfigWidget::signatureChanged(QString certFile)
{
m_ui.certificateDetails->setEnabled(m_ui.signaturePath->isValid());
if (!certFile.isEmpty() && m_ui.keyFilePath->path().isEmpty()) {
/* If a cert file is selected and there is not key file inserted,
then we check if there is a .key or .pem file in the folder with
......@@ -828,7 +836,6 @@ void S60CreatePackageStepConfigWidget::signatureChanged(QString certFile)
void S60CreatePackageStepConfigWidget::updateUi()
{
switch(m_signStep->signingMode()) {
case S60CreatePackageStep::SignCustom:
m_ui.selfSignedButton->setChecked(false);
......@@ -872,6 +879,17 @@ void S60CreatePackageStepConfigWidget::updateFromUi()
updateUi();
}
void S60CreatePackageStepConfigWidget::displayCertificateDetails()
{
S60CertificateInfo *certificateInformation = new S60CertificateInfo(m_ui.signaturePath->path());
certificateInformation->devicesSupported().sort();
S60CertificateDetailsDialog dialog;
dialog.setText(certificateInformation->toHtml(false));
dialog.exec();
delete certificateInformation;
}
void S60CreatePackageStepConfigWidget::resetPassphrases()
{
QMessageBox msgBox(QMessageBox::Question, tr("Reset Passphrases"),
......
......@@ -194,6 +194,7 @@ private slots:
void updateFromUi();
void resetPassphrases();
void signatureChanged(QString certFile);
void displayCertificateDetails();
private:
S60CreatePackageStep *m_signStep;
......
......@@ -126,6 +126,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="certificateDetails">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Certificate's details</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment