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] 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();