1 /* This file is part of the KDE project
2 Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
3 Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #ifndef SOLID_CONTROL_AUTHENTICATION_H
22 #define SOLID_CONTROL_AUTHENTICATION_H
24 #include <solid/control/ifaces/authentication.h>
31 * Base class for wireless authentication schemes. No need to instantiate this
33 class SOLIDCONTROL_EXPORT Authentication
36 typedef QMap
<QString
, QString
> SecretMap
;
39 virtual ~Authentication();
42 * All the authentication's secrets are stored in this map.
43 * These can be plaintext passwords, hashed passwords, certificate passphrases
45 void setSecrets(const SecretMap
&);
47 * retrieve the map containing secrets.
49 SecretMap
secrets() const;
57 * This Authentication is a null authentication. Used for open networks
59 class SOLIDCONTROL_EXPORT AuthenticationNone
: public Authentication
63 virtual ~AuthenticationNone();
71 * WEP (Wired Equivalent Privacy) Authentication.
72 * Better than prayer for protecting your data, but not much.
74 class SOLIDCONTROL_EXPORT AuthenticationWep
: public Authentication
78 * Wep password type. WepAscii and WepPassphrase are both hashed to WepHex using
79 * standard algorithms, but are easier to remember.
81 enum WepType
{ WepAscii
, WepHex
, WepPassphrase
};
83 * Authentication schemes
84 * Open System has no authentication, if you have the encryption key, you are able to use the network
85 * Shared Key means that the station must know a secret key to authenticate to the network.
86 * Not sure if the same key is used for both Auth and Encryption though.
88 enum WepMethod
{ WepOpenSystem
, WepSharedKey
};
91 virtual ~AuthenticationWep();
94 * Set the auth scheme in use
96 void setMethod(WepMethod
);
98 * Get the auth scheme in use
100 WepMethod
method() const;
102 * Set the password scheme in use
104 void setType(WepType
);
106 * Get the password scheme in use
108 WepType
type() const;
110 * Set the key length in bits
111 * Valid values are 40 or 64 (equivalent)
115 * other values (rare)
117 void setKeyLength(int);
119 * Get the key length, in bits
121 int keyLength() const;
129 * AuthenticationWpa contains functionality shared by both Personal and Enterprise
130 * authentication flavors
132 class SOLIDCONTROL_EXPORT AuthenticationWpa
: public Authentication
136 * Possible Authentication schemes
138 enum WpaProtocol
{ WpaAuto
, WpaTkip
, WpaCcmpAes
, // WPA Personal only
139 WpaEap
/* WPA Enterprise only */ };
143 enum WpaVersion
{ Wpa1
, Wpa2
};
146 * WPA key management schemes
148 enum WpaKeyManagement
{ WpaPsk
, Wpa8021x
};
151 virtual ~AuthenticationWpa();
154 * Set the protocol in use
156 void setProtocol(WpaProtocol
);
158 * Set the protocol in use
160 WpaProtocol
protocol() const;
163 * Set the WPA version
165 void setVersion(WpaVersion
);
167 * Get the WPA version
169 WpaVersion
version() const;
172 * Set the key management scheme
174 void setKeyManagement(WpaKeyManagement
);
177 * Get the key management scheme
179 WpaKeyManagement
keyManagement() const;
187 * WPA Personal authentication.
189 class SOLIDCONTROL_EXPORT AuthenticationWpaPersonal
: public AuthenticationWpa
192 AuthenticationWpaPersonal();
193 virtual ~AuthenticationWpaPersonal();
203 class SOLIDCONTROL_EXPORT AuthenticationWpaEnterprise
: public AuthenticationWpa
207 * Subtypes of Enterprise Authentication Protocol
209 enum EapMethod
{ EapPeap
, EapTls
, EapTtls
, EapMd5
, EapMsChap
, EapOtp
, EapGtc
};
210 AuthenticationWpaEnterprise();
211 virtual ~AuthenticationWpaEnterprise();
214 * TODO: check with thoenig what this means - probably identity off one of the certs
216 void setIdentity(const QString
&);
218 * TODO: check with thoenig what this means - probably identity off one of the certs
220 QString
identity() const;
223 * TODO: check with thoenig what this means - probably identity off one of the certs
225 void setAnonIdentity(const QString
&);
227 * TODO: check with thoenig what this means - probably identity off one of the certs
229 QString
anonIdentity() const;
232 * Set path to the client certificate
234 void setCertClient(const QString
&);
236 * Get path to the client certificate
238 QString
certClient() const;
240 * Set path to the certification authority certificate
242 void setCertCA(const QString
&);
244 * Get path to the certification authority certificate
246 QString
certCA() const;
249 * Set path to the private certificate
251 void setCertPrivate(const QString
&);
253 * Get path to the private certificate
255 QString
certPrivate() const;
259 void setMethod(EapMethod
);
263 EapMethod
method() const;
265 * Set the ID password key (helper method)
267 void setIdPasswordKey(const QString
&);
269 * Set the ID password key (helper method)
271 QString
idPasswordKey() const;
274 * Set the private certificate password key (helper method)
276 void setCertPrivatePasswordKey(const QString
&);
278 * Get the private certificate password key (helper method)
280 QString
certPrivatePasswordKey() const;
289 * Contains a backend specific validator instance to validate authentication
290 * Can be used for example to authenticate user input as they type
292 class SOLIDCONTROL_EXPORT AuthenticationValidator
295 AuthenticationValidator();
296 virtual ~AuthenticationValidator();
298 * Call this to check if an authentication is valid
299 * (All secrets present, passphrase length correct
301 bool validate(const Authentication
*);