1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef NETWORKMANAGERQT_SECURITY8021X_SETTING_H
8#define NETWORKMANAGERQT_SECURITY8021X_SETTING_H
9
10#include "setting.h"
11#include <networkmanagerqt/networkmanagerqt_export.h>
12
13namespace NetworkManager
14{
15class Security8021xSettingPrivate;
16
17/**
18 * Represents 802.1x wireless security setting
19 */
20class NETWORKMANAGERQT_EXPORT Security8021xSetting : public Setting
21{
22public:
23 typedef QSharedPointer<Security8021xSetting> Ptr;
24 typedef QList<Ptr> List;
25 enum EapMethod {
26 EapMethodUnknown = 0,
27 EapMethodLeap,
28 EapMethodMd5,
29 EapMethodTls,
30 EapMethodPeap,
31 EapMethodTtls,
32 EapMethodSim,
33 EapMethodFast,
34 EapMethodPwd,
35 };
36 enum PeapVersion {
37 PeapVersionUnknown = -1,
38 PeapVersionZero,
39 PeapVersionOne,
40 };
41 enum PeapLabel {
42 PeapLabelUnknown = 0,
43 PeapLabelForce,
44 };
45 enum FastProvisioning {
46 FastProvisioningUnknown = -1,
47 FastProvisioningDisabled,
48 FastProvisioningAllowUnauthenticated,
49 FastProvisioningAllowAuthenticated,
50 FastProvisioningAllowBoth,
51 };
52 enum AuthMethod {
53 AuthMethodUnknown = 0,
54 AuthMethodPap,
55 AuthMethodChap,
56 AuthMethodMschap,
57 AuthMethodMschapv2,
58 AuthMethodGtc,
59 AuthMethodOtp,
60 AuthMethodMd5,
61 AuthMethodTls,
62 };
63 enum AuthEapMethod {
64 AuthEapMethodUnknown = 0,
65 AuthEapMethodMd5,
66 AuthEapMethodMschapv2,
67 AuthEapMethodOtp,
68 AuthEapMethodGtc,
69 AuthEapMethodTls,
70 };
71
72 Security8021xSetting();
73 explicit Security8021xSetting(const Ptr &other);
74 ~Security8021xSetting() override;
75
76 QString name() const override;
77
78 void setEapMethods(const QList<EapMethod> &methods);
79 QList<EapMethod> eapMethods() const;
80
81 void setIdentity(const QString &identity);
82 QString identity() const;
83
84 void setAnonymousIdentity(const QString &identity);
85 QString anonymousIdentity() const;
86
87 void setDomainSuffixMatch(const QString &domainSuffixMatch);
88 QString domainSuffixMatch() const;
89
90 /**
91 * Set UTF-8 encoded file path containing PAC for EAP-FAST.
92 *
93 * \param filePath file path to be set.
94 */
95 void setPacFile(const QString &filePath);
96 QString pacFile() const;
97
98 /**
99 * Set certificate authority (ca)'s certificate for this setting.
100 *
101 * \param certificate certificate's file path encoded into a byte array.
102 *
103 * \warning certificate have to be null terminated or NetworkManager will refuse it.
104 */
105 void setCaCertificate(const QByteArray &certificate);
106 QByteArray caCertificate() const;
107
108 void setCaPath(const QString &path);
109 QString caPath() const;
110
111 void setSubjectMatch(const QString &substring);
112 QString subjectMatch() const;
113
114 void setAltSubjectMatches(const QStringList &strings);
115 QStringList altSubjectMatches() const;
116
117 /**
118 * Set client certificate for this setting.
119 *
120 * \param certificate certificate's file path encoded into a byte array.
121 *
122 * \warning certificate have to be null terminated or NetworkManager will refuse it.
123 */
124 void setClientCertificate(const QByteArray &certificate);
125 QByteArray clientCertificate() const;
126
127 void setPhase1PeapVersion(PeapVersion version);
128 PeapVersion phase1PeapVersion() const;
129
130 void setPhase1PeapLabel(PeapLabel label);
131 PeapLabel phase1PeapLabel() const;
132
133 void setPhase1FastProvisioning(FastProvisioning provisioning);
134 FastProvisioning phase1FastProvisioning() const;
135
136 void setPhase2AuthMethod(AuthMethod method);
137 AuthMethod phase2AuthMethod() const;
138
139 void setPhase2AuthEapMethod(AuthEapMethod method);
140 AuthEapMethod phase2AuthEapMethod() const;
141
142 /**
143 * Contains the CA certificate if used by the EAP method specified in the
144 * phase2AuthMethod() or phase2AuthEapMethod() properties.
145 *
146 * \param certificate certificate's file path encoded into a byte array.
147 *
148 * \warning certificate have to be null terminated or NetworkManager will refuse it.
149 */
150 void setPhase2CaCertificate(const QByteArray &certificate);
151 QByteArray phase2CaCertificate() const;
152
153 void setPhase2CaPath(const QString &path);
154 QString phase2CaPath() const;
155
156 void setPhase2SubjectMatch(const QString &substring);
157 QString phase2SubjectMatch() const;
158
159 void setPhase2AltSubjectMatches(const QStringList &strings);
160 QStringList phase2AltSubjectMatches() const;
161
162 void setPhase2ClientCertificate(const QByteArray &certificate);
163 QByteArray phase2ClientCertificate() const;
164
165 void setPassword(const QString &password);
166 QString password() const;
167
168 void setPasswordFlags(Setting::SecretFlags flags);
169 Setting::SecretFlags passwordFlags() const;
170
171 void setPasswordRaw(const QByteArray &password);
172 QByteArray passwordRaw() const;
173
174 void setPasswordRawFlags(Setting::SecretFlags flags);
175 Setting::SecretFlags passwordRawFlags() const;
176
177 /**
178 * Set private key for this setting.
179 *
180 * \param key the key to be set.
181 *
182 * \warning key have to be null terminated or NetworkManager will refuse it.
183 */
184 void setPrivateKey(const QByteArray &key);
185 QByteArray privateKey() const;
186
187 void setPrivateKeyPassword(const QString &password);
188 QString privateKeyPassword() const;
189
190 void setPrivateKeyPasswordFlags(Setting::SecretFlags flags);
191 Setting::SecretFlags privateKeyPasswordFlags() const;
192
193 void setPhase2PrivateKey(const QByteArray &key);
194 QByteArray phase2PrivateKey() const;
195
196 void setPhase2PrivateKeyPassword(const QString &password);
197 QString phase2PrivateKeyPassword() const;
198
199 void setPhase2PrivateKeyPasswordFlags(Setting::SecretFlags flags);
200 Setting::SecretFlags phase2PrivateKeyPasswordFlags() const;
201
202 void setPin(const QString &pin);
203 QString pin() const;
204
205 void setPinFlags(Setting::SecretFlags flags);
206 Setting::SecretFlags pinFlags() const;
207
208 void setSystemCaCertificates(bool use);
209 bool systemCaCertificates() const;
210
211 QStringList needSecrets(bool requestNew = false) const override;
212
213 void secretsFromMap(const QVariantMap &secrets) override;
214
215 QVariantMap secretsToMap() const override;
216
217 void fromMap(const QVariantMap &setting) override;
218
219 QVariantMap toMap() const override;
220
221protected:
222 Security8021xSettingPrivate *const d_ptr;
223
224private:
225 Q_DECLARE_PRIVATE(Security8021xSetting)
226};
227
228NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Security8021xSetting &setting);
229
230}
231
232#endif // NETWORKMANAGERQT_SECURITY802X_SETTING_H
233

source code of networkmanager-qt/src/settings/security8021xsetting.h