22 #include "ksslcertificatecache.h"
23 #include "ksslcertchain.h"
24 #include "ksslcertificate.h"
28 #include <dcopclient.h>
29 #include <kdatastream.h>
32 class KSSLCertificateCache::KSSLCertificateCachePrivate {
36 KSSLCertificateCachePrivate() { dcc =
new DCOPClient; dcc->attach(); }
37 ~KSSLCertificateCachePrivate() {
delete dcc;}
43 KSSLCertificateCache::KSSLCertificateCache() {
44 d =
new KSSLCertificateCachePrivate;
48 KSSLCertificateCache::~KSSLCertificateCache() {
53 void KSSLCertificateCache::saveToDisk() {
54 kdDebug() <<
"Deprecated function KSSLCertificateCache::saveToDisk() called" << endl;
58 void KSSLCertificateCache::clearList() {
59 kdDebug() <<
"Deprecated function KSSLCertificateCache::clearList() called" << endl;
63 void KSSLCertificateCache::loadDefaultPolicies() {
64 kdDebug() <<
"Deprecated function KSSLCertificateCache::loadDefaultPolicies() called" << endl;
68 void KSSLCertificateCache::reload() {
69 TQByteArray data, retval;
71 TQDataStream arg(data, IO_WriteOnly);
72 d->dcc->call(
"kded",
"kssld",
74 data, rettype, retval);
79 KSSLCertificatePolicy policy,
bool permanent) {
80 TQByteArray data, retval;
82 TQDataStream arg(data, IO_WriteOnly);
86 d->dcc->call(
"kded",
"kssld",
87 "cacheAddCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool)",
88 data, rettype, retval);
93 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCN(TQString& cn) {
94 TQByteArray data, retval;
96 TQDataStream arg(data, IO_WriteOnly);
98 bool rc = d->dcc->call(
"kded",
"kssld",
99 "cacheGetPolicyByCN(TQString)",
100 data, rettype, retval);
102 if (rc && rettype ==
"KSSLCertificateCache::KSSLCertificatePolicy") {
103 TQDataStream retStream(retval, IO_ReadOnly);
104 KSSLCertificateCache::KSSLCertificatePolicy drc;
108 return KSSLCertificateCache::Ambiguous;
112 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCertificate(
KSSLCertificate& cert) {
113 TQByteArray data, retval;
115 TQDataStream arg(data, IO_WriteOnly);
117 bool rc = d->dcc->call(
"kded",
"kssld",
118 "cacheGetPolicyByCertificate(KSSLCertificate)",
119 data, rettype, retval);
121 if (rc && rettype ==
"KSSLCertificateCache::KSSLCertificatePolicy") {
122 TQDataStream retStream(retval, IO_ReadOnly);
123 KSSLCertificateCache::KSSLCertificatePolicy drc;
127 return KSSLCertificateCache::Ambiguous;
132 bool KSSLCertificateCache::seenCN(TQString& cn) {
133 TQByteArray data, retval;
135 TQDataStream arg(data, IO_WriteOnly);
137 bool rc = d->dcc->call(
"kded",
"kssld",
138 "cacheSeenCN(TQString)",
139 data, rettype, retval);
141 if (rc && rettype ==
"bool") {
142 TQDataStream retStream(retval, IO_ReadOnly);
153 TQByteArray data, retval;
155 TQDataStream arg(data, IO_WriteOnly);
157 bool rc = d->dcc->call(
"kded",
"kssld",
158 "cacheSeenCertificate(KSSLCertificate)",
159 data, rettype, retval);
161 if (rc && rettype ==
"bool") {
162 TQDataStream retStream(retval, IO_ReadOnly);
173 TQByteArray data, retval;
175 TQDataStream arg(data, IO_WriteOnly);
177 bool rc = d->dcc->call(
"kded",
"kssld",
178 "cacheIsPermanent(KSSLCertificate)",
179 data, rettype, retval);
181 if (rc && rettype ==
"bool") {
182 TQDataStream retStream(retval, IO_ReadOnly);
193 bool KSSLCertificateCache::removeByCN(TQString& cn) {
194 TQByteArray data, retval;
196 TQDataStream arg(data, IO_WriteOnly);
198 bool rc = d->dcc->call(
"kded",
"kssld",
199 "cacheRemoveByCN(TQString)",
200 data, rettype, retval);
202 if (rc && rettype ==
"bool") {
203 TQDataStream retStream(retval, IO_ReadOnly);
213 bool KSSLCertificateCache::removeByCertificate(
KSSLCertificate& cert) {
214 TQByteArray data, retval;
216 TQDataStream arg(data, IO_WriteOnly);
218 bool rc = d->dcc->call(
"kded",
"kssld",
219 "cacheRemoveByCertificate(KSSLCertificate)",
220 data, rettype, retval);
222 if (rc && rettype ==
"bool") {
223 TQDataStream retStream(retval, IO_ReadOnly);
234 bool KSSLCertificateCache::modifyByCN(TQString& cn,
235 KSSLCertificateCache::KSSLCertificatePolicy policy,
237 TQDateTime& expires) {
238 TQByteArray data, retval;
240 TQDataStream arg(data, IO_WriteOnly);
241 arg << cn << policy << permanent << expires;
242 bool rc = d->dcc->call(
"kded",
"kssld",
243 "cacheModifyByCN(TQString,KSSLCertificateCache::KSSLCertificatePolicy,bool,TQDateTime)",
244 data, rettype, retval);
246 if (rc && rettype ==
"bool") {
247 TQDataStream retStream(retval, IO_ReadOnly);
258 KSSLCertificateCache::KSSLCertificatePolicy policy,
260 TQDateTime& expires) {
261 TQByteArray data, retval;
263 TQDataStream arg(data, IO_WriteOnly);
264 arg << cert << policy << permanent << expires;
265 bool rc = d->dcc->call(
"kded",
"kssld",
266 "cacheModifyByCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool,TQDateTime)",
267 data, rettype, retval);
269 if (rc && rettype ==
"bool") {
270 TQDataStream retStream(retval, IO_ReadOnly);
280 TQStringList KSSLCertificateCache::getHostList(
KSSLCertificate& cert) {
281 TQByteArray data, retval;
283 TQDataStream arg(data, IO_WriteOnly);
285 bool rc = d->dcc->call(
"kded",
"kssld",
286 "cacheGetHostList(KSSLCertificate)",
287 data, rettype, retval);
289 if (rc && rettype ==
"TQStringList") {
290 TQDataStream retStream(retval, IO_ReadOnly);
295 return TQStringList();
300 bool KSSLCertificateCache::addHost(
KSSLCertificate& cert, TQString& host) {
301 TQByteArray data, retval;
303 TQDataStream arg(data, IO_WriteOnly);
305 bool rc = d->dcc->call(
"kded",
"kssld",
306 "cacheAddHost(KSSLCertificate,TQString)",
307 data, rettype, retval);
309 if (rc && rettype ==
"bool") {
310 TQDataStream retStream(retval, IO_ReadOnly);
321 bool KSSLCertificateCache::removeHost(
KSSLCertificate& cert, TQString& host) {
322 TQByteArray data, retval;
324 TQDataStream arg(data, IO_WriteOnly);
326 bool rc = d->dcc->call(
"kded",
"kssld",
327 "cacheRemoveHost(KSSLCertificate,TQString)",
328 data, rettype, retval);
330 if (rc && rettype ==
"bool") {
331 TQDataStream retStream(retval, IO_ReadOnly);
341 TQStringList KSSLCertificateCache::getKDEKeyByEmail(
const TQString &email) {
342 TQByteArray data, retval;
344 TQDataStream arg(data, IO_WriteOnly);
346 bool rc = d->dcc->call(
"kded",
"kssld",
347 "getKDEKeyByEmail(TQString)",
348 data, rettype, retval);
350 if (rc && rettype ==
"TQStringList") {
351 TQDataStream retStream(retval, IO_ReadOnly);
357 return TQStringList();
361 KSSLCertificate *KSSLCertificateCache::getCertByMD5Digest(
const TQString &key) {
362 TQByteArray data, retval;
364 TQDataStream arg(data, IO_WriteOnly);
366 bool rc = d->dcc->call(
"kded",
"kssld",
367 "getCertByMD5Digest(TQString)",
368 data, rettype, retval);
370 if (rc && rettype ==
"KSSLCertificate") {
371 TQDataStream retStream(retval, IO_ReadOnly);
383 TQDataStream& operator<<(TQDataStream& s,
const KSSLCertificateCache::KSSLCertificatePolicy& p) {
389 TQDataStream& operator>>(TQDataStream& s, KSSLCertificateCache::KSSLCertificatePolicy& p) {
392 p = (KSSLCertificateCache::KSSLCertificatePolicy) pd;