From bfeb0c22184665a1c1524e60920542217cd9374c Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Wed, 1 Mar 2023 17:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=89=E7=A7=8D=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E7=BD=91=E7=B1=BB=E5=9E=8BLEAP=20PWD=20FAST=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=B9=E6=B3=95=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../depend/kyenterpricesettinginfo.cpp | 143 +++++++++ .../depend/kyenterpricesettinginfo.h | 90 ++++++ .../depend/kywirelessconnectoperation.cpp | 296 ++++++++++++++++++ .../depend/kywirelessconnectoperation.h | 12 + .../depend/kywirelessnetresource.cpp | 122 ++++++++ .../depend/kywirelessnetresource.h | 3 + .../libnm-base-kylin/kylinnetworkmanager.h | 12 + .../libnm-base-kylin/kylinnetworkmanger.cpp | 54 ++++ 8 files changed, 732 insertions(+) diff --git a/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.cpp b/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.cpp index bcf3a464..6f7658d1 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.cpp +++ b/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.cpp @@ -169,3 +169,146 @@ void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSet wifi_8021x_sett->setCaCertificate(caCerEndWithNull); return; } + +void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(leapInfo.m_userName); + wifi_8021x_sett->setPassword(leapInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag); + + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + return; +} + +void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(pwdInfo.m_userName); + wifi_8021x_sett->setPassword(pwdInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag); + + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + return; +} + +void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity); + if (fastInfo.m_allowAutoPacFlag) { + wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning); + } else { + wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled); + } + QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0'); + wifi_8021x_sett->setPacFile(pacEndWithNull); + wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod); + wifi_8021x_sett->setIdentity(fastInfo.m_userName); + wifi_8021x_sett->setPassword(fastInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag); + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + + return; +} + +void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(leapInfo.m_userName); + if(leapInfo.bChanged) + { + wifi_8021x_sett->setPassword(leapInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag); + + QByteArray caCerEndWithNull(""); + wifi_8021x_sett->setCaCertificate(caCerEndWithNull); + + return; +} + +void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(pwdInfo.m_userName); + if(pwdInfo.bChanged) + { + wifi_8021x_sett->setPassword(pwdInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag); + + QByteArray caCerEndWithNull(""); + wifi_8021x_sett->setCaCertificate(caCerEndWithNull); + + return; +} + +void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity); + if (fastInfo.m_allowAutoPacFlag) { + wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning); + } else { + wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled); + } + QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0'); + wifi_8021x_sett->setPacFile(pacEndWithNull); + wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod); + wifi_8021x_sett->setIdentity(fastInfo.m_userName); + if(fastInfo.bChanged) + { + wifi_8021x_sett->setPassword(fastInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag); + return; +} diff --git a/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.h b/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.h index 01c8b29e..1f7d144a 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.h +++ b/libnm-kylin/libnm-base-kylin/depend/kyenterpricesettinginfo.h @@ -11,6 +11,9 @@ enum KyEapMethodType { TLS = 0, PEAP, TTLS, + LEAP, + PWD, + FAST, }; class KyEapMethodTlsInfo @@ -135,12 +138,99 @@ public: } }; +typedef enum { + KyFastProvisioningUnknown = -1, + KyFastProvisioningDisabled, + KyFastProvisioningAllowUnauthenticated, + KyFastProvisioningAllowAuthenticated, + KyFastProvisioningAllowBoth +}KyFastProvisioning; + +class KyEapMethodLeapInfo +{ +public: + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodLeapInfo& info) const + { + if (this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + +class KyEapMethodPwdInfo +{ +public: + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodPwdInfo& info) const + { + if (this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + +class KyEapMethodFastInfo +{ +public: + QString m_anonIdentity; + KyFastProvisioning m_pacProvisioning; + bool m_allowAutoPacFlag; + QString m_pacFilePath; + KyNoEapMethodAuth m_authMethod; + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodFastInfo& info) const + { + if (this->m_anonIdentity == info.m_anonIdentity + && this->m_pacProvisioning == info.m_pacProvisioning + && this->m_allowAutoPacFlag == info.m_allowAutoPacFlag + && this->m_pacFilePath == info.m_pacFilePath + && this->m_authMethod == info.m_authMethod + && this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo); void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo); void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo); +void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo); +void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo); +void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo); void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo); void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo); void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo); +void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo); +void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo); +void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo); #endif // KYENTERPRICESETTINGINFO_H diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.cpp b/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.cpp index 225ddfff..21489464 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.cpp +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.cpp @@ -268,6 +268,101 @@ void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting & return; } +void KyWirelessConnectOperation::addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodLeapSettings(connSetting, leapInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless leap connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } + watcher->deleteLater(); + }); + + return; +} + +void KyWirelessConnectOperation::addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodPwdSettings(connSetting, pwdInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless pwd connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } + watcher->deleteLater(); + }); + + return; +} + +void KyWirelessConnectOperation::addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodFastSettings(connSetting, fastInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless fast connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } + watcher->deleteLater(); + }); + return; +} + void KyWirelessConnectOperation::setWirelessAutoConnect(const QString &uuid, bool bAutoConnect) { NetworkManager::Connection::Ptr connectPtr = @@ -432,6 +527,60 @@ void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QStri return; } +void KyWirelessConnectOperation::updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodLeapSettings(connectionSettings, leapInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + +void KyWirelessConnectOperation::updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodPwdSettings(connectionSettings, pwdInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + +void KyWirelessConnectOperation::updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodFastSettings(connectionSettings, fastInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + void KyWirelessConnectOperation::addAndActiveWirelessConnect(KyWirelessConnectSetting &connSettingInfo, KySecuType &type) { KyKeyMgmt mgmt; @@ -671,6 +820,153 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap }); } +void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo &info, KyWirelessConnectSetting &connSettingInfo) +{ + QString devIface = connSettingInfo.m_ifaceName; + QString conn_uni, dev_uni, spec_object; + NMVariantMapMap map_settings; + NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr; + + if (!connSettingInfo.isHidden) { + NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface; + qWarning()<referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceByName(devIface); + if (dev.isNull()) { + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden); + assembleEapMethodLeapSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodLeapSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPriseLeapConnect failed " << errorMessage; + } + watcher->deleteLater(); + }); +} + +void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo) +{ + QString devIface = connSettingInfo.m_ifaceName; + QString conn_uni, dev_uni, spec_object; + NMVariantMapMap map_settings; + NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr; + + if (!connSettingInfo.isHidden) { + NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface; + qWarning()<referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceByName(devIface); + if (dev.isNull()) { + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden); + assembleEapMethodPwdSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodPwdSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPrisePwdConnect failed " << errorMessage; + } + watcher->deleteLater(); + }); +} + +void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo) +{ + QString devIface = connSettingInfo.m_ifaceName; + QString conn_uni, dev_uni, spec_object; + NMVariantMapMap map_settings; + NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr; + + if (!connSettingInfo.isHidden) { + NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface; + qWarning()<referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceByName(devIface); + if (dev.isNull()) { + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden); + assembleEapMethodFastSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodFastSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPriseFastConnect failed " << errorMessage; + } + watcher->deleteLater(); + }); +} + bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &flag) { NetworkManager::Connection::Ptr conn; diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.h b/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.h index 7481f07d..9fc489b5 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.h +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessconnectoperation.h @@ -68,6 +68,12 @@ public: void addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo); //新增TTLS连接 void addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo); + //新增LEAP连接 + void addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo); + //新增PWD连接 + void addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo); + //新增FAST连接 + void addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo); //新增连接并激活(普通wifi) void addAndActiveWirelessConnect(KyWirelessConnectSetting &connSettingInfo, KySecuType &type); @@ -75,6 +81,9 @@ public: void addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo); void addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo); void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo); + void addAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo &info, KyWirelessConnectSetting &connSettingInfo); + void addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo); + void addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo); //属性页 page1 AutoConnect void setWirelessAutoConnect(const QString &uuid, bool bAutoConnect); //属性页 page2 page3 ipv6 @@ -86,6 +95,9 @@ public: void updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo); void updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo); void updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo); + void updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo); + void updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo); + void updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo); //忘记 void deleteWirelessConnect(const QString &connectUuid); //获取密码 diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp index 99caab98..94f87a33 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp @@ -308,6 +308,12 @@ bool KyWirelessNetResource::getEnterpiseEapMethod(const QString &uuid, KyEapMeth type = PEAP; } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) { type = TTLS; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap)) { + type = LEAP; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd)) { + type = PWD; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast)) { + type = FAST; } return true; } @@ -446,6 +452,122 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls return true; } +bool KyWirelessNetResource::getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoLeap connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + KyWirelessConnectOperation operation; + info.m_userPwd = operation.get8021xPassword(conn->uuid()); + } + + return true; +} + +bool KyWirelessNetResource::getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoPwd connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + KyWirelessConnectOperation operation; + info.m_userPwd = operation.get8021xPassword(conn->uuid()); + } + + return true; +} + +bool KyWirelessNetResource::getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoFast connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_anonIdentity = setting->anonymousIdentity(); + info.m_pacProvisioning = (KyFastProvisioning)setting->phase1FastProvisioning(); + info.m_pacFilePath = setting->pacFile(); + if (info.m_pacFilePath.left(7) == "file://") { + info.m_pacFilePath = info.m_pacFilePath.mid(7); + } + info.m_authMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod(); + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + KyWirelessConnectOperation operation; + info.m_userPwd = operation.get8021xPassword(conn->uuid()); + } + + return true; +} + void KyWirelessNetResource::getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting) { getBaseInfo(interface, ssid, true, !uuid.isEmpty(), connectSetting); diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h index f9d84ba9..a7da235b 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h @@ -30,6 +30,9 @@ public: bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info); bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info); bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info); + bool getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info); + bool getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info); + bool getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info); //获取企业网类型 bool getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type); diff --git a/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h b/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h index 3803d7c0..3bb1ad91 100644 --- a/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h +++ b/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h @@ -130,6 +130,9 @@ public: bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info); bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info); bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info); + bool getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info); + bool getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info); + bool getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info); //获取企业网类型 bool getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type); @@ -168,6 +171,12 @@ public Q_SLOTS: KyWirelessConnectSetting connSettingInfo); void onAddAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo info, KyWirelessConnectSetting connSettingInfo); + void onAddAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo info, + KyWirelessConnectSetting connSettingInfo); + void onAddAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo info, + KyWirelessConnectSetting connSettingInfo); + void onAddAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo info, + KyWirelessConnectSetting connSettingInfo); //=====================新增配置操作==================== //新增普通连接 @@ -187,6 +196,9 @@ public Q_SLOTS: void onUpdateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo); void onUpdateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo); void onUpdateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo); + void onUpdateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo); + void onUpdateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo); + void onUpdateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo); void onUpdateWirelessAutoConnectState(const QString &uuid, bool bAutoConnect); }; diff --git a/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp b/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp index ce2a31e7..dd8dd7bd 100644 --- a/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp +++ b/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp @@ -232,6 +232,24 @@ bool KyNetworkManager::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo return resource.getEnterPriseInfoTtls(uuid, info); } +bool KyNetworkManager::getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info) +{ + KyWirelessNetResource resource; + return resource.getEnterPriseInfoLeap(uuid, info); +} + +bool KyNetworkManager::getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info) +{ + KyWirelessNetResource resource; + return resource.getEnterPriseInfoPwd(uuid, info); +} + +bool KyNetworkManager::getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info) +{ + KyWirelessNetResource resource; + return resource.getEnterPriseInfoFast(uuid, info); +} + //获取企业网类型 bool KyNetworkManager::getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type) { @@ -340,6 +358,24 @@ void KyNetworkManager::onAddAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTt operate.addAndActiveWirelessEnterPriseTtlsConnect(info, connSettingInfo); } +void KyNetworkManager::onAddAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo info, KyWirelessConnectSetting connSettingInfo) +{ + KyWirelessConnectOperation operate; + operate.addAndActiveWirelessEnterPriseLeapConnect(info, connSettingInfo); +} + +void KyNetworkManager::onAddAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo info, KyWirelessConnectSetting connSettingInfo) +{ + KyWirelessConnectOperation operate; + operate.addAndActiveWirelessEnterPrisePwdConnect(info, connSettingInfo); +} + +void KyNetworkManager::onAddAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo info, KyWirelessConnectSetting connSettingInfo) +{ + KyWirelessConnectOperation operate; + operate.addAndActiveWirelessEnterPriseFastConnect(info, connSettingInfo); +} + //=====================新增配置操作==================== //新增普通连接 void KyNetworkManager::onAddNormalConnect(const KyWirelessConnectSetting &connSettingInfo, KySecuType &type) @@ -396,6 +432,24 @@ void KyNetworkManager::onUpdateWirelessEnterPriseTtlsConnect(const QString &uuid operate.updateWirelessEnterPriseTtlsConnect(uuid, ttlsInfo); } +void KyNetworkManager::onUpdateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo) +{ + KyWirelessConnectOperation operate; + operate.updateWirelessEnterPriseLeapConnect(uuid, leapInfo); +} + +void KyNetworkManager::onUpdateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo) +{ + KyWirelessConnectOperation operate; + operate.updateWirelessEnterPrisePwdConnect(uuid, pwdInfo); +} + +void KyNetworkManager::onUpdateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo) +{ + KyWirelessConnectOperation operate; + operate.updateWirelessEnterPriseFastConnect(uuid, fastInfo); +} + void KyNetworkManager::onUpdateWirelessAutoConnectState(const QString &uuid, bool bAutoConnect) { KyWirelessConnectOperation operate;