From 8c4595ced4074c50d29691579d024097d478908d Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Fri, 22 Oct 2021 11:14:35 +0800 Subject: [PATCH 1/2] fix enterprise property page --- .../kywirelessconnectoperation.cpp | 7 +++-- .../dbus-interface/kywirelessnetresource.cpp | 15 +++++++-- src/frontend/netdetails/coninfo.h | 7 +++++ src/frontend/netdetails/securitypage.cpp | 31 +++++++++++++++---- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src/backend/dbus-interface/kywirelessconnectoperation.cpp b/src/backend/dbus-interface/kywirelessconnectoperation.cpp index 709b135b..4edb0bec 100644 --- a/src/backend/dbus-interface/kywirelessconnectoperation.cpp +++ b/src/backend/dbus-interface/kywirelessconnectoperation.cpp @@ -3,6 +3,7 @@ #include #define PSK_SETTING_NAME "802-11-wireless-security" +#define PRIVATE_PSK_SETTING_NAME "802-1x" NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect) { @@ -296,7 +297,7 @@ QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connect qWarning()< reply = connectPtr->secrets(PSK_SETTING_NAME); + QDBusPendingReply reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME); QMap map(reply.value()); if (map.contains("802-1x") && map.value("802-1x").contains("private-key-password")) { @@ -316,7 +317,7 @@ QString KyWirelessConnectOperation::get8021xPassword(const QString &connectUuid) qWarning()< reply = connectPtr->secrets(PSK_SETTING_NAME); + QDBusPendingReply reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME); QMap map(reply.value()); if (map.contains("802-1x") && map.value("802-1x").contains("password")) { @@ -909,6 +910,8 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type); if (bPwdChange) { security_sett->setPsk(connSettingInfo.m_psk); + NetworkManager::Setting::SecretFlags flag = NetworkManager::Setting::None; + security_sett->setPskFlags(flag); } return; } diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index ab596bdf..923b3b02 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -440,7 +440,10 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn info.caCertPath = setting->caPath(); info.clientCertPath = setting->clientCertificate(); info.clientPrivateKey = QString(setting->privateKey()); - info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid()); + info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags(); + if (!info.m_privateKeyPWDFlag) { + info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid()); + } return true; } @@ -470,7 +473,10 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod(); info.userName = setting->identity(); - info.userPWD = m_operation->get8021xPassword(conn->uuid()); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + info.userPWD = m_operation->get8021xPassword(conn->uuid()); + } return true; } @@ -510,7 +516,10 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls info.authType = KyTtlsAuthMethod::AUTH_NO_EAP; } info.userName = setting->identity(); - info.userPWD = m_operation->get8021xPassword(conn->uuid()); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + info.userPWD = m_operation->get8021xPassword(conn->uuid()); + } return true; diff --git a/src/frontend/netdetails/coninfo.h b/src/frontend/netdetails/coninfo.h index 9aeb1526..fea774f8 100644 --- a/src/frontend/netdetails/coninfo.h +++ b/src/frontend/netdetails/coninfo.h @@ -12,6 +12,13 @@ #define AUTO_CONFIG 0 #define MANUAL_CONFIG 1 +enum PeapInnerType +{ + MSCHAPV2_PEAP = 0, + MD5_PEAP, + GTC_PEAP, +}; + enum TtlsInnerType { PAP = 0, diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index 4b8dc71d..8ccf93a8 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -242,7 +242,13 @@ void SecurityPage::setPeapInfo(KyEapMethodPeapInfo &info) showPeapOrTtls(); eapTypeCombox->setCurrentIndex(PEAP); onEapTypeComboxIndexChanged(); - eapMethodCombox->setCurrentIndex(info.phase2AuthMethod); + if (info.phase2AuthMethod == KyAuthMethodMschapv2) { + eapMethodCombox->setCurrentIndex(MSCHAPV2_PEAP); + } else if (info.phase2AuthMethod == KyAuthMethodMd5){ + eapMethodCombox->setCurrentIndex(MD5_PEAP); + } else if (info.phase2AuthMethod == KyAuthMethodGtc) { + eapMethodCombox->setCurrentIndex(GTC_PEAP); + } userNameEdit->setText(info.userName); userPwdEdit->setText(info.userPWD); if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) { @@ -529,7 +535,20 @@ KyEapMethodTlsInfo SecurityPage::assembleTlsInfo() KyEapMethodPeapInfo SecurityPage::assemblePeapInfo() { KyEapMethodPeapInfo info; - info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); +// info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); + switch (eapMethodCombox->currentIndex()) { + case 0: + info.phase2AuthMethod = KyAuthMethodMschapv2; + break; + case 1: + info.phase2AuthMethod = KyAuthMethodMd5; + break; + case 2: + info.phase2AuthMethod = KyAuthMethodGtc; + break; + default: + break; + } info.userName = userNameEdit->text(); info.userPWD = userPwdEdit->text(); info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); @@ -539,7 +558,7 @@ KyEapMethodPeapInfo SecurityPage::assemblePeapInfo() KyEapMethodTtlsInfo SecurityPage::assembleTtlsInfo() { KyEapMethodTtlsInfo info; - switch (eapMethodCombox->currentData().toInt()) { + switch (eapMethodCombox->currentIndex()) { case PAP: info.authType = AUTH_NO_EAP; info.authNoEapMethod = KyAuthMethodPap; @@ -671,9 +690,9 @@ void SecurityPage::onEapTypeComboxIndexChanged() } else if (index == PEAP) { showPeapOrTtls(); eapMethodCombox->clear(); - eapMethodCombox->addItem("MSCHAPv2", KyAuthMethodMschapv2); - eapMethodCombox->addItem("MD5", KyAuthMethodMd5); - eapMethodCombox->addItem("GTC", KyAuthMethodGtc); + eapMethodCombox->addItem("MSCHAPv2", MSCHAPV2_PEAP); + eapMethodCombox->addItem("MD5", MD5_PEAP); + eapMethodCombox->addItem("GTC", GTC_PEAP); emit this->eapTypeChanged(PEAP); } else if (index == TTLS) { showPeapOrTtls(); From 62bcafc22714400c00e133fc0e1f7375652c0ff3 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Fri, 22 Oct 2021 11:44:16 +0800 Subject: [PATCH 2/2] check pwdflag is change --- .../dbus-interface/kyenterpricesettinginfo.h | 8 ++++---- .../dbus-interface/kywirelessnetresource.cpp | 9 +++++++++ src/frontend/netdetails/securitypage.cpp | 16 ++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/backend/dbus-interface/kyenterpricesettinginfo.h b/src/backend/dbus-interface/kyenterpricesettinginfo.h index c2427671..01c8b29e 100644 --- a/src/backend/dbus-interface/kyenterpricesettinginfo.h +++ b/src/backend/dbus-interface/kyenterpricesettinginfo.h @@ -38,7 +38,7 @@ public: && this->clientCertPath == info.clientCertPath && this->clientPrivateKey == info.clientPrivateKey && this->clientPrivateKeyPWD == info.clientPrivateKeyPWD - /*&& this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag*/) { + && this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag) { return true; } else { return false; @@ -83,7 +83,7 @@ public: if (this->phase2AuthMethod == info.phase2AuthMethod && this->userName == info.userName && this->userPWD == info.userPWD - /*&& this->m_passwdFlag == info.m_passwdFlag*/) { + && this->m_passwdFlag == info.m_passwdFlag) { return true; } else { return false; @@ -116,7 +116,7 @@ public: if (this->authEapMethod == info.authEapMethod && this ->userName == info.userName && this->userPWD == info.userPWD - /*&& this->m_passwdFlag == info.m_passwdFlag*/) { + && this->m_passwdFlag == info.m_passwdFlag) { return true; } } else { @@ -124,7 +124,7 @@ public: if (this->authNoEapMethod == info.authNoEapMethod && this ->userName == info.userName && this->userPWD == info.userPWD - /*&& this->m_passwdFlag == info.m_passwdFlag*/) { + && this->m_passwdFlag == info.m_passwdFlag) { return true; } } diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index 923b3b02..658839ad 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -438,8 +438,17 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn info.identity = setting->identity(); info.domain = setting->domainSuffixMatch(); info.caCertPath = setting->caPath(); + if (info.caCertPath.left(7) == "file://") { + info.caCertPath = info.caCertPath.mid(7); + } info.clientCertPath = setting->clientCertificate(); + if (info.clientCertPath.left(7) == "file://") { + info.clientCertPath = info.clientCertPath.mid(7); + } info.clientPrivateKey = QString(setting->privateKey()); + if (info.clientPrivateKey.left(7) == "file://") { + info.clientPrivateKey = info.clientPrivateKey.mid(7); + } info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags(); if (!info.m_privateKeyPWDFlag) { info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid()); diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index 8ccf93a8..0aec0a87 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -251,7 +251,7 @@ void SecurityPage::setPeapInfo(KyEapMethodPeapInfo &info) } userNameEdit->setText(info.userName); userPwdEdit->setText(info.userPWD); - if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) { + if (info.m_passwdFlag) { userPwdFlagBox->setChecked(true); } else { userPwdFlagBox->setChecked(false); @@ -289,7 +289,7 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info) } userNameEdit->setText(info.userName); userPwdEdit->setText(info.userPWD); - if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) { + if (info.m_passwdFlag) { userPwdFlagBox->setChecked(true); } else { userPwdFlagBox->setChecked(false); @@ -313,9 +313,9 @@ void SecurityPage::setSecurityVisible(const bool &visible) void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info) { KyEapMethodTlsInfo tlsInfo = assembleTlsInfo(); -// if (tlsInfo.clientPrivateKeyPWD != info.clientPrivateKeyPWD) { + if (tlsInfo.clientPrivateKeyPWD != info.clientPrivateKeyPWD) { tlsInfo.bChanged = true; -// } + } tlsInfo.devIfaceName = info.devIfaceName; info = tlsInfo; } @@ -323,18 +323,18 @@ void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info) void SecurityPage::updatePeapChange(KyEapMethodPeapInfo &info) { KyEapMethodPeapInfo peapInfo = assemblePeapInfo(); -// if (peapInfo.userPWD != info.userPWD) { + if (peapInfo.userPWD != info.userPWD) { peapInfo.bChanged = true; -// } + } info = peapInfo; } void SecurityPage::updateTtlsChange(KyEapMethodTtlsInfo &info) { KyEapMethodTtlsInfo ttlsInfo = assembleTtlsInfo(); -// if (ttlsInfo.userPWD != info.userPWD) { + if (ttlsInfo.userPWD != info.userPWD) { ttlsInfo.bChanged = true; -// } + } info = ttlsInfo; }