File indexing completed on 2024-04-21 15:06:21

0001 /*
0002     SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef NETWORKMANAGERQT_SECURITY8021X_SETTING_H
0008 #define NETWORKMANAGERQT_SECURITY8021X_SETTING_H
0009 
0010 #include "setting.h"
0011 #include <networkmanagerqt/networkmanagerqt_export.h>
0012 
0013 namespace NetworkManager
0014 {
0015 class Security8021xSettingPrivate;
0016 
0017 /**
0018  * Represents 802.1x wireless security setting
0019  */
0020 class NETWORKMANAGERQT_EXPORT Security8021xSetting : public Setting
0021 {
0022 public:
0023     typedef QSharedPointer<Security8021xSetting> Ptr;
0024     typedef QList<Ptr> List;
0025     enum EapMethod {
0026         EapMethodUnknown = 0,
0027         EapMethodLeap,
0028         EapMethodMd5,
0029         EapMethodTls,
0030         EapMethodPeap,
0031         EapMethodTtls,
0032         EapMethodSim,
0033         EapMethodFast,
0034         EapMethodPwd,
0035     };
0036     enum PeapVersion {
0037         PeapVersionUnknown = -1,
0038         PeapVersionZero,
0039         PeapVersionOne,
0040     };
0041     enum PeapLabel {
0042         PeapLabelUnknown = 0,
0043         PeapLabelForce,
0044     };
0045     enum FastProvisioning {
0046         FastProvisioningUnknown = -1,
0047         FastProvisioningDisabled,
0048         FastProvisioningAllowUnauthenticated,
0049         FastProvisioningAllowAuthenticated,
0050         FastProvisioningAllowBoth,
0051     };
0052     enum AuthMethod {
0053         AuthMethodUnknown = 0,
0054         AuthMethodPap,
0055         AuthMethodChap,
0056         AuthMethodMschap,
0057         AuthMethodMschapv2,
0058         AuthMethodGtc,
0059         AuthMethodOtp,
0060         AuthMethodMd5,
0061         AuthMethodTls,
0062     };
0063     enum AuthEapMethod {
0064         AuthEapMethodUnknown = 0,
0065         AuthEapMethodMd5,
0066         AuthEapMethodMschapv2,
0067         AuthEapMethodOtp,
0068         AuthEapMethodGtc,
0069         AuthEapMethodTls,
0070     };
0071 
0072     Security8021xSetting();
0073     explicit Security8021xSetting(const Ptr &other);
0074     ~Security8021xSetting() override;
0075 
0076     QString name() const override;
0077 
0078     void setEapMethods(const QList<EapMethod> &methods);
0079     QList<EapMethod> eapMethods() const;
0080 
0081     void setIdentity(const QString &identity);
0082     QString identity() const;
0083 
0084     void setAnonymousIdentity(const QString &identity);
0085     QString anonymousIdentity() const;
0086 
0087     void setDomainSuffixMatch(const QString &domainSuffixMatch);
0088     QString domainSuffixMatch() const;
0089 
0090     /**
0091      * Set UTF-8 encoded file path containing PAC for EAP-FAST.
0092      *
0093      * \param filePath file path to be set.
0094      */
0095     void setPacFile(const QString &filePath);
0096     QString pacFile() const;
0097 
0098     /**
0099      * Set certificate authority (ca)'s certificate for this setting.
0100      *
0101      * \param certificate certificate's file path encoded into a byte array.
0102      *
0103      * \warning certificate have to be null terminated or NetworkManager will refuse it.
0104      */
0105     void setCaCertificate(const QByteArray &certificate);
0106     QByteArray caCertificate() const;
0107 
0108     void setCaPath(const QString &path);
0109     QString caPath() const;
0110 
0111     void setSubjectMatch(const QString &substring);
0112     QString subjectMatch() const;
0113 
0114     void setAltSubjectMatches(const QStringList &strings);
0115     QStringList altSubjectMatches() const;
0116 
0117     /**
0118      * Set client certificate for this setting.
0119      *
0120      * \param certificate certificate's file path encoded into a byte array.
0121      *
0122      * \warning certificate have to be null terminated or NetworkManager will refuse it.
0123      */
0124     void setClientCertificate(const QByteArray &certificate);
0125     QByteArray clientCertificate() const;
0126 
0127     void setPhase1PeapVersion(PeapVersion version);
0128     PeapVersion phase1PeapVersion() const;
0129 
0130     void setPhase1PeapLabel(PeapLabel label);
0131     PeapLabel phase1PeapLabel() const;
0132 
0133     void setPhase1FastProvisioning(FastProvisioning provisioning);
0134     FastProvisioning phase1FastProvisioning() const;
0135 
0136     void setPhase2AuthMethod(AuthMethod method);
0137     AuthMethod phase2AuthMethod() const;
0138 
0139     void setPhase2AuthEapMethod(AuthEapMethod method);
0140     AuthEapMethod phase2AuthEapMethod() const;
0141 
0142     /**
0143      * Contains the CA certificate if used by the EAP method specified in the
0144      * phase2AuthMethod() or phase2AuthEapMethod() properties.
0145      *
0146      * \param certificate certificate's file path encoded into a byte array.
0147      *
0148      * \warning certificate have to be null terminated or NetworkManager will refuse it.
0149      */
0150     void setPhase2CaCertificate(const QByteArray &certificate);
0151     QByteArray phase2CaCertificate() const;
0152 
0153     void setPhase2CaPath(const QString &path);
0154     QString phase2CaPath() const;
0155 
0156     void setPhase2SubjectMatch(const QString &substring);
0157     QString phase2SubjectMatch() const;
0158 
0159     void setPhase2AltSubjectMatches(const QStringList &strings);
0160     QStringList phase2AltSubjectMatches() const;
0161 
0162     void setPhase2ClientCertificate(const QByteArray &certificate);
0163     QByteArray phase2ClientCertificate() const;
0164 
0165     void setPassword(const QString &password);
0166     QString password() const;
0167 
0168     void setPasswordFlags(Setting::SecretFlags flags);
0169     Setting::SecretFlags passwordFlags() const;
0170 
0171     void setPasswordRaw(const QByteArray &password);
0172     QByteArray passwordRaw() const;
0173 
0174     void setPasswordRawFlags(Setting::SecretFlags flags);
0175     Setting::SecretFlags passwordRawFlags() const;
0176 
0177     /**
0178      * Set private key for this setting.
0179      *
0180      * \param key the key to be set.
0181      *
0182      * \warning key have to be null terminated or NetworkManager will refuse it.
0183      */
0184     void setPrivateKey(const QByteArray &key);
0185     QByteArray privateKey() const;
0186 
0187     void setPrivateKeyPassword(const QString &password);
0188     QString privateKeyPassword() const;
0189 
0190     void setPrivateKeyPasswordFlags(Setting::SecretFlags flags);
0191     Setting::SecretFlags privateKeyPasswordFlags() const;
0192 
0193     void setPhase2PrivateKey(const QByteArray &key);
0194     QByteArray phase2PrivateKey() const;
0195 
0196     void setPhase2PrivateKeyPassword(const QString &password);
0197     QString phase2PrivateKeyPassword() const;
0198 
0199     void setPhase2PrivateKeyPasswordFlags(Setting::SecretFlags flags);
0200     Setting::SecretFlags phase2PrivateKeyPasswordFlags() const;
0201 
0202     void setPin(const QString &pin);
0203     QString pin() const;
0204 
0205     void setPinFlags(Setting::SecretFlags flags);
0206     Setting::SecretFlags pinFlags() const;
0207 
0208     void setSystemCaCertificates(bool use);
0209     bool systemCaCertificates() const;
0210 
0211     QStringList needSecrets(bool requestNew = false) const override;
0212 
0213     void secretsFromMap(const QVariantMap &secrets) override;
0214 
0215     QVariantMap secretsToMap() const override;
0216 
0217     void fromMap(const QVariantMap &setting) override;
0218 
0219     QVariantMap toMap() const override;
0220 
0221 protected:
0222     Security8021xSettingPrivate *const d_ptr;
0223 
0224 private:
0225     Q_DECLARE_PRIVATE(Security8021xSetting)
0226 };
0227 
0228 NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Security8021xSetting &setting);
0229 
0230 }
0231 
0232 #endif // NETWORKMANAGERQT_SECURITY802X_SETTING_H