Commit 07da6325 authored by Rafael Roquetto's avatar Rafael Roquetto

BlackBerry: do not show invalid password message

Do not show "Invalid password" dialog when the user has actually pressed
"Cancel" upon prompting for the certificate password or csk password dialog,
and make sure the "overwrite" dialog does not appear after a failed attempt to
request a debug token.

Change-Id: Id9aa78ab3517249df5bd3b4c2d1e0fd2032c3c0b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 312d032a
...@@ -143,9 +143,24 @@ void BlackBerryDebugTokenRequestDialog::requestDebugToken() ...@@ -143,9 +143,24 @@ void BlackBerryDebugTokenRequestDialog::requestDebugToken()
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
bool ok;
const QString cskPassword = m_utils.cskPassword(this, &ok);
if (!ok) {
setBusy(false);
return;
}
const QString certificatePassword = m_utils.certificatePassword(this, &ok);
if (!ok) {
setBusy(false);
return;
}
m_requester->requestDebugToken(m_ui->debugTokenPath->path(), m_requester->requestDebugToken(m_ui->debugTokenPath->path(),
m_utils.cskPassword(this), configuration.defaultKeystorePath(), cskPassword, configuration.defaultKeystorePath(),
m_utils.certificatePassword(this), m_ui->devicePin->text()); certificatePassword, m_ui->devicePin->text());
} }
void BlackBerryDebugTokenRequestDialog::setDefaultPath() void BlackBerryDebugTokenRequestDialog::setDefaultPath()
...@@ -235,6 +250,11 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status) ...@@ -235,6 +250,11 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status)
break; break;
} }
QFile file(m_ui->debugTokenPath->path());
if (file.exists())
file.remove();
QMessageBox::critical(this, tr("Error"), errorString); QMessageBox::critical(this, tr("Error"), errorString);
setBusy(false); setBusy(false);
......
...@@ -215,6 +215,13 @@ void BlackBerrySetupWizard::debugTokenArrived(int status) ...@@ -215,6 +215,13 @@ void BlackBerrySetupWizard::debugTokenArrived(int status)
break; break;
} }
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
QFile dt(configuration.defaultKeystorePath());
if (dt.exists())
dt.remove();
QMessageBox::critical(this, tr("Error"), errorString); QMessageBox::critical(this, tr("Error"), errorString);
reset(); reset();
...@@ -405,8 +412,13 @@ void BlackBerrySetupWizard::requestDebugToken() ...@@ -405,8 +412,13 @@ void BlackBerrySetupWizard::requestDebugToken()
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance(); BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
bool ok;
const QString cskPassword = m_utils.cskPassword(this, &ok);
if (!ok)
return;
m_requester->requestDebugToken(configuration.defaultDebugTokenPath(), m_requester->requestDebugToken(configuration.defaultDebugTokenPath(),
m_utils.cskPassword(this), configuration.defaultKeystorePath(), certificatePassword(), m_devicePin); cskPassword, configuration.defaultKeystorePath(), certificatePassword(), m_devicePin);
} }
void BlackBerrySetupWizard::uploadDebugToken() void BlackBerrySetupWizard::uploadDebugToken()
......
...@@ -82,18 +82,24 @@ bool BlackBerrySigningUtils::hasDefaultCertificate() ...@@ -82,18 +82,24 @@ bool BlackBerrySigningUtils::hasDefaultCertificate()
return keystore.exists(); return keystore.exists();
} }
QString BlackBerrySigningUtils::cskPassword(QWidget *passwordPromptParent) QString BlackBerrySigningUtils::cskPassword(QWidget *passwordPromptParent, bool *ok)
{ {
if (m_cskPassword.isEmpty()) if (m_cskPassword.isEmpty())
m_cskPassword = promptPassword(tr("Please provide your bbidtoken.csk PIN."), passwordPromptParent); m_cskPassword = promptPassword(tr("Please provide your bbidtoken.csk PIN."), passwordPromptParent, ok);
else if (ok)
*ok = true;
return m_cskPassword; return m_cskPassword;
} }
QString BlackBerrySigningUtils::certificatePassword(QWidget *passwordPromptParent) QString BlackBerrySigningUtils::certificatePassword(QWidget *passwordPromptParent, bool *ok)
{ {
if (m_certificatePassword.isEmpty()) if (m_certificatePassword.isEmpty()) {
m_certificatePassword = promptPassword(tr("Please enter your certificate password."), passwordPromptParent); m_certificatePassword =
promptPassword(tr("Please enter your certificate password."), passwordPromptParent, ok);
} else if (ok) {
*ok = true;
}
return m_certificatePassword; return m_certificatePassword;
} }
...@@ -110,7 +116,12 @@ void BlackBerrySigningUtils::openDefaultCertificate(QWidget *passwordPromptParen ...@@ -110,7 +116,12 @@ void BlackBerrySigningUtils::openDefaultCertificate(QWidget *passwordPromptParen
return; return;
} }
const QString password = certificatePassword(passwordPromptParent); bool ok;
const QString password = certificatePassword(passwordPromptParent, &ok);
// action has been canceled
if (!ok)
return;
BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance(); BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance();
...@@ -165,7 +176,8 @@ void BlackBerrySigningUtils::certificateLoaded(int status) ...@@ -165,7 +176,8 @@ void BlackBerrySigningUtils::certificateLoaded(int status)
emit defaultCertificateLoaded(status); emit defaultCertificateLoaded(status);
} }
QString BlackBerrySigningUtils::promptPassword(const QString &message, QWidget *dialogParent) const QString BlackBerrySigningUtils::promptPassword(const QString &message,
QWidget *dialogParent, bool *ok) const
{ {
QInputDialog dialog(dialogParent); QInputDialog dialog(dialogParent);
dialog.setWindowTitle(tr("Qt Creator")); dialog.setWindowTitle(tr("Qt Creator"));
...@@ -173,8 +185,15 @@ QString BlackBerrySigningUtils::promptPassword(const QString &message, QWidget * ...@@ -173,8 +185,15 @@ QString BlackBerrySigningUtils::promptPassword(const QString &message, QWidget *
dialog.setLabelText(message); dialog.setLabelText(message);
dialog.setTextEchoMode(QLineEdit::Password); dialog.setTextEchoMode(QLineEdit::Password);
if (dialog.exec() == QDialog::Rejected) if (dialog.exec() == QDialog::Rejected) {
if (ok)
*ok = false;
return QString(); return QString();
}
if (ok)
*ok = true;
return dialog.textValue(); return dialog.textValue();
} }
...@@ -55,8 +55,8 @@ public: ...@@ -55,8 +55,8 @@ public:
bool hasLegacyKeys(); bool hasLegacyKeys();
bool hasDefaultCertificate(); bool hasDefaultCertificate();
QString cskPassword(QWidget *passwordPromptParent = 0); QString cskPassword(QWidget *passwordPromptParent = 0, bool *ok = 0);
QString certificatePassword(QWidget *passwordPromptParent = 0); QString certificatePassword(QWidget *passwordPromptParent = 0, bool *ok = 0);
const BlackBerryCertificate *defaultCertificate() const; const BlackBerryCertificate *defaultCertificate() const;
...@@ -77,7 +77,7 @@ private: ...@@ -77,7 +77,7 @@ private:
BlackBerrySigningUtils(QObject *parent = 0); BlackBerrySigningUtils(QObject *parent = 0);
QString promptPassword(const QString &message, QWidget *dialogParent = 0) const; QString promptPassword(const QString &message, QWidget *dialogParent = 0, bool *ok = 0) const;
BlackBerryCertificate *m_defaultCertificate; BlackBerryCertificate *m_defaultCertificate;
......
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