refactor: TlsUtility::isEnabled is now a static member
This commit is contained in:
parent
bc857a7cb4
commit
4216acdb3a
4 changed files with 9 additions and 15 deletions
|
|
@ -141,7 +141,7 @@ MainWindow::MainWindow()
|
||||||
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
|
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
|
||||||
|
|
||||||
// Force generation of SHA256 for the localhost
|
// Force generation of SHA256 for the localhost
|
||||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
if (TlsUtility::isEnabled()) {
|
||||||
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
|
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
this, kAppName,
|
this, kAppName,
|
||||||
|
|
@ -371,7 +371,7 @@ void MainWindow::settingsChanged(const QString &key)
|
||||||
|
|
||||||
if ((key == Settings::Security::Certificate) || (key == Settings::Security::KeySize) ||
|
if ((key == Settings::Security::Certificate) || (key == Settings::Security::KeySize) ||
|
||||||
(key == Settings::Security::TlsEnabled) || (key == Settings::Security::CheckPeers)) {
|
(key == Settings::Security::TlsEnabled) || (key == Settings::Security::CheckPeers)) {
|
||||||
if (m_tlsUtility.isEnabled() && !QFile::exists(Settings::value(Settings::Security::Certificate).toString())) {
|
if (TlsUtility::isEnabled() && !QFile::exists(Settings::value(Settings::Security::Certificate).toString())) {
|
||||||
m_tlsUtility.generateCertificate();
|
m_tlsUtility.generateCertificate();
|
||||||
}
|
}
|
||||||
updateSecurityIcon(m_lblSecurityStatus->isVisible());
|
updateSecurityIcon(m_lblSecurityStatus->isVisible());
|
||||||
|
|
@ -581,7 +581,7 @@ void MainWindow::updateSecurityIcon(bool visible)
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool secureSocket = Settings::value(Settings::Security::TlsEnabled).toBool();
|
bool secureSocket = TlsUtility::isEnabled();
|
||||||
|
|
||||||
const auto txt =
|
const auto txt =
|
||||||
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
|
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
|
||||||
|
|
@ -1010,8 +1010,7 @@ void MainWindow::coreConnectionStateChanged(CoreConnectionState state)
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
{
|
{
|
||||||
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
m_btnFingerprint->setVisible(TlsUtility::isEnabled() && QFile::exists(Settings::tlsLocalDb()));
|
||||||
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(Settings::tlsLocalDb()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::hide()
|
void MainWindow::hide()
|
||||||
|
|
|
||||||
|
|
@ -234,11 +234,9 @@ void SettingsDialog::updateTlsControls()
|
||||||
|
|
||||||
ui->comboTlsKeyLength->setCurrentText(Settings::value(Settings::Security::KeySize).toString());
|
ui->comboTlsKeyLength->setCurrentText(Settings::value(Settings::Security::KeySize).toString());
|
||||||
|
|
||||||
const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
|
||||||
|
|
||||||
ui->lineTlsCertPath->setText(certificate);
|
ui->lineTlsCertPath->setText(certificate);
|
||||||
ui->cbRequireClientCert->setChecked(Settings::value(Settings::Security::CheckPeers).toBool());
|
ui->cbRequireClientCert->setChecked(Settings::value(Settings::Security::CheckPeers).toBool());
|
||||||
ui->groupSecurity->setChecked(tlsEnabled);
|
ui->groupSecurity->setChecked(TlsUtility::isEnabled());
|
||||||
|
|
||||||
ui->groupSecurity->setEnabled(Settings::isWritable());
|
ui->groupSecurity->setEnabled(Settings::isWritable());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ TlsUtility::TlsUtility(QObject *parent) : QObject(parent)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TlsUtility::isEnabled() const
|
bool TlsUtility::isEnabled()
|
||||||
{
|
{
|
||||||
return Settings::value(Settings::Security::TlsEnabled).toBool();
|
return Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,10 @@ public:
|
||||||
bool persistCertificate() const;
|
bool persistCertificate() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Combines the availability and the enabled status of TLS.
|
* @brief Checks the settings values Settings::Security::TlsEnabled
|
||||||
*
|
* @return true when tls is enabled
|
||||||
* @return Given that the app setting for TLS is enabled:
|
|
||||||
* If licensing is enabled, it checks whether the product has TLS
|
|
||||||
* available, and if licensing is not enabled, true is returned.
|
|
||||||
*/
|
*/
|
||||||
bool isEnabled() const;
|
static bool isEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TlsCertificate m_certificate;
|
TlsCertificate m_certificate;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue