| 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 | |
| 13 | namespace NetworkManager |
| 14 | { |
| 15 | class Security8021xSettingPrivate; |
| 16 | |
| 17 | /*! |
| 18 | * \class NetworkManager::Security8021xSetting |
| 19 | * \inheaderfile NetworkManagerQt/Security8021xSetting |
| 20 | * \inmodule NetworkManagerQt |
| 21 | * |
| 22 | * \brief Represents 802.1x wireless security setting. |
| 23 | */ |
| 24 | class NETWORKMANAGERQT_EXPORT Security8021xSetting : public Setting |
| 25 | { |
| 26 | public: |
| 27 | /*! |
| 28 | * \typedef NetworkManager::Security8021xSetting::Ptr |
| 29 | */ |
| 30 | typedef QSharedPointer<Security8021xSetting> Ptr; |
| 31 | /*! |
| 32 | * \typedef NetworkManager::Security8021xSetting::List |
| 33 | */ |
| 34 | typedef QList<Ptr> List; |
| 35 | /*! |
| 36 | * |
| 37 | * \value EapMethodUnknown |
| 38 | * \value EapMethodLeap |
| 39 | * \value EapMethodMd5 |
| 40 | * \value EapMethodTls |
| 41 | * \value EapMethodPeap |
| 42 | * \value EapMethodTtls |
| 43 | * \value EapMethodSim |
| 44 | * \value EapMethodFast |
| 45 | * \value EapMethodPwd |
| 46 | */ |
| 47 | enum EapMethod { |
| 48 | EapMethodUnknown = 0, |
| 49 | EapMethodLeap, |
| 50 | EapMethodMd5, |
| 51 | EapMethodTls, |
| 52 | EapMethodPeap, |
| 53 | EapMethodTtls, |
| 54 | EapMethodSim, |
| 55 | EapMethodFast, |
| 56 | EapMethodPwd, |
| 57 | }; |
| 58 | /*! |
| 59 | * |
| 60 | * \value PeapVersionUnknown |
| 61 | * \value PeapVersionZero |
| 62 | * \value PeapVersionOne |
| 63 | */ |
| 64 | enum PeapVersion { |
| 65 | PeapVersionUnknown = -1, |
| 66 | PeapVersionZero, |
| 67 | PeapVersionOne, |
| 68 | }; |
| 69 | /*! |
| 70 | * |
| 71 | * \value PeapLabelUnknown |
| 72 | * \value PeapLabelForce |
| 73 | */ |
| 74 | enum PeapLabel { |
| 75 | PeapLabelUnknown = 0, |
| 76 | PeapLabelForce, |
| 77 | }; |
| 78 | /*! |
| 79 | * |
| 80 | * \value FastProvisioningUnknown |
| 81 | * \value FastProvisioningDisabled |
| 82 | * \value FastProvisioningAllowUnauthenticated |
| 83 | * \value FastProvisioningAllowAuthenticated |
| 84 | * \value FastProvisioningAllowBoth |
| 85 | */ |
| 86 | enum FastProvisioning { |
| 87 | FastProvisioningUnknown = -1, |
| 88 | FastProvisioningDisabled, |
| 89 | FastProvisioningAllowUnauthenticated, |
| 90 | FastProvisioningAllowAuthenticated, |
| 91 | FastProvisioningAllowBoth, |
| 92 | }; |
| 93 | /*! |
| 94 | * |
| 95 | * \value AuthMethodUnknown |
| 96 | * \value AuthMethodPap |
| 97 | * \value AuthMethodChap |
| 98 | * \value AuthMethodMschap |
| 99 | * \value AuthMethodMschapv2 |
| 100 | * \value AuthMethodGtc |
| 101 | * \value AuthMethodOtp |
| 102 | * \value AuthMethodMd5 |
| 103 | * \value AuthMethodTls |
| 104 | */ |
| 105 | enum AuthMethod { |
| 106 | AuthMethodUnknown = 0, |
| 107 | AuthMethodPap, |
| 108 | AuthMethodChap, |
| 109 | AuthMethodMschap, |
| 110 | AuthMethodMschapv2, |
| 111 | AuthMethodGtc, |
| 112 | AuthMethodOtp, |
| 113 | AuthMethodMd5, |
| 114 | AuthMethodTls, |
| 115 | }; |
| 116 | /*! |
| 117 | * |
| 118 | * \value AuthEapMethodUnknown |
| 119 | * \value AuthEapMethodMd5 |
| 120 | * \value AuthEapMethodMschapv2 |
| 121 | * \value AuthEapMethodOtp |
| 122 | * \value AuthEapMethodGtc |
| 123 | * \value AuthEapMethodTls |
| 124 | */ |
| 125 | enum AuthEapMethod { |
| 126 | AuthEapMethodUnknown = 0, |
| 127 | AuthEapMethodMd5, |
| 128 | AuthEapMethodMschapv2, |
| 129 | AuthEapMethodOtp, |
| 130 | AuthEapMethodGtc, |
| 131 | AuthEapMethodTls, |
| 132 | }; |
| 133 | |
| 134 | /*! |
| 135 | */ |
| 136 | Security8021xSetting(); |
| 137 | /*! |
| 138 | */ |
| 139 | explicit Security8021xSetting(const Ptr &other); |
| 140 | ~Security8021xSetting() override; |
| 141 | |
| 142 | QString name() const override; |
| 143 | |
| 144 | /*! |
| 145 | */ |
| 146 | void setEapMethods(const QList<EapMethod> &methods); |
| 147 | /*! |
| 148 | */ |
| 149 | QList<EapMethod> eapMethods() const; |
| 150 | |
| 151 | /*! |
| 152 | */ |
| 153 | void setIdentity(const QString &identity); |
| 154 | /*! |
| 155 | */ |
| 156 | QString identity() const; |
| 157 | |
| 158 | /*! |
| 159 | */ |
| 160 | void setAnonymousIdentity(const QString &identity); |
| 161 | /*! |
| 162 | */ |
| 163 | QString anonymousIdentity() const; |
| 164 | |
| 165 | /*! |
| 166 | */ |
| 167 | void setDomainSuffixMatch(const QString &domainSuffixMatch); |
| 168 | /*! |
| 169 | */ |
| 170 | QString domainSuffixMatch() const; |
| 171 | |
| 172 | /*! |
| 173 | * Set UTF-8 encoded file path containing PAC for EAP-FAST. |
| 174 | * |
| 175 | * \param filePath file path to be set. |
| 176 | */ |
| 177 | void setPacFile(const QString &filePath); |
| 178 | /*! |
| 179 | */ |
| 180 | QString pacFile() const; |
| 181 | |
| 182 | /*! |
| 183 | * Set certificate authority (ca)'s certificate for this setting. |
| 184 | * |
| 185 | * \param certificate certificate's file path encoded into a byte array. |
| 186 | * |
| 187 | * \warning certificate have to be null terminated or NetworkManager will refuse it. |
| 188 | */ |
| 189 | void setCaCertificate(const QByteArray &certificate); |
| 190 | /*! |
| 191 | */ |
| 192 | QByteArray caCertificate() const; |
| 193 | |
| 194 | /*! |
| 195 | */ |
| 196 | void setCaPath(const QString &path); |
| 197 | /*! |
| 198 | */ |
| 199 | QString caPath() const; |
| 200 | |
| 201 | /*! |
| 202 | */ |
| 203 | void setSubjectMatch(const QString &substring); |
| 204 | /*! |
| 205 | */ |
| 206 | QString subjectMatch() const; |
| 207 | |
| 208 | /*! |
| 209 | */ |
| 210 | void setAltSubjectMatches(const QStringList &strings); |
| 211 | /*! |
| 212 | */ |
| 213 | QStringList altSubjectMatches() const; |
| 214 | |
| 215 | /*! |
| 216 | * Set client certificate for this setting. |
| 217 | * |
| 218 | * \param certificate certificate's file path encoded into a byte array. |
| 219 | * |
| 220 | * \warning certificate have to be null terminated or NetworkManager will refuse it. |
| 221 | */ |
| 222 | void setClientCertificate(const QByteArray &certificate); |
| 223 | /*! |
| 224 | */ |
| 225 | QByteArray clientCertificate() const; |
| 226 | |
| 227 | /*! |
| 228 | */ |
| 229 | void setPhase1PeapVersion(PeapVersion version); |
| 230 | /*! |
| 231 | */ |
| 232 | PeapVersion phase1PeapVersion() const; |
| 233 | |
| 234 | /*! |
| 235 | */ |
| 236 | void setPhase1PeapLabel(PeapLabel label); |
| 237 | /*! |
| 238 | */ |
| 239 | PeapLabel phase1PeapLabel() const; |
| 240 | |
| 241 | /*! |
| 242 | */ |
| 243 | void setPhase1FastProvisioning(FastProvisioning provisioning); |
| 244 | /*! |
| 245 | */ |
| 246 | FastProvisioning phase1FastProvisioning() const; |
| 247 | |
| 248 | /*! |
| 249 | */ |
| 250 | void setPhase2AuthMethod(AuthMethod method); |
| 251 | /*! |
| 252 | */ |
| 253 | AuthMethod phase2AuthMethod() const; |
| 254 | |
| 255 | /*! |
| 256 | */ |
| 257 | void setPhase2AuthEapMethod(AuthEapMethod method); |
| 258 | /*! |
| 259 | */ |
| 260 | AuthEapMethod phase2AuthEapMethod() const; |
| 261 | |
| 262 | /*! |
| 263 | * Contains the CA certificate if used by the EAP method specified in the |
| 264 | * phase2AuthMethod() or phase2AuthEapMethod() properties. |
| 265 | * |
| 266 | * \param certificate certificate's file path encoded into a byte array. |
| 267 | * |
| 268 | * \warning certificate have to be null terminated or NetworkManager will refuse it. |
| 269 | */ |
| 270 | void setPhase2CaCertificate(const QByteArray &certificate); |
| 271 | /*! |
| 272 | */ |
| 273 | QByteArray phase2CaCertificate() const; |
| 274 | |
| 275 | /*! |
| 276 | */ |
| 277 | void setPhase2CaPath(const QString &path); |
| 278 | /*! |
| 279 | */ |
| 280 | QString phase2CaPath() const; |
| 281 | |
| 282 | /*! |
| 283 | */ |
| 284 | void setPhase2SubjectMatch(const QString &substring); |
| 285 | /*! |
| 286 | */ |
| 287 | QString phase2SubjectMatch() const; |
| 288 | |
| 289 | /*! |
| 290 | */ |
| 291 | void setPhase2AltSubjectMatches(const QStringList &strings); |
| 292 | /*! |
| 293 | */ |
| 294 | QStringList phase2AltSubjectMatches() const; |
| 295 | |
| 296 | /*! |
| 297 | */ |
| 298 | void setPhase2ClientCertificate(const QByteArray &certificate); |
| 299 | /*! |
| 300 | */ |
| 301 | QByteArray phase2ClientCertificate() const; |
| 302 | |
| 303 | /*! |
| 304 | */ |
| 305 | void setPassword(const QString &password); |
| 306 | /*! |
| 307 | */ |
| 308 | QString password() const; |
| 309 | |
| 310 | /*! |
| 311 | */ |
| 312 | void setPasswordFlags(Setting::SecretFlags flags); |
| 313 | /*! |
| 314 | */ |
| 315 | Setting::SecretFlags passwordFlags() const; |
| 316 | |
| 317 | /*! |
| 318 | */ |
| 319 | void setPasswordRaw(const QByteArray &password); |
| 320 | /*! |
| 321 | */ |
| 322 | QByteArray passwordRaw() const; |
| 323 | |
| 324 | /*! |
| 325 | */ |
| 326 | void setPasswordRawFlags(Setting::SecretFlags flags); |
| 327 | /*! |
| 328 | */ |
| 329 | Setting::SecretFlags passwordRawFlags() const; |
| 330 | |
| 331 | /*! |
| 332 | * Set private key for this setting. |
| 333 | * |
| 334 | * \param key the key to be set. |
| 335 | * |
| 336 | * \warning key have to be null terminated or NetworkManager will refuse it. |
| 337 | */ |
| 338 | void setPrivateKey(const QByteArray &key); |
| 339 | /*! |
| 340 | */ |
| 341 | QByteArray privateKey() const; |
| 342 | |
| 343 | /*! |
| 344 | */ |
| 345 | void setPrivateKeyPassword(const QString &password); |
| 346 | /*! |
| 347 | */ |
| 348 | QString privateKeyPassword() const; |
| 349 | |
| 350 | /*! |
| 351 | */ |
| 352 | void setPrivateKeyPasswordFlags(Setting::SecretFlags flags); |
| 353 | /*! |
| 354 | */ |
| 355 | Setting::SecretFlags privateKeyPasswordFlags() const; |
| 356 | |
| 357 | /*! |
| 358 | */ |
| 359 | void setPhase2PrivateKey(const QByteArray &key); |
| 360 | /*! |
| 361 | */ |
| 362 | QByteArray phase2PrivateKey() const; |
| 363 | |
| 364 | /*! |
| 365 | */ |
| 366 | void setPhase2PrivateKeyPassword(const QString &password); |
| 367 | /*! |
| 368 | */ |
| 369 | QString phase2PrivateKeyPassword() const; |
| 370 | |
| 371 | /*! |
| 372 | */ |
| 373 | void setPhase2PrivateKeyPasswordFlags(Setting::SecretFlags flags); |
| 374 | /*! |
| 375 | */ |
| 376 | Setting::SecretFlags phase2PrivateKeyPasswordFlags() const; |
| 377 | |
| 378 | /*! |
| 379 | */ |
| 380 | void setPin(const QString &pin); |
| 381 | /*! |
| 382 | */ |
| 383 | QString pin() const; |
| 384 | |
| 385 | /*! |
| 386 | */ |
| 387 | void setPinFlags(Setting::SecretFlags flags); |
| 388 | /*! |
| 389 | */ |
| 390 | Setting::SecretFlags pinFlags() const; |
| 391 | |
| 392 | /*! |
| 393 | */ |
| 394 | void setSystemCaCertificates(bool use); |
| 395 | /*! |
| 396 | */ |
| 397 | bool systemCaCertificates() const; |
| 398 | |
| 399 | QStringList needSecrets(bool requestNew = false) const override; |
| 400 | |
| 401 | void secretsFromMap(const QVariantMap &secrets) override; |
| 402 | |
| 403 | QVariantMap secretsToMap() const override; |
| 404 | |
| 405 | void fromMap(const QVariantMap &setting) override; |
| 406 | |
| 407 | QVariantMap toMap() const override; |
| 408 | |
| 409 | protected: |
| 410 | Security8021xSettingPrivate *const d_ptr; |
| 411 | |
| 412 | private: |
| 413 | Q_DECLARE_PRIVATE(Security8021xSetting) |
| 414 | }; |
| 415 | |
| 416 | NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Security8021xSetting &setting); |
| 417 | |
| 418 | } |
| 419 | |
| 420 | #endif // NETWORKMANAGERQT_SECURITY802X_SETTING_H |
| 421 | |