• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/kssl
 

tdeio/kssl

  • tdeio
  • kssl
ksslcertificatehome.cpp
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2000-2005 George Staikos <staikos@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 as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include <ksslcertificatehome.h>
22#include <ksslcertificate.h>
23#include <ksslpkcs12.h>
24
25#include <kresolver.h>
26#include <ksimpleconfig.h>
27
28using namespace KNetwork;
29
30TQStringList KSSLCertificateHome::getCertificateList() {
31KSimpleConfig cfg("ksslcertificates", false);
32TQStringList list = cfg.groupList();
33TQString defaultstr("<default>");
34TQString blankstr("");
35
36list.remove(defaultstr);
37list.remove(blankstr);
38
39return list;
40}
41
42
43// KDE 4: make it const TQString &
44void KSSLCertificateHome::setDefaultCertificate(TQString name, TQString host, bool send, bool prompt) {
45KSimpleConfig cfg("ksslauthmap", false);
46
47#ifdef TQ_WS_WIN //temporary
48 cfg.setGroup(host);
49#else
50 cfg.setGroup(KResolver::domainToAscii(host));
51#endif
52 cfg.writeEntry("certificate", name);
53 cfg.writeEntry("send", send);
54 cfg.writeEntry("prompt", prompt);
55 cfg.sync();
56}
57
58
59// KDE 4: make it const TQString &
60void KSSLCertificateHome::setDefaultCertificate(KSSLPKCS12 *cert, TQString host, bool send, bool prompt) {
61 if (cert)
62 KSSLCertificateHome::setDefaultCertificate(cert->name(), host, send, prompt);
63}
64
65
66// KDE 4: make it const TQString &
67bool KSSLCertificateHome::addCertificate(TQString filename, TQString password, bool storePass) {
68KSSLPKCS12 *pkcs = KSSLPKCS12::loadCertFile(filename, password);
69
70 if (!pkcs) return false;
71
72 KSSLCertificateHome::addCertificate(pkcs, storePass?password:TQString(""));
73 delete pkcs;
74
75return true;
76}
77
78
79// KDE 4: make it const TQString &
80bool KSSLCertificateHome::addCertificate(KSSLPKCS12 *cert, TQString passToStore) {
81 if (!cert) return false;
82
83KSimpleConfig cfg("ksslcertificates", false);
84
85 cfg.setGroup(cert->name());
86 cfg.writeEntry("PKCS12Base64", cert->toString());
87 cfg.writeEntry("Password", passToStore);
88 cfg.sync();
89return true;
90}
91
92bool KSSLCertificateHome::deleteCertificate(const TQString &filename, const TQString &password) {
93KSSLPKCS12 *pkcs = KSSLPKCS12::loadCertFile(filename, password);
94
95 if (!pkcs) return false;
96
97 bool ok = deleteCertificate(pkcs);
98 delete pkcs;
99
100return ok;
101}
102
103bool KSSLCertificateHome::deleteCertificate(KSSLPKCS12 *cert) {
104 if (!cert) return false;
105
106 return deleteCertificateByName(cert->name());
107}
108
109bool KSSLCertificateHome::deleteCertificateByName(const TQString &name) {
110 if (name.isEmpty()) return false;
111
112KSimpleConfig cfg("ksslcertificates", false);
113
114 bool ok = cfg.deleteGroup(name);
115 cfg.sync();
116
117return ok;
118}
119
120// KDE 4: make it const TQString &
121KSSLPKCS12* KSSLCertificateHome::getCertificateByName(TQString name, TQString password) {
122KSimpleConfig cfg("ksslcertificates", false);
123 if (!cfg.hasGroup(name)) return NULL;
124
125 cfg.setGroup(name);
126
127 return KSSLPKCS12::fromString(cfg.readEntry("PKCS12Base64", ""), password);
128}
129
130
131// KDE 4: make it const TQString &
132KSSLPKCS12* KSSLCertificateHome::getCertificateByName(TQString name) {
133KSimpleConfig cfg("ksslcertificates", false);
134 if (!cfg.hasGroup(name)) return NULL;
135
136 cfg.setGroup(name);
137
138 return KSSLPKCS12::fromString(cfg.readEntry("PKCS12Base64", ""), cfg.readEntry("Password", ""));
139}
140
141
142// KDE 4: make it const TQString &
143bool KSSLCertificateHome::hasCertificateByName(TQString name) {
144KSimpleConfig cfg("ksslcertificates", false);
145 if (!cfg.hasGroup(name)) return false;
146 return true;
147}
148
149// KDE 4: make it const TQString &
150KSSLPKCS12* KSSLCertificateHome::getCertificateByHost(TQString host, TQString password, KSSLAuthAction *aa) {
151 return KSSLCertificateHome::getCertificateByName(KSSLCertificateHome::getDefaultCertificateName(host, aa), password);
152}
153
154
155// KDE 4: make it const TQString &
156TQString KSSLCertificateHome::getDefaultCertificateName(TQString host, KSSLAuthAction *aa) {
157KSimpleConfig cfg("ksslauthmap", false);
158
159#ifdef TQ_WS_WIN //temporary
160 if (!cfg.hasGroup(host)) {
161#else
162 if (!cfg.hasGroup(KResolver::domainToAscii(host))) {
163#endif
164 if (aa) *aa = AuthNone;
165 return TQString::null;
166 } else {
167#ifdef TQ_WS_WIN //temporary
168 cfg.setGroup(host);
169#else
170 cfg.setGroup(KResolver::domainToAscii(host));
171#endif
172 if (aa) {
173 bool tmp = cfg.readBoolEntry("send", false);
174 *aa = AuthSend;
175 if (!tmp) {
176 tmp = cfg.readBoolEntry("prompt", false);
177 *aa = AuthPrompt;
178 if (!tmp) {
179 *aa = AuthDont;
180 }
181 }
182 }
183 return cfg.readEntry("certificate", "");
184 }
185}
186
187
188TQString KSSLCertificateHome::getDefaultCertificateName(KSSLAuthAction *aa) {
189TDEConfig cfg("cryptodefaults", false);
190
191 cfg.setGroup("Auth");
192 if (aa) {
193 TQString am = cfg.readEntry("AuthMethod", "");
194 if (am == "send")
195 *aa = AuthSend;
196 else if (am == "prompt")
197 *aa = AuthPrompt;
198 else
199 *aa = AuthDont;
200 }
201
202return cfg.readEntry("DefaultCert", "");
203}
204
205
206// KDE 4: make it const TQString &
207KSSLPKCS12* KSSLCertificateHome::getDefaultCertificate(TQString password, KSSLAuthAction *aa) {
208TQString name = KSSLCertificateHome::getDefaultCertificateName(aa);
209KSimpleConfig cfg("ksslcertificates", false);
210
211 if (name.isEmpty()) return NULL;
212
213 cfg.setGroup(name);
214 return KSSLPKCS12::fromString(cfg.readEntry("PKCS12Base64", ""), password);
215}
216
217
218
219KSSLPKCS12* KSSLCertificateHome::getDefaultCertificate(KSSLAuthAction *aa) {
220TQString name = KSSLCertificateHome::getDefaultCertificateName(aa);
221KSimpleConfig cfg("ksslcertificates", false);
222
223 if (name.isEmpty()) return NULL;
224
225 cfg.setGroup(name);
226 return KSSLPKCS12::fromString(cfg.readEntry("PKCS12Base64", ""),
227 cfg.readEntry("Password", ""));
228}
229
230
231// KDE 4: make it const TQString &
232void KSSLCertificateHome::setDefaultCertificate(TQString name, bool send, bool prompt) {
233KSimpleConfig cfg("ksslauthmap", false);
234
235 cfg.setGroup("<default>");
236 cfg.writeEntry("defaultCertificate", name);
237 cfg.writeEntry("send", send);
238 cfg.writeEntry("prompt", prompt);
239}
240
241
242void KSSLCertificateHome::setDefaultCertificate(KSSLPKCS12 *cert, bool send, bool prompt) {
243 if (cert)
244 KSSLCertificateHome::setDefaultCertificate(cert->name(), send, prompt);
245}
246
KSSLPKCS12
KDE PKCS#12 Certificate.
Definition: ksslpkcs12.h:61
KSSLPKCS12::name
TQString name()
The name of this certificate.
Definition: ksslpkcs12.cpp:271
KSSLPKCS12::toString
TQString toString()
Convert to a Base64 string.
Definition: ksslpkcs12.cpp:186
KSSLPKCS12::fromString
static KSSLPKCS12 * fromString(TQString base64, TQString password="")
Create a KSSLPKCS12 object from a Base64 in a TQString.
Definition: ksslpkcs12.cpp:65
KSSLPKCS12::loadCertFile
static KSSLPKCS12 * loadCertFile(TQString filename, TQString password="")
Create a KSSLPKCS12 object by reading a PKCS#12 file.
Definition: ksslpkcs12.cpp:83

tdeio/kssl

Skip menu "tdeio/kssl"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/kssl

Skip menu "tdeio/kssl"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/kssl by doxygen 1.9.4
This website is maintained by Timothy Pearson.