fix enterprise property page

This commit is contained in:
jzxc95 2021-10-22 11:14:35 +08:00
parent b2411b918b
commit 8c4595ced4
4 changed files with 49 additions and 11 deletions

View File

@ -3,6 +3,7 @@
#include <networkmanagerqt/wirelesssecuritysetting.h>
#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()<<errorMessage;
return "";
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
QMap<QString,QVariantMap> 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()<<errorMessage;
return "";
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
QMap<QString,QVariantMap> 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;
}

View File

@ -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;

View File

@ -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,

View File

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