You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
252 lines
6.1 KiB
252 lines
6.1 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
*
|
||
|
* Copyright (C) 2001 George Staikos <staikos@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.
|
||
|
*/
|
||
|
|
||
|
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
#include "ksslcertificate.h"
|
||
|
#include "ksslsigners.h"
|
||
|
#include <stdlib.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <dcopclient.h>
|
||
|
#include <kdatastream.h>
|
||
|
|
||
|
|
||
|
KSSLSigners::KSSLSigners() {
|
||
|
dcc = new DCOPClient;
|
||
|
dcc->attach();
|
||
|
}
|
||
|
|
||
|
|
||
|
KSSLSigners::~KSSLSigners() {
|
||
|
delete dcc;
|
||
|
}
|
||
|
|
||
|
bool KSSLSigners::addCA(KSSLCertificate& cert,
|
||
|
bool ssl,
|
||
|
bool email,
|
||
|
bool code) {
|
||
|
return addCA(cert.toString(), ssl, email, code);
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::addCA(TQString cert,
|
||
15 years ago
|
bool ssl,
|
||
|
bool email,
|
||
|
bool code) {
|
||
15 years ago
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << cert;
|
||
|
arg << ssl << email << code;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caAdd(TQString,bool,bool,bool)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KSSLSigners::regenerate() {
|
||
15 years ago
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
bool rc = dcc->call("kded", "kssld",
|
||
|
"caRegenerate()",
|
||
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KSSLSigners::useForSSL(KSSLCertificate& cert) {
|
||
|
return useForSSL(cert.getSubject());
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::useForSSL(TQString subject) {
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caUseForSSL(TQString)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KSSLSigners::useForEmail(KSSLCertificate& cert) {
|
||
|
return useForEmail(cert.getSubject());
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::useForEmail(TQString subject) {
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caUseForEmail(TQString)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KSSLSigners::useForCode(KSSLCertificate& cert) {
|
||
|
return useForCode(cert.getSubject());
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::useForCode(TQString subject) {
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caUseForCode(TQString)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KSSLSigners::remove(KSSLCertificate& cert) {
|
||
|
return remove(cert.getSubject());
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::remove(TQString subject) {
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caRemove(TQString)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQStringList KSSLSigners::list() {
|
||
|
TQStringList drc;
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
bool rc = dcc->call("kded", "kssld",
|
||
|
"caList()",
|
||
|
data, rettype, retval);
|
||
|
|
||
14 years ago
|
if (rc && rettype == TQSTRINGLIST_OBJECT_NAME_STRING) {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
retStream >> drc;
|
||
|
}
|
||
|
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQString KSSLSigners::getCert(TQString subject) {
|
||
|
TQString drc;
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caGetCert(TQString)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
14 years ago
|
if (rc && rettype == TQSTRING_OBJECT_NAME_STRING) {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
retStream >> drc;
|
||
|
}
|
||
|
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
bool KSSLSigners::setUse(TQString subject, bool ssl, bool email, bool code) {
|
||
|
TQByteArray data, retval;
|
||
|
TQCString rettype;
|
||
|
TQDataStream arg(data, IO_WriteOnly);
|
||
15 years ago
|
arg << subject << ssl << email << code;
|
||
|
bool rc = dcc->call("kded", "kssld",
|
||
15 years ago
|
"caSetUse(TQString,bool,bool,bool)",
|
||
15 years ago
|
data, rettype, retval);
|
||
|
|
||
|
if (rc && rettype == "bool") {
|
||
15 years ago
|
TQDataStream retStream(retval, IO_ReadOnly);
|
||
15 years ago
|
bool drc;
|
||
|
retStream >> drc;
|
||
|
return drc;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|