7#include "security8021xsetting.h"
8#include "security8021xsetting_p.h"
12NetworkManager::Security8021xSettingPrivate::Security8021xSettingPrivate()
13 : name(NM_SETTING_802_1X_SETTING_NAME)
14 , phase1PeapVer(Security8021xSetting::PeapVersionUnknown)
15 , phase1PeapLabel(Security8021xSetting::PeapLabelUnknown)
16 , phase1FastProvisioning(Security8021xSetting::FastProvisioningUnknown)
17 , phase2AuthMethod(Security8021xSetting::AuthMethodUnknown)
18 , phase2AuthEapMethod(Security8021xSetting::AuthEapMethodUnknown)
24 , systemCaCerts(false)
28NetworkManager::Security8021xSetting::Security8021xSetting()
29 : Setting(Setting::Security8021x)
30 , d_ptr(new Security8021xSettingPrivate())
34NetworkManager::Security8021xSetting::Security8021xSetting(
const Ptr &other)
36 , d_ptr(new Security8021xSettingPrivate())
38 setEapMethods(other->eapMethods());
39 setIdentity(other->identity());
40 setDomainSuffixMatch(other->domainSuffixMatch());
41 setAnonymousIdentity(other->anonymousIdentity());
42 setPacFile(other->pacFile());
43 setCaCertificate(other->caCertificate());
44 setCaPath(other->caPath());
45 setSubjectMatch(other->subjectMatch());
46 setAltSubjectMatches(other->altSubjectMatches());
47 setClientCertificate(other->clientCertificate());
48 setPhase1PeapVersion(other->phase1PeapVersion());
49 setPhase1PeapLabel(other->phase1PeapLabel());
50 setPhase1FastProvisioning(other->phase1FastProvisioning());
51 setPhase2AuthMethod(other->phase2AuthMethod());
52 setPhase2AuthEapMethod(other->phase2AuthEapMethod());
53 setPhase2CaCertificate(other->phase2CaCertificate());
54 setPhase2CaPath(other->phase2CaPath());
55 setPhase2SubjectMatch(other->phase2SubjectMatch());
56 setPhase2AltSubjectMatches(other->phase2AltSubjectMatches());
57 setPassword(other->password());
58 setPasswordFlags(other->passwordFlags());
59 setPasswordRaw(other->passwordRaw());
60 setPasswordRawFlags(other->passwordRawFlags());
61 setPrivateKey(other->privateKey());
62 setPrivateKeyPassword(other->privateKeyPassword());
63 setPrivateKeyPasswordFlags(other->privateKeyPasswordFlags());
64 setPhase2PrivateKey(other->phase2PrivateKey());
65 setPhase2PrivateKeyPassword(other->phase2PrivateKeyPassword());
66 setPhase2PrivateKeyPasswordFlags(other->phase2PrivateKeyPasswordFlags());
67 setSystemCaCertificates(other->systemCaCertificates());
70NetworkManager::Security8021xSetting::~Security8021xSetting()
91 Q_D(
const Security8021xSetting);
96void NetworkManager::Security8021xSetting::setIdentity(
const QString &identity)
98 Q_D(Security8021xSetting);
100 d->identity = identity;
103QString NetworkManager::Security8021xSetting::identity()
const
105 Q_D(
const Security8021xSetting);
110void NetworkManager::Security8021xSetting::setAnonymousIdentity(
const QString &identity)
112 Q_D(Security8021xSetting);
114 d->anonymousIdentity = identity;
117QString NetworkManager::Security8021xSetting::anonymousIdentity()
const
119 Q_D(
const Security8021xSetting);
121 return d->anonymousIdentity;
124void NetworkManager::Security8021xSetting::setDomainSuffixMatch(
const QString &domain)
126 Q_D(Security8021xSetting);
128 d->domainSuffixMatch = domain;
131QString NetworkManager::Security8021xSetting::domainSuffixMatch()
const
133 Q_D(
const Security8021xSetting);
135 return d->domainSuffixMatch;
142 d->pacFile = filePath;
145QString NetworkManager::Security8021xSetting::pacFile()
const
156 d->caCert = certificate;
159QByteArray NetworkManager::Security8021xSetting::caCertificate()
const
166void NetworkManager::Security8021xSetting::setCaPath(
const QString &path)
168 Q_D(Security8021xSetting);
173QString NetworkManager::Security8021xSetting::caPath()
const
175 Q_D(
const Security8021xSetting);
180void NetworkManager::Security8021xSetting::setSubjectMatch(
const QString &substring)
182 Q_D(Security8021xSetting);
184 d->subjectMatch = substring;
187QString NetworkManager::Security8021xSetting::subjectMatch()
const
189 Q_D(
const Security8021xSetting);
191 return d->subjectMatch;
194void NetworkManager::Security8021xSetting::setAltSubjectMatches(
const QStringList &strings)
196 Q_D(Security8021xSetting);
198 d->altSubjectMatches = strings;
201QStringList NetworkManager::Security8021xSetting::altSubjectMatches()
const
203 Q_D(
const Security8021xSetting);
205 return d->altSubjectMatches;
212 d->clientCert = certificate;
215QByteArray NetworkManager::Security8021xSetting::clientCertificate()
const
219 return d->clientCert;
222void NetworkManager::Security8021xSetting::setPhase1PeapVersion(NetworkManager::Security8021xSetting::PeapVersion
version)
224 Q_D(Security8021xSetting);
229NetworkManager::Security8021xSetting::PeapVersion NetworkManager::Security8021xSetting::phase1PeapVersion()
const
231 Q_D(
const Security8021xSetting);
233 return d->phase1PeapVer;
236void NetworkManager::Security8021xSetting::setPhase1PeapLabel(NetworkManager::Security8021xSetting::PeapLabel label)
238 Q_D(Security8021xSetting);
240 d->phase1PeapLabel =
label;
243NetworkManager::Security8021xSetting::PeapLabel NetworkManager::Security8021xSetting::phase1PeapLabel()
const
245 Q_D(
const Security8021xSetting);
247 return d->phase1PeapLabel;
250void NetworkManager::Security8021xSetting::setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning provisioning)
252 Q_D(Security8021xSetting);
254 d->phase1FastProvisioning = provisioning;
257NetworkManager::Security8021xSetting::FastProvisioning NetworkManager::Security8021xSetting::phase1FastProvisioning()
const
259 Q_D(
const Security8021xSetting);
261 return d->phase1FastProvisioning;
264void NetworkManager::Security8021xSetting::setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethod method)
266 Q_D(Security8021xSetting);
268 d->phase2AuthMethod = method;
271NetworkManager::Security8021xSetting::AuthMethod NetworkManager::Security8021xSetting::phase2AuthMethod()
const
273 Q_D(
const Security8021xSetting);
275 return d->phase2AuthMethod;
278void NetworkManager::Security8021xSetting::setPhase2AuthEapMethod(NetworkManager::Security8021xSetting::AuthEapMethod method)
280 Q_D(Security8021xSetting);
282 d->phase2AuthEapMethod = method;
285NetworkManager::Security8021xSetting::AuthEapMethod NetworkManager::Security8021xSetting::phase2AuthEapMethod()
const
287 Q_D(
const Security8021xSetting);
289 return d->phase2AuthEapMethod;
296 d->phase2CaCert = certificate;
299QByteArray NetworkManager::Security8021xSetting::phase2CaCertificate()
const
303 return d->phase2CaCert;
306void NetworkManager::Security8021xSetting::setPhase2CaPath(
const QString &path)
308 Q_D(Security8021xSetting);
310 d->phase2CaPath = path;
313QString NetworkManager::Security8021xSetting::phase2CaPath()
const
315 Q_D(
const Security8021xSetting);
317 return d->phase2CaPath;
320void NetworkManager::Security8021xSetting::setPhase2SubjectMatch(
const QString &substring)
322 Q_D(Security8021xSetting);
324 d->phase2SubjectMatch = substring;
327QString NetworkManager::Security8021xSetting::phase2SubjectMatch()
const
329 Q_D(
const Security8021xSetting);
331 return d->phase2SubjectMatch;
334void NetworkManager::Security8021xSetting::setPhase2AltSubjectMatches(
const QStringList &strings)
336 Q_D(Security8021xSetting);
338 d->phase2AltSubjectMatches = strings;
341QStringList NetworkManager::Security8021xSetting::phase2AltSubjectMatches()
const
343 Q_D(
const Security8021xSetting);
345 return d->phase2AltSubjectMatches;
348void NetworkManager::Security8021xSetting::setPhase2ClientCertificate(
const QByteArray &certificate)
350 Q_D(Security8021xSetting);
352 d->phase2ClientCert = certificate;
355QByteArray NetworkManager::Security8021xSetting::phase2ClientCertificate()
const
357 Q_D(
const Security8021xSetting);
359 return d->phase2ClientCert;
362void NetworkManager::Security8021xSetting::setPassword(
const QString &password)
364 Q_D(Security8021xSetting);
366 d->password = password;
369QString NetworkManager::Security8021xSetting::password()
const
371 Q_D(
const Security8021xSetting);
378 Q_D(Security8021xSetting);
380 d->passwordFlags = flags;
385 Q_D(
const Security8021xSetting);
387 return d->passwordFlags;
390void NetworkManager::Security8021xSetting::setPasswordRaw(
const QByteArray &password)
392 Q_D(Security8021xSetting);
394 d->passwordRaw = password;
397QByteArray NetworkManager::Security8021xSetting::passwordRaw()
const
399 Q_D(
const Security8021xSetting);
401 return d->passwordRaw;
406 Q_D(Security8021xSetting);
408 d->passwordRawFlags = flags;
413 Q_D(
const Security8021xSetting);
415 return d->passwordRawFlags;
425QByteArray NetworkManager::Security8021xSetting::privateKey()
const
429 return d->privateKey;
432void NetworkManager::Security8021xSetting::setPrivateKeyPassword(
const QString &password)
434 Q_D(Security8021xSetting);
436 d->privateKeyPassword = password;
439QString NetworkManager::Security8021xSetting::privateKeyPassword()
const
441 Q_D(
const Security8021xSetting);
443 return d->privateKeyPassword;
448 Q_D(Security8021xSetting);
450 d->privateKeyPasswordFlags = flags;
455 Q_D(
const Security8021xSetting);
457 return d->privateKeyPasswordFlags;
460void NetworkManager::Security8021xSetting::setPhase2PrivateKey(
const QByteArray &key)
462 Q_D(Security8021xSetting);
464 d->phase2PrivateKey = key;
467QByteArray NetworkManager::Security8021xSetting::phase2PrivateKey()
const
469 Q_D(
const Security8021xSetting);
471 return d->phase2PrivateKey;
474void NetworkManager::Security8021xSetting::setPhase2PrivateKeyPassword(
const QString &password)
476 Q_D(Security8021xSetting);
478 d->phase2PrivateKeyPassword = password;
481QString NetworkManager::Security8021xSetting::phase2PrivateKeyPassword()
const
483 Q_D(
const Security8021xSetting);
485 return d->phase2PrivateKeyPassword;
490 Q_D(Security8021xSetting);
492 d->phase2PrivateKeyPasswordFlags = flags;
497 Q_D(
const Security8021xSetting);
499 return d->phase2PrivateKeyPasswordFlags;
502void NetworkManager::Security8021xSetting::setSystemCaCertificates(
bool use)
504 Q_D(Security8021xSetting);
506 d->systemCaCerts = use;
509void NetworkManager::Security8021xSetting::setPin(
const QString &pin)
511 Q_D(Security8021xSetting);
516QString NetworkManager::Security8021xSetting::pin()
const
518 Q_D(
const Security8021xSetting);
525 Q_D(Security8021xSetting);
532 Q_D(
const Security8021xSetting);
537bool NetworkManager::Security8021xSetting::systemCaCertificates()
const
539 Q_D(
const Security8021xSetting);
541 return d->systemCaCerts;
544QStringList NetworkManager::Security8021xSetting::needSecrets(
bool requestNew)
const
549 if (eapMethods().contains(EapMethodTls)
550 && (privateKeyPassword().isEmpty() || requestNew)
551 && !privateKeyPasswordFlags().testFlag(NotRequired)) {
552 secrets <<
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
553 }
else if ((eapMethods().contains(EapMethodTtls)
554 || eapMethods().contains(EapMethodPeap)
555 || eapMethods().contains(EapMethodLeap)
556 || eapMethods().contains(EapMethodFast)
557 || eapMethods().contains(EapMethodPwd))
558 && (password().isEmpty() || requestNew)
559 && !passwordFlags().testFlag(NotRequired)) {
562 }
else if (eapMethods().contains(EapMethodSim)
563 && (pin().isEmpty() || requestNew)
564 && !pinFlags().testFlag(NotRequired)) {
569 if ((phase2AuthMethod() == AuthMethodTls || phase2AuthEapMethod() == AuthEapMethodTls)
570 && (phase2PrivateKeyPassword().isEmpty() || requestNew)
571 && !phase2PrivateKeyPasswordFlags().testFlag(NotRequired)) {
572 secrets <<
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD);
578void NetworkManager::Security8021xSetting::secretsFromMap(
const QVariantMap &secrets)
580 if (secrets.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD))) {
584 if (secrets.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW))) {
585 setPasswordRaw(secrets.value(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW)).toByteArray());
588 if (secrets.contains(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD))) {
589 setPrivateKeyPassword(secrets.value(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)).
toString());
592 if (secrets.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD))) {
593 setPhase2PrivateKeyPassword(secrets.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD)).
toString());
596 if (secrets.contains(
QLatin1String(NM_SETTING_802_1X_PIN))) {
601QVariantMap NetworkManager::Security8021xSetting::secretsToMap()
const
605 if (!password().isEmpty()) {
606 secrets.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD), password());
609 if (!passwordRaw().isEmpty()) {
610 secrets.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW), passwordRaw());
613 if (!privateKeyPassword().isEmpty()) {
614 secrets.insert(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), privateKeyPassword());
617 if (!phase2PrivateKeyPassword().isEmpty()) {
618 secrets.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), phase2PrivateKeyPassword());
621 if (!pin().isEmpty()) {
630 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_EAP))) {
633 for (
const QString &method : methods) {
634 if (method ==
"leap") {
635 eapMethods << EapMethodLeap;
636 }
else if (method ==
"md5") {
637 eapMethods << EapMethodMd5;
638 }
else if (method ==
"tls") {
639 eapMethods << EapMethodTls;
640 }
else if (method ==
"peap") {
641 eapMethods << EapMethodPeap;
642 }
else if (method ==
"ttls") {
643 eapMethods << EapMethodTtls;
644 }
else if (method ==
"sim") {
645 eapMethods << EapMethodSim;
646 }
else if (method ==
"fast") {
647 eapMethods << EapMethodFast;
648 }
else if (method ==
"pwd") {
649 eapMethods << EapMethodPwd;
653 setEapMethods(eapMethods);
656 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_IDENTITY))) {
657 setIdentity(setting.value(
QLatin1String(NM_SETTING_802_1X_IDENTITY)).toString());
660 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY))) {
661 setAnonymousIdentity(setting.value(
QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY)).toString());
664 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH))) {
665 setDomainSuffixMatch(setting.value(
QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH)).toString());
668 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PAC_FILE))) {
669 setPacFile(setting.value(
QLatin1String(NM_SETTING_802_1X_PAC_FILE)).toString());
672 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_CA_CERT))) {
673 setCaCertificate(setting.value(
QLatin1String(NM_SETTING_802_1X_CA_CERT)).toByteArray());
676 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_CA_PATH))) {
677 setCaPath(setting.value(
QLatin1String(NM_SETTING_802_1X_CA_PATH)).toString());
680 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH))) {
681 setSubjectMatch(setting.value(
QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH)).toString());
684 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES))) {
685 setAltSubjectMatches(setting.value(
QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES)).toStringList());
688 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_CLIENT_CERT))) {
689 setClientCertificate(setting.value(
QLatin1String(NM_SETTING_802_1X_CLIENT_CERT)).toByteArray());
692 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPVER))) {
696 setPhase1PeapVersion(PeapVersionZero);
698 setPhase1PeapVersion(PeapVersionOne);
702 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL))) {
703 const QString label = setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL)).toString();
706 setPhase1PeapLabel(PeapLabelForce);
710 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING))) {
711 const QString provisioning = setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING)).toString();
713 if (provisioning ==
"0") {
714 setPhase1FastProvisioning(FastProvisioningDisabled);
715 }
else if (provisioning ==
"1") {
716 setPhase1FastProvisioning(FastProvisioningAllowUnauthenticated);
717 }
else if (provisioning ==
"2") {
718 setPhase1FastProvisioning(FastProvisioningAllowAuthenticated);
719 }
else if (provisioning ==
"3") {
720 setPhase1FastProvisioning(FastProvisioningAllowBoth);
724 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH))) {
725 const QString authMethod = setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH)).toString();
727 if (authMethod ==
"pap") {
728 setPhase2AuthMethod(AuthMethodPap);
729 }
else if (authMethod ==
"chap") {
730 setPhase2AuthMethod(AuthMethodChap);
731 }
else if (authMethod ==
"mschap") {
732 setPhase2AuthMethod(AuthMethodMschap);
733 }
else if (authMethod ==
"mschapv2") {
734 setPhase2AuthMethod(AuthMethodMschapv2);
735 }
else if (authMethod ==
"gtc") {
736 setPhase2AuthMethod(AuthMethodGtc);
737 }
else if (authMethod ==
"otp") {
738 setPhase2AuthMethod(AuthMethodOtp);
739 }
else if (authMethod ==
"md5") {
740 setPhase2AuthMethod(AuthMethodMd5);
741 }
else if (authMethod ==
"tls") {
742 setPhase2AuthMethod(AuthMethodTls);
746 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP))) {
747 const QString authEapMethod = setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP)).toString();
749 if (authEapMethod ==
"md5") {
750 setPhase2AuthEapMethod(AuthEapMethodMd5);
751 }
else if (authEapMethod ==
"mschapv2") {
752 setPhase2AuthEapMethod(AuthEapMethodMschapv2);
753 }
else if (authEapMethod ==
"otp") {
754 setPhase2AuthEapMethod(AuthEapMethodOtp);
755 }
else if (authEapMethod ==
"gtc") {
756 setPhase2AuthEapMethod(AuthEapMethodGtc);
757 }
else if (authEapMethod ==
"tls") {
758 setPhase2AuthEapMethod(AuthEapMethodTls);
762 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT))) {
763 setPhase2CaCertificate(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT)).toByteArray());
766 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH))) {
767 setPhase2CaPath(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH)).toString());
770 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH))) {
771 setPhase2SubjectMatch(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH)).toString());
774 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES))) {
775 setPhase2AltSubjectMatches(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES)).toStringList());
778 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT))) {
779 setPhase2ClientCertificate(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT)).toByteArray());
782 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD))) {
783 setPassword(setting.value(
QLatin1String(NM_SETTING_802_1X_PASSWORD)).toString());
786 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS))) {
790 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW))) {
791 setPasswordRaw(setting.value(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW)).toByteArray());
794 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS))) {
798 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY))) {
799 setPrivateKey(setting.value(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY)).toByteArray());
802 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD))) {
803 setPrivateKeyPassword(setting.value(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)).toString());
806 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS))) {
810 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY))) {
811 setPhase2PrivateKey(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY)).toByteArray());
814 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD))) {
815 setPhase2PrivateKeyPassword(setting.value(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD)).toString());
818 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS))) {
822 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PIN))) {
823 setPin(setting.value(
QLatin1String(NM_SETTING_802_1X_PIN)).toString());
826 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_PIN_FLAGS))) {
830 if (setting.contains(
QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS))) {
831 setSystemCaCertificates(setting.value(
QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS)).toBool());
839 if (!eapMethods().isEmpty()) {
842 const auto methodList = eapMethods();
843 for (
const EapMethod &method : methodList) {
844 if (method == EapMethodLeap) {
846 }
else if (method == EapMethodMd5) {
848 }
else if (method == EapMethodTls) {
850 }
else if (method == EapMethodPeap) {
852 }
else if (method == EapMethodTtls) {
854 }
else if (method == EapMethodSim) {
856 }
else if (method == EapMethodFast) {
858 }
else if (method == EapMethodPwd) {
863 setting.insert(
QLatin1String(NM_SETTING_802_1X_EAP), methods);
866 if (!identity().isEmpty()) {
867 setting.insert(
QLatin1String(NM_SETTING_802_1X_IDENTITY), identity());
870 if (!anonymousIdentity().isEmpty()) {
871 setting.insert(
QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY), anonymousIdentity());
874 if (!domainSuffixMatch().isEmpty()) {
875 setting.insert(
QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), domainSuffixMatch());
878 if (!pacFile().isEmpty()) {
879 setting.insert(
QLatin1String(NM_SETTING_802_1X_PAC_FILE), pacFile());
882 if (!caCertificate().isEmpty()) {
883 setting.insert(
QLatin1String(NM_SETTING_802_1X_CA_CERT), caCertificate());
886 if (!caPath().isEmpty()) {
887 setting.insert(
QLatin1String(NM_SETTING_802_1X_CA_PATH), caPath());
890 if (!subjectMatch().isEmpty()) {
891 setting.insert(
QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH), subjectMatch());
894 if (!altSubjectMatches().isEmpty()) {
895 setting.insert(
QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES), altSubjectMatches());
898 if (!clientCertificate().isEmpty()) {
899 setting.insert(
QLatin1String(NM_SETTING_802_1X_CLIENT_CERT), clientCertificate());
903 switch (phase1PeapVersion()) {
904 case PeapVersionZero:
910 case PeapVersionUnknown:
919 switch (phase1PeapLabel()) {
923 case PeapLabelUnknown:
928 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL), peapLabel);
932 switch (phase1FastProvisioning()) {
933 case FastProvisioningDisabled:
936 case FastProvisioningAllowUnauthenticated:
939 case FastProvisioningAllowAuthenticated:
942 case FastProvisioningAllowBoth:
945 case FastProvisioningUnknown:
950 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), provisioning);
954 switch (phase2AuthMethod()) {
961 case AuthMethodMschap:
962 authMethod =
"mschap";
964 case AuthMethodMschapv2:
965 authMethod =
"mschapv2";
979 case AuthMethodUnknown:
984 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH), authMethod);
988 switch (phase2AuthEapMethod()) {
989 case AuthEapMethodMd5:
990 authEapMethod =
"md5";
992 case AuthEapMethodMschapv2:
993 authEapMethod =
"mschapv2";
995 case AuthEapMethodOtp:
996 authEapMethod =
"otp";
998 case AuthEapMethodGtc:
999 authEapMethod =
"gtc";
1001 case AuthEapMethodTls:
1002 authEapMethod =
"tls";
1004 case AuthEapMethodUnknown:
1008 if (!authEapMethod.
isEmpty()) {
1009 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP), authEapMethod);
1012 if (!phase2CaCertificate().isEmpty()) {
1013 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT), phase2CaCertificate());
1016 if (!phase2CaPath().isEmpty()) {
1017 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH), phase2CaPath());
1020 if (!phase2SubjectMatch().isEmpty()) {
1021 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), phase2SubjectMatch());
1024 if (!phase2AltSubjectMatches().isEmpty()) {
1025 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), phase2AltSubjectMatches());
1028 if (!phase2ClientCertificate().isEmpty()) {
1029 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT), phase2ClientCertificate());
1032 if (!password().isEmpty()) {
1033 setting.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD), password());
1036 if (passwordFlags() != None) {
1037 setting.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS), (
int)passwordFlags());
1040 if (!passwordRaw().isEmpty()) {
1041 setting.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW), passwordRaw());
1044 if (passwordRawFlags() != None) {
1045 setting.insert(
QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), (
int)passwordRawFlags());
1048 if (!privateKey().isEmpty()) {
1049 setting.insert(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY), privateKey());
1052 if (!privateKeyPassword().isEmpty()) {
1053 setting.insert(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), privateKeyPassword());
1056 if (privateKeyPasswordFlags() != None) {
1057 setting.insert(
QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), (
int)privateKeyPasswordFlags());
1060 if (!phase2PrivateKey().isEmpty()) {
1061 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), phase2PrivateKey());
1064 if (!phase2PrivateKeyPassword().isEmpty()) {
1065 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), phase2PrivateKeyPassword());
1068 if (phase2PrivateKeyPasswordFlags() != None) {
1069 setting.insert(
QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), (
int)phase2PrivateKeyPasswordFlags());
1072 if (!pin().isEmpty()) {
1073 setting.insert(
QLatin1String(NM_SETTING_802_1X_PIN), pin());
1076 if (pinFlags() != None) {
1077 setting.insert(
QLatin1String(NM_SETTING_802_1X_PIN_FLAGS), (
int)pinFlags());
1080 if (systemCaCertificates()) {
1081 setting.insert(
QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS), systemCaCertificates());
1089 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
1090 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
1092 dbg.
nospace() << NM_SETTING_802_1X_EAP <<
": " << setting.eapMethods() <<
'\n';
1093 dbg.
nospace() << NM_SETTING_802_1X_IDENTITY <<
": " << setting.identity() <<
'\n';
1094 dbg.
nospace() << NM_SETTING_802_1X_ANONYMOUS_IDENTITY <<
": " << setting.anonymousIdentity() <<
'\n';
1095 dbg.
nospace() << NM_SETTING_802_1X_PAC_FILE <<
": " << setting.pacFile() <<
'\n';
1096 dbg.
nospace() << NM_SETTING_802_1X_CA_CERT <<
": " << setting.caCertificate() <<
'\n';
1097 dbg.
nospace() << NM_SETTING_802_1X_CA_PATH <<
": " << setting.caPath() <<
'\n';
1098 dbg.
nospace() << NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH <<
": " << setting.domainSuffixMatch() <<
'\n';
1099 dbg.
nospace() << NM_SETTING_802_1X_SUBJECT_MATCH <<
": " << setting.subjectMatch() <<
'\n';
1100 dbg.
nospace() << NM_SETTING_802_1X_ALTSUBJECT_MATCHES <<
": " << setting.altSubjectMatches() <<
'\n';
1101 dbg.
nospace() << NM_SETTING_802_1X_CLIENT_CERT <<
": " << setting.clientCertificate() <<
'\n';
1102 dbg.
nospace() << NM_SETTING_802_1X_PHASE1_PEAPVER <<
": " << setting.phase1PeapVersion() <<
'\n';
1103 dbg.
nospace() << NM_SETTING_802_1X_PHASE1_PEAPLABEL <<
": " << setting.phase1PeapLabel() <<
'\n';
1104 dbg.
nospace() << NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING <<
": " << setting.phase1FastProvisioning() <<
'\n';
1105 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_AUTH <<
": " << setting.phase2AuthMethod() <<
'\n';
1106 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_AUTHEAP <<
": " << setting.phase2AuthEapMethod() <<
'\n';
1107 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_CA_CERT <<
": " << setting.phase2CaCertificate() <<
'\n';
1108 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_CA_PATH <<
": " << setting.phase2CaPath() <<
'\n';
1109 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH <<
": " << setting.phase2SubjectMatch() <<
'\n';
1110 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES <<
": " << setting.phase2AltSubjectMatches() <<
'\n';
1111 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_CLIENT_CERT <<
": " << setting.phase2ClientCertificate() <<
'\n';
1112 dbg.
nospace() << NM_SETTING_802_1X_PASSWORD <<
": " << setting.password() <<
'\n';
1113 dbg.
nospace() << NM_SETTING_802_1X_PASSWORD_FLAGS <<
": " << setting.passwordFlags() <<
'\n';
1114 dbg.
nospace() << NM_SETTING_802_1X_PASSWORD_RAW <<
": " << setting.passwordRaw() <<
'\n';
1115 dbg.
nospace() << NM_SETTING_802_1X_PASSWORD_RAW_FLAGS <<
": " << setting.passwordRawFlags() <<
'\n';
1116 dbg.
nospace() << NM_SETTING_802_1X_PRIVATE_KEY <<
": " << setting.privateKey() <<
'\n';
1117 dbg.
nospace() << NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD <<
": " << setting.privateKeyPassword() <<
'\n';
1118 dbg.
nospace() << NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS <<
": " << setting.privateKeyPasswordFlags() <<
'\n';
1119 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY <<
": " << setting.phase2PrivateKey() <<
'\n';
1120 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD <<
": " << setting.phase2PrivateKeyPassword() <<
'\n';
1121 dbg.
nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS <<
": " << setting.phase2PrivateKeyPasswordFlags() <<
'\n';
1122 dbg.
nospace() << NM_SETTING_802_1X_PIN <<
": " << setting.pin() <<
'\n';
1123 dbg.
nospace() << NM_SETTING_802_1X_PIN_FLAGS <<
": " << setting.pinFlags() <<
'\n';
1124 dbg.
nospace() << NM_SETTING_802_1X_SYSTEM_CA_CERTS <<
": " << setting.systemCaCertificates() <<
'\n';
Represents 802.1x wireless security setting.
void setPrivateKey(const QByteArray &key)
Set private key for this setting.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
void setPacFile(const QString &filePath)
Set UTF-8 encoded file path containing PAC for EAP-FAST.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void setPhase2CaCertificate(const QByteArray &certificate)
Contains the CA certificate if used by the EAP method specified in the phase2AuthMethod() or phase2Au...
void setCaCertificate(const QByteArray &certificate)
Set certificate authority (ca)'s certificate for this setting.
void setClientCertificate(const QByteArray &certificate)
Set client certificate for this setting.
QString name() const override
Must be reimplemented, default implementationd does nothing.
char * toString(const EngineQuery &query)
QString label(StandardShortcut id)
This class allows querying the underlying system to discover the available network interfaces and rea...
NETWORKMANAGERQT_EXPORT QString version()
Get the NetworkManager version.
T value(qsizetype i) const const
bool isEmpty() const const