summaryrefslogtreecommitdiffstats
path: root/kio/kssl/ksslinfodlg.h
blob: b7ff3d2eb5ca03f6ee00fca00995b04b9defc24b (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
/* This file is part of the KDE project
 *
 * Copyright (C) 2000-2003 George Staikos <staikos@kde.org>
 * Copyright (C) 2000 Malte Starostik <malte@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef _KSSLINFODLG_H
#define _KSSLINFODLG_H

#include <kdialog.h>

#include "ksslx509map.h"
#include "ksslcertificate.h"
#include "kssl.h"
#include <qscrollview.h>

class QWidget;
class KSSLCertBox;
class KSSLCertChain;


/**
 * KDE SSL Information Dialog
 *
 * This class creates a dialog that can be used to display information about
 * an SSL session.
 *
 * There are NO GUARANTEES that KSSLInfoDlg will remain binary compatible/
 * Contact staikos@kde.org for details if needed.
 *
 * @author George Staikos <staikos@kde.org>
 * @see KSSL
 * @short KDE SSL Information Dialog
 */
class KIO_EXPORT KSSLInfoDlg : public KDialog {
	Q_OBJECT
public:
	/**
	 *  Construct a KSSL Information Dialog
	 *
	 *  @param secureConnection true if the connection is secured with SSL
	 *  @param parent the parent widget
	 *  @param name the internal name of this instance
	 *  @param modal true if the dialog should be modal
	 */
	KSSLInfoDlg(bool secureConnection, QWidget *parent=0L, const char *name=0L, bool modal=false);

	/**
	 *  Destroy this dialog
	 */
	virtual ~KSSLInfoDlg();

	/**
	 *  Tell the dialog if the connection has portions that may not be
	 *  secure (ie. a mixture of secure and insecure frames)
	 *
	 *  @param isIt true if security is in question
	 */
	void setSecurityInQuestion(bool isIt);

	/**
	 *  Setup the dialog before showing it.
	 *
	 *  @param cert the certificate presented by the site
	 *  @param ip the ip of the remote host
	 *  @param url the url being accessed
	 *  @param cipher the cipher in use
	 *  @param cipherdesc text description of the cipher in use
	 *  @param sslversion the version of SSL in use (SSLv2, SSLv3, TLSv1, etc)
	 *  @param usedbits the number of bits in the cipher key being used
	 *  @param bits the bit-size of the cipher in use
	 *  @param certState the certificate state (valid, invalid, etc)
	 */
	void setup(KSSLCertificate *cert,
			const QString& ip, const QString& url,
			const QString& cipher, const QString& cipherdesc,
			const QString& sslversion, int usedbits, int bits,
			KSSLCertificate::KSSLValidation certState);

	/**
	 *  Setup the dialog before showing it.  This is a convenience version
	 *  of the above method, and obtains the same information using the
	 *  @param ssl parameter instead.
	 *
	 *  @param ssl the ssl connection
	 *  @param ip the ip of the remote host
	 *  @param url the url being accessed
	 */
	void setup( KSSL & ssl, const QString & ip, const QString & url );

        /**
         *  Set the errors that were encountered while validating the site 
         *  certificate.
         */
        void setCertState(const QString &errorNrs);

	/**
	 *  Utility function to generate the widget which displays the detailed
	 *  information about an X.509 certificate.
	 *
	 *  @param parent the parent widget
	 *  @param certName the name (subject) of the certificate
	 *  @param mailCatcher the class which catches click events on e-mail
	 *         addresses
	 */
	static KSSLCertBox *certInfoWidget(QWidget *parent, const QString &certName, QWidget *mailCatcher=0);

private:
	QScrollView *buildCertInfo(const QString &certName);
	void displayCert(KSSLCertificate *x);

	class KSSLInfoDlgPrivate;
	KSSLInfoDlgPrivate *d;

private slots:
	void launchConfig();
	void urlClicked(const QString &url);
	void mailClicked(const QString &url);
	void slotChain(int x);
};


/**
 * KDE SSL Certificate Box
 *
 * This class creates a widget which formats and displays the contents of an
 * SSL X.509 certificate.  That is, it takes the "subject" of the certificate
 * and displays everything contained therein.
 *
 * @author George Staikos <staikos@kde.org>
 * @see KSSLInfoDlg
 * @short KDE SSL Certificate Box
 */
class KIO_EXPORT KSSLCertBox : public QScrollView {
public:
	/**
	 *  Construct a certificate box
	 *
	 *  @param parent the parent widget
	 *  @param name the internal name of this instance
	 *  @param f widget flags for the object
	 */
	KSSLCertBox(QWidget *parent=0L, const char *name=0L, WFlags f=0);

	/**
	 *  Change the contents of the widget
	 *
	 *  @param certName the name ("subject") of the certificate
	 *  @param mailCatcher the widget which catches the url open events
	 */
	void setValues(QString certName, QWidget *mailCatcher=0L);

private:
	QFrame *_frame;
};

#endif