summaryrefslogtreecommitdiffstats
path: root/kcontrol/crypto/crypto.h
blob: 7f1b1d21c8c51a0d032cb62da7bc4d254be86425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/**
 * crypto.h
 *
 * Copyright (c) 2000-2001 George Staikos <staikos@kde.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef _CRYPTO_H
#define _CRYPTO_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqcheckbox.h>
#include <tqdatetime.h>
#include <tqlineedit.h>
#include <tqlistview.h>
#include <tqptrlist.h>
#include <tqtabwidget.h>
#include <tqvbuttongroup.h>

#include <kcmodule.h>
#include <ksimpleconfig.h>

class TQGridLayout;
class TQVButtonGroup;

class KComboBox;
class KCryptoConfig;
class KPushButton;
class KSSLCertBox;
class KSSLSigners;
class KURLLabel;
class KURLRequester;

class CipherItem : public QCheckListItem
{
public:
    CipherItem( TQListView *view, const TQString& cipher, int bits, int maxBits,
		KCryptoConfig *module );
    ~CipherItem() {}

    void setCipher( const TQString& cipher ) { m_cipher = cipher; }
    const TQString& cipher() const { return m_cipher; }
    void setBits( int bits ) { m_bits = bits; }
    int bits() const { return m_bits; }

    TQString configName() const;

protected:
    virtual void stateChange( bool );

private:
    int m_bits;
    TQString m_cipher;
    KCryptoConfig *m_module; // just to call configChanged()
};



class OtherCertItem : public QListViewItem
{
public:
    OtherCertItem(TQListView *view, const TQString& sub, const TQString& md5, bool perm, int policy, TQDateTime exp, KCryptoConfig *module );
    ~OtherCertItem() {}

    TQString configName() const;
    const TQString& getSub() { return _sub; }
    int getPolicy() { return _policy; }
    const TQString& getMD5() { return _md5; }
    bool isPermanent() { return _perm; }
    TQDateTime getExpires() { return _exp; }
    void setPolicy(int x) { _policy = x; }
    void setPermanent(bool x) { _perm = x; }
    void setExpires(TQDateTime x) { _exp = x; }

protected:
    virtual void stateChange( bool );

private:
    TQString _sub, _md5;
    KCryptoConfig *m_module; // just to call configChanged()
    TQDateTime _exp;
    bool _perm;
    int _policy;
};




class YourCertItem : public QListViewItem
{
public:
    YourCertItem(TQListView *view, TQString pkcs, TQString pass, TQString name, KCryptoConfig *module );
    ~YourCertItem() {}

    TQString configName() const;
    TQString& getPKCS() { return _pkcs; }
    void setPKCS(TQString pkcs) { _pkcs = pkcs; }
    TQString& getPass() { return _pass; }
    void setPass(TQString pass) { _pass = pass; }
    TQString& getName() { return _name; }
    void setName(TQString name) { _name = name; }
    TQString& getPassCache() { return _cpass; }
    void setPassCache(TQString pass) { _cpass = pass; }

protected:
    virtual void stateChange( bool );

private:
    TQString _pkcs;
    TQString _pass;
    TQString _cpass;
    TQString _name;
    KCryptoConfig *m_module; // just to call configChanged()
};




class CAItem : public QListViewItem
{
public:
    CAItem(TQListView *view, TQString name, TQString cert, bool site, bool email, bool code, KCryptoConfig *module );
    ~CAItem() {}

    TQString configName() const;
    TQString& getName() { return _name; }
    void setName(TQString name) { _name = name; }

    inline TQString getCert() const { return _cert; }
    inline bool getSite() const { return _site; }
    inline bool getEmail() const { return _email; }
    inline bool getCode() const { return _code; }
    inline void setSite(bool x) { _site = x; }
    inline void setEmail(bool x) { _email = x; }
    inline void setCode(bool x) { _code = x; }

    bool isNew, modified;

protected:
    virtual void stateChange( bool );

private:
    TQString _name;
    TQString _cert;
    bool _site, _email, _code;
    KCryptoConfig *m_module; // just to call configChanged()
};





class HostAuthItem : public QListViewItem
{
public:
    HostAuthItem(TQListView *view, TQString host, TQString name, KCryptoConfig *module ) : TQListViewItem(view, TQString::null ) {
                               _name = name;  _host = host;
                               m_module = module;
                               setText(0, _host);
                               setText(1, _name);
                               _oname = TQString::null;
                              }
    ~HostAuthItem() {}

    void setAction(KSSLCertificateHome::KSSLAuthAction aa) {
                 _aa = aa;
                               switch (aa) {
                               case KSSLCertificateHome::AuthSend:
                                 setText(2, i18n("Send"));
                                break;
                               case KSSLCertificateHome::AuthDont:
                                 setText(2, i18n("Don't Send"));
                                break;
                               case KSSLCertificateHome::AuthPrompt:
                                 setText(2, i18n("Prompt"));
                                break;
                               default:
                                break;
                               }
    }
    KSSLCertificateHome::KSSLAuthAction getAction() const { return _aa; }
    TQString configName() const { return _host; }
    TQString getCertName() const { return _name; }
    void setCertName(TQString name) { _name = name; setText(1, name); }
    void setHost(TQString name) { _host = name; setText(0, name); }
    void setOriginalName(TQString oname) { _oname = oname; }
    TQString originalName() const { return _oname; }

protected:

private:
    TQString _host;
    TQString _name, _oname;
    KSSLCertificateHome::KSSLAuthAction _aa;
    KCryptoConfig *m_module; // just to call configChanged()
};





class KCryptoConfig : public KCModule
{
  Q_OBJECT
public:
  KCryptoConfig(TQWidget *parent = 0L, const char *name = 0L, const TQStringList &list = TQStringList());
  virtual ~KCryptoConfig();

  void load();
  void load( bool useDefaults );
  void save();
  void defaults();

#ifdef HAVE_SSL
  bool loadCiphers();
#endif

public slots:
  void configChanged();

  void slotGeneratePersonal();
  void slotUseEGD();
  void slotUseEFile();
  void slotSelectCipher(int id);

  void slotTestOSSL();

  void slotExportCert();
  void slotRemoveCert();
  void slotVerifyCert();
  void slotOtherCertSelect();
  void slotPolicyChanged(int id);
  void slotPermanent();
  void slotUntil();
  void slotDatePick();

  void slotYourImport();
  void slotYourExport();
  void slotYourVerify();
  void slotYourRemove();
  void slotYourUnlock();
  void slotYourPass();
  void slotYourCertSelect();

  void slotNewHostAuth();
  void slotRemoveHostAuth();
  void slotAuthItemChanged();
  void slotAuthText(const TQString &t);
  void slotAuthButtons();
  void slotAuthCombo();

  void slotCAImport();
  void slotCARemove();
  void slotCARestore();
  void slotCAItemChanged();
  void slotCAChecked();

protected:
  void cwCompatible();
  void cwUS();
  void cwExp();
  void cwAll();

private:

  void offerImportToKMail( const TQString& certFile );
  void setAuthCertLists();
  void genCAList();

  TQTabWidget *tabs;
  TQWidget *tabSSL, *tabOSSL;

  TQWidget *tabYourSSLCert, *tabOtherSSLCert, *tabSSLCA, *tabSSLCOpts, *tabAuth;

  TQListView *SSLv2Box, *SSLv3Box;
  TQCheckBox *mUseTLS, *mUseSSLv2, *mUseSSLv3;
  TQCheckBox *mWarnOnEnter, *mWarnOnLeave;

  /* EGD stuff */
  TQLabel        *mEGDLabel;
  KURLRequester *mEGDPath;
  TQCheckBox     *mUseEGD;
  TQCheckBox     *mUseEFile;

  /* CipherWizards */
  TQPushButton *mCWall, *mCWus, *mCWexp, *mCWcompatible;

  TQCheckBox *mWarnOnUnencrypted, *mWarnOnMixed;
  TQListView *yourSSLBox, *otherSSLBox, *caList;
  TQCheckBox *mWarnSelfSigned, *mWarnExpired, *mWarnRevoked;
  TQPushButton *macAdd, *macRemove;
  KPushButton *macClear;
  TQListBox *macBox;
  TQPushButton *otherSSLExport, *otherSSLView, *otherSSLRemove, *otherSSLVerify;
  TQPushButton *yourSSLImport, *yourSSLPass, *yourSSLRemove, *yourSSLExport,
              *yourSSLUnlock, *yourSSLVerify;
  TQRadioButton *yourSSLUseDefault, *yourSSLList, *yourSSLDont;
  TQLineEdit *macCert;
  KSSLCertBox *oSubject, *oIssuer;
  KSSLCertBox *ySubject, *yIssuer;
  TQGridLayout *oGrid;

  TQVButtonGroup *policyGroup;
  TQVButtonGroup *cacheGroup;
  TQRadioButton *policyAccept, *policyReject, *policyPrompt;
  TQRadioButton *cacheUntil, *cachePerm;
  TQLabel *fromLabel, *untilLabel;
  TQLabel *validFrom, *validUntil;
  TQLabel *yValidFrom, *yValidUntil;
  KURLLabel *untilDate;

  TQVGroupBox  *oInfo;
  KURLRequester *oPath;
  TQPushButton *oTest;
  TQPtrList<OtherCertItem> otherCertDelList;
  TQPtrList<YourCertItem> yourCertDelList;
  TQPtrList<CAItem> caDelList;

  /* Personal Cert Policies tab */
  KComboBox *defCertBox;
  KComboBox *hostCertBox;
  TQVButtonGroup *defCertBG;
  TQHButtonGroup *hostCertBG;
  TQRadioButton *defSend, *defPrompt, *defDont;
  TQRadioButton *hostSend, *hostPrompt, *hostDont;
  TQListView *hostAuthList;
  TQPushButton *authAdd, *authRemove;
  TQLineEdit *authHost;
  TQPtrList<HostAuthItem> authDelList;
  TQLabel *yHash, *pHash;

  /* CA stuff */
  KSSLCertBox *caSubject, *caIssuer;
  TQPushButton *caSSLImport, *caSSLRemove, *caSSLRestore;
  TQCheckBox *caSite, *caEmail, *caCode;
  KSSLSigners *_signers;
  TQLabel *cHash;

  KConfig *config;
  KSimpleConfig *policies, *pcerts, *authcfg;
  KConfig *cacfg;

  bool ___lehack;       // to hack around a lineedit problem
};

#endif