~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to solid/control/solid/control/authentication.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-31 19:16:54 UTC
  • Revision ID: james.westby@ubuntu.com-20071031191654-xuof6e1jg6uxqaze
Tags: 3.95.0-0ubuntu1~gutsy1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
4
 
 
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.
8
 
 
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.
13
 
 
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.
18
 
 
19
 
*/
20
 
 
21
 
#ifndef SOLID_AUTHENTICATION_H
22
 
#define SOLID_AUTHENTICATION_H
23
 
 
24
 
#include <solid/control/ifaces/authentication.h>
25
 
 
26
 
namespace Solid
27
 
{
28
 
namespace Control
29
 
{
30
 
    /**
31
 
     * Base class for wireless authentication schemes.  No need to instantiate this
32
 
     */
33
 
    class SOLIDCONTROL_EXPORT Authentication
34
 
    {
35
 
    public:
36
 
        typedef QMap<QString, QString> SecretMap;
37
 
 
38
 
        Authentication();
39
 
        virtual ~Authentication();
40
 
 
41
 
        /**
42
 
         * All the authentication's secrets are stored in this map.
43
 
         * These can be plaintext passwords, hashed passwords, certificate passphrases
44
 
         */
45
 
        void setSecrets(const SecretMap &);
46
 
        /**
47
 
         * retrieve the map containing secrets.
48
 
         */
49
 
        SecretMap secrets() const;
50
 
 
51
 
    private:
52
 
        class Private;
53
 
        Private * const d;
54
 
    };
55
 
 
56
 
    /**
57
 
     * This Authentication is a null authentication.  Used for open networks
58
 
     */
59
 
    class SOLIDCONTROL_EXPORT AuthenticationNone : public Authentication
60
 
    {
61
 
    public:
62
 
        AuthenticationNone();
63
 
        virtual ~AuthenticationNone();
64
 
 
65
 
    private:
66
 
        class Private;
67
 
        Private * const d;
68
 
    };
69
 
 
70
 
    /**
71
 
     * WEP (Wired Equivalent Privacy) Authentication.
72
 
     * Better than prayer for protecting your data, but not much.
73
 
     */
74
 
    class SOLIDCONTROL_EXPORT AuthenticationWep : public Authentication
75
 
    {
76
 
    public:
77
 
        /**
78
 
         * Wep password type.  WepAscii and WepPassphrase are both hashed to WepHex using
79
 
         * standard algorithms, but are easier to remember.
80
 
         */
81
 
        enum WepType { WepAscii, WepHex, WepPassphrase };
82
 
        /**
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.
87
 
         */
88
 
        enum WepMethod { WepOpenSystem, WepSharedKey };
89
 
 
90
 
        AuthenticationWep();
91
 
        virtual ~AuthenticationWep();
92
 
 
93
 
        /**
94
 
         * Set the auth scheme in use
95
 
         */
96
 
        void setMethod(WepMethod);
97
 
        /**
98
 
         * Get the auth scheme in use
99
 
         */
100
 
        WepMethod method() const;
101
 
        /**
102
 
         * Set the password scheme in use
103
 
         */
104
 
        void setType(WepType);
105
 
        /**
106
 
         * Get the password scheme in use
107
 
         */
108
 
        WepType type() const;
109
 
        /**
110
 
         * Set the key length in bits
111
 
         * Valid values are 40 or 64 (equivalent)
112
 
         *                  104 or 128
113
 
         *                  192
114
 
         *                  256
115
 
         *                  other values (rare)
116
 
         */
117
 
        void setKeyLength(int);
118
 
        /**
119
 
         * Get the key length, in bits
120
 
         */
121
 
        int keyLength() const;
122
 
 
123
 
    private:
124
 
        class Private;
125
 
        Private * const d;
126
 
    };
127
 
 
128
 
    /**
129
 
     * AuthenticationWpa contains functionality shared by both Personal and Enterprise
130
 
     * authentication flavors
131
 
     */
132
 
    class SOLIDCONTROL_EXPORT AuthenticationWpa : public Authentication
133
 
    {
134
 
    public:
135
 
        /**
136
 
         * Possible Authentication schemes
137
 
         */
138
 
        enum WpaProtocol { WpaAuto, WpaTkip, WpaCcmpAes, // WPA Personal only
139
 
                           WpaEap /* WPA Enterprise only */ };
140
 
        /**
141
 
         * WPA Versions
142
 
         */
143
 
        enum WpaVersion { Wpa1, Wpa2 };
144
 
 
145
 
        /**
146
 
         * WPA key management schemes
147
 
         */
148
 
        enum WpaKeyManagement { WpaPsk, Wpa8021x };
149
 
 
150
 
        AuthenticationWpa();
151
 
        virtual ~AuthenticationWpa();
152
 
 
153
 
        /**
154
 
         * Set the protocol in use
155
 
         */
156
 
        void setProtocol(WpaProtocol);
157
 
        /**
158
 
         * Set the protocol in use
159
 
         */
160
 
        WpaProtocol protocol() const;
161
 
 
162
 
        /**
163
 
         * Set the WPA version
164
 
         */
165
 
        void setVersion(WpaVersion);
166
 
        /**
167
 
         * Get the WPA version
168
 
         */
169
 
        WpaVersion version() const;
170
 
 
171
 
        /**
172
 
         * Set the key management scheme
173
 
         */
174
 
        void setKeyManagement(WpaKeyManagement);
175
 
 
176
 
        /**
177
 
         * Get the key management scheme
178
 
         */
179
 
        WpaKeyManagement keyManagement() const;
180
 
 
181
 
    private:
182
 
        class Private;
183
 
        Private * const d;
184
 
    };
185
 
 
186
 
    /**
187
 
     * WPA Personal authentication.
188
 
     */
189
 
    class SOLIDCONTROL_EXPORT AuthenticationWpaPersonal : public AuthenticationWpa
190
 
    {
191
 
    public:
192
 
        AuthenticationWpaPersonal();
193
 
        virtual ~AuthenticationWpaPersonal();
194
 
 
195
 
    private:
196
 
        class Private;
197
 
        Private * const d;
198
 
    };
199
 
 
200
 
    /**
201
 
     * WPA Enterprise
202
 
     */
203
 
    class SOLIDCONTROL_EXPORT AuthenticationWpaEnterprise : public AuthenticationWpa
204
 
    {
205
 
    public:
206
 
        /**
207
 
         * Subtypes of Enterprise Authentication Protocol
208
 
         */
209
 
        enum EapMethod { EapPeap, EapTls, EapTtls, EapMd5, EapMsChap, EapOtp, EapGtc };
210
 
        AuthenticationWpaEnterprise();
211
 
        virtual ~AuthenticationWpaEnterprise();
212
 
 
213
 
        /**
214
 
         * TODO: check with thoenig what this means - probably identity off one of the certs
215
 
         */
216
 
        void setIdentity(const QString  &);
217
 
        /**
218
 
         * TODO: check with thoenig what this means - probably identity off one of the certs
219
 
         */
220
 
        QString identity() const;
221
 
 
222
 
        /**
223
 
         * TODO: check with thoenig what this means - probably identity off one of the certs
224
 
         */
225
 
        void setAnonIdentity(const QString  &);
226
 
        /**
227
 
         * TODO: check with thoenig what this means - probably identity off one of the certs
228
 
         */
229
 
        QString anonIdentity() const;
230
 
 
231
 
        /**
232
 
         * Set path to the client certificate
233
 
         */
234
 
        void setCertClient(const QString  &);
235
 
        /**
236
 
         * Get path to the client certificate
237
 
         */
238
 
        QString certClient() const;
239
 
        /**
240
 
         * Set path to the certification authority certificate
241
 
         */
242
 
        void setCertCA(const QString  &);
243
 
        /**
244
 
         * Get path to the certification authority certificate
245
 
         */
246
 
        QString certCA() const;
247
 
 
248
 
        /**
249
 
         * Set path to the private certificate
250
 
         */
251
 
        void setCertPrivate(const QString  &);
252
 
        /**
253
 
         * Get path to the private certificate
254
 
         */
255
 
        QString certPrivate() const;
256
 
        /**
257
 
         * Set the EAP method
258
 
         */
259
 
        void setMethod(EapMethod);
260
 
        /**
261
 
         * Get the EAP method
262
 
         */
263
 
        EapMethod method() const;
264
 
        /**
265
 
         * Set the ID password key (helper method)
266
 
         */
267
 
        void setIdPasswordKey(const QString  &);
268
 
        /**
269
 
         * Set the ID password key (helper method)
270
 
         */
271
 
        QString idPasswordKey() const;
272
 
 
273
 
        /**
274
 
         * Set the private certificate password key (helper method)
275
 
         */
276
 
        void setCertPrivatePasswordKey(const QString  &);
277
 
        /**
278
 
         * Get the private certificate password key (helper method)
279
 
         */
280
 
        QString certPrivatePasswordKey() const;
281
 
 
282
 
    private:
283
 
        class Private;
284
 
        Private * const d;
285
 
    };
286
 
 
287
 
    /**
288
 
     * Utility class
289
 
     * Contains a backend specific validator instance to validate authentication
290
 
     * Can be used for example to authenticate user input as they type
291
 
     */
292
 
    class SOLIDCONTROL_EXPORT AuthenticationValidator
293
 
    {
294
 
        public:
295
 
            AuthenticationValidator();
296
 
            virtual ~AuthenticationValidator();
297
 
            /**
298
 
             * Call this to check if an authentication is valid
299
 
             * (All secrets present, passphrase length correct
300
 
             */
301
 
            bool validate(const Authentication *);
302
 
        private:
303
 
            class Private;
304
 
            Private * const d;
305
 
    };
306
 
}
307
 
}
308
 
 
309
 
#endif