mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
- Delete unused view/ directory
- readd truststate
This commit is contained in:
parent
d4d02b6d7e
commit
a656a56a66
@ -5,7 +5,7 @@
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
@ -13,7 +13,7 @@
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
@ -34,10 +34,10 @@
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
@ -45,7 +45,7 @@
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#include "db_base.h"
|
||||
@ -65,7 +65,7 @@
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/ImportMulti.h"
|
||||
|
||||
db_base::db_base(QString db, MainWindow *mw)
|
||||
db_base::db_base(QString db, MainWindow *mw)
|
||||
:QAbstractItemModel(NULL)
|
||||
{
|
||||
dbName = db;
|
||||
@ -97,7 +97,7 @@ void db_base::remFromCont(QModelIndex &idx)
|
||||
pki_base *parent_pki = pki->getParent();
|
||||
printf("PKI=%p, parent=%p\n", pki,parent_pki);
|
||||
int row = pki->row();
|
||||
|
||||
|
||||
beginRemoveRows(parent(idx), row, row);
|
||||
parent_pki->takeChild(pki);
|
||||
endRemoveRows();
|
||||
@ -108,7 +108,7 @@ void db_base::loadContainer()
|
||||
db mydb(dbName);
|
||||
unsigned char *p;
|
||||
db_header_t head;
|
||||
|
||||
|
||||
pki_base *pb, *pki;
|
||||
pb = newPKI();
|
||||
while ( mydb.find(pb->getType(), NULL) == 0 ) {
|
||||
@ -143,9 +143,9 @@ void db_base::insertPKI(pki_base *pki)
|
||||
int size;
|
||||
QString name;
|
||||
db mydb(dbName);
|
||||
|
||||
|
||||
p = pki->toData(&size);
|
||||
|
||||
|
||||
if (p) {
|
||||
name = mydb.uniq_name(pki->getIntName(), pki->getType());
|
||||
pki->setIntName(name);
|
||||
@ -165,7 +165,7 @@ void db_base::delete_ask()
|
||||
delete_txt + ": " + pki->getIntName() + " ?\n" ,
|
||||
tr("Delete"), tr("Cancel"))
|
||||
) return;
|
||||
|
||||
|
||||
deletePKI();
|
||||
}
|
||||
|
||||
@ -174,9 +174,9 @@ void db_base::deletePKI()
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
pki_base *pki = static_cast<pki_base*>(currentIdx.internalPointer());
|
||||
|
||||
|
||||
remFromCont(currentIdx);
|
||||
|
||||
|
||||
db mydb(dbName);
|
||||
mydb.find(pki->getType(), CCHAR(pki->getIntName()));
|
||||
mydb.erase();
|
||||
@ -190,7 +190,7 @@ void db_base::updatePKI(pki_base *pki)
|
||||
db mydb(dbName);
|
||||
|
||||
p = pki->toData(&size);
|
||||
|
||||
|
||||
if (p) {
|
||||
mydb.set(p, size, pki->getVersion(), pki->getType(),
|
||||
CCHAR(pki->getIntName()));
|
||||
@ -204,19 +204,19 @@ void db_base::deleteSelectedItems(QAbstractItemView* view)
|
||||
QModelIndexList indexes = selectionModel->selectedIndexes();
|
||||
QModelIndex index;
|
||||
QString items;
|
||||
|
||||
|
||||
foreach(index, indexes) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
pki_base *pki = static_cast<pki_base*>(index.internalPointer());
|
||||
items += "'" + pki->getIntName() + "' ";
|
||||
}
|
||||
|
||||
|
||||
if (QMessageBox::information(mainwin, tr(XCA_TITLE),
|
||||
delete_txt + ": " + items + " ?\n" ,
|
||||
tr("Delete"), tr("Cancel"))
|
||||
) return;
|
||||
|
||||
|
||||
foreach(index, indexes) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
@ -232,7 +232,7 @@ void db_base::showSelectedItems(QAbstractItemView* view)
|
||||
QModelIndexList indexes = selectionModel->selectedIndexes();
|
||||
QModelIndex index;
|
||||
QString items;
|
||||
|
||||
|
||||
foreach(index, indexes) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
|
||||
171
lib/db_x509.cpp
171
lib/db_x509.cpp
@ -34,10 +34,10 @@
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
@ -52,6 +52,7 @@
|
||||
#include "pki_pkcs7.h"
|
||||
#include "widgets/CertDetail.h"
|
||||
#include "widgets/ExportCert.h"
|
||||
#include "ui/TrustState.h"
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/qevent.h>
|
||||
#include <Qt/qaction.h>
|
||||
@ -86,7 +87,7 @@ pki_x509 *db_x509::findSigner(pki_x509 *client)
|
||||
return client;
|
||||
}
|
||||
FOR_ALL_pki(pki, pki_x509)
|
||||
if (client->verify(pki))
|
||||
if (client->verify(pki))
|
||||
return pki;
|
||||
return NULL;
|
||||
}
|
||||
@ -96,7 +97,7 @@ QStringList db_x509::getPrivateDesc()
|
||||
QStringList x;
|
||||
FOR_ALL_pki(pki, pki_x509)
|
||||
if (pki->getRefKey())
|
||||
x.append(pki->getIntName());
|
||||
x.append(pki->getIntName());
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ QStringList db_x509::getSignerDesc()
|
||||
QStringList x;
|
||||
FOR_ALL_pki(pki, pki_x509)
|
||||
if (pki->canSign())
|
||||
x.append(pki->getIntName());
|
||||
x.append(pki->getIntName());
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -117,14 +118,14 @@ void db_x509::remFromCont(QModelIndex &idx)
|
||||
pki_base *parent_pki = pki->getParent();
|
||||
row = pki->row();
|
||||
pki_x509 *child;
|
||||
|
||||
|
||||
beginRemoveRows(parent(idx), row, row);
|
||||
parent_pki->takeChild(pki);
|
||||
endRemoveRows();
|
||||
|
||||
row = rootItem->childCount()+1;
|
||||
num = pki->childCount();
|
||||
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row + num );
|
||||
while (pki->childCount()) {
|
||||
printf("Insert dangling children: %d\n", pki->childCount());
|
||||
@ -142,10 +143,10 @@ void db_x509::preprocess()
|
||||
{
|
||||
FOR_ALL_pki(pki, pki_x509) {
|
||||
findSigner(pki);
|
||||
findKey(pki);
|
||||
findKey(pki);
|
||||
}
|
||||
calcEffTrust();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -163,29 +164,28 @@ void db_x509::insertPKI(pki_base *refpki)
|
||||
FOR_ALL_pki(pki, pki_x509) /* sets this cert as signer the certs */
|
||||
pki->verify(x);
|
||||
db_base::insertPKI(refpki);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void db_x509::inToCont(pki_base *pki)
|
||||
{
|
||||
static int i=0;
|
||||
pki_x509 *cert = (pki_x509*)pki;
|
||||
|
||||
|
||||
findSigner(cert);
|
||||
pki_base *root = cert->getSigner();
|
||||
QModelIndex idx = QModelIndex(), this_idx;
|
||||
|
||||
|
||||
if (root == pki || root == NULL)
|
||||
root = rootItem;
|
||||
else
|
||||
idx = createIndex(root->row(), 0, root);
|
||||
|
||||
|
||||
int row = root->childCount()+1;
|
||||
|
||||
beginInsertRows(idx, row, row);
|
||||
root->append(pki);
|
||||
endInsertRows();
|
||||
this_idx = index(row, 0, idx);
|
||||
|
||||
|
||||
/* search for dangling certificates, which signer this is */
|
||||
FOR_ALL_pki(client, pki_x509) {
|
||||
if (client->getSigner() == NULL) {
|
||||
@ -196,7 +196,7 @@ void db_x509::inToCont(pki_base *pki)
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
rootItem->takeChild(client);
|
||||
endRemoveRows();
|
||||
|
||||
|
||||
row = root->childCount()+1;
|
||||
beginInsertRows(this_idx, row, row);
|
||||
pki->append(client);
|
||||
@ -224,7 +224,7 @@ pki_x509 *db_x509::getBySubject(const x509name &xname, pki_x509 *last)
|
||||
{
|
||||
bool lastfound = false;
|
||||
if (last == NULL) lastfound = true;
|
||||
|
||||
|
||||
FOR_ALL_pki(pki, pki_x509) {
|
||||
if ( pki->getSubject() == xname) {
|
||||
if (lastfound) {
|
||||
@ -244,7 +244,7 @@ void db_x509::revokeCert(const x509rev &revok, const pki_x509 *iss)
|
||||
if (crt)
|
||||
crt->setRevoked(revok.getDate());
|
||||
}
|
||||
|
||||
|
||||
pki_x509 *db_x509::getByIssSerial(const pki_x509 *issuer, const a1int &a)
|
||||
{
|
||||
if (!issuer ) return NULL;
|
||||
@ -278,7 +278,7 @@ a1int db_x509::searchSerial(pki_x509 *signer)
|
||||
{
|
||||
// returns the highest certificate serial
|
||||
// of all certs with this signer (itself too)
|
||||
a1int sserial, myserial;
|
||||
a1int sserial, myserial;
|
||||
if (!signer) return sserial;
|
||||
sserial = signer->getCaSerial();
|
||||
FOR_ALL_pki(pki, pki_x509)
|
||||
@ -315,7 +315,7 @@ pki_base *db_x509::insert(pki_base *item)
|
||||
updatePKI(cert->getSigner());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check CA serial of this cert
|
||||
serial = searchSerial(cert);
|
||||
if ( ++serial > cert->getCaSerial()) {
|
||||
@ -379,9 +379,9 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
a1time notBefore, notAfter;
|
||||
x509name subject;
|
||||
QString intname;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
try {
|
||||
|
||||
// Step 1 - Subject and key
|
||||
if (!dlg->fromReqCB->isChecked()) {
|
||||
clientkey = dlg->getSelectedKey();
|
||||
@ -389,7 +389,7 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
intname = dlg->description->text();
|
||||
}
|
||||
else {
|
||||
// A PKCS#10 Request was selected
|
||||
// A PKCS#10 Request was selected
|
||||
req = dlg->getSelectedReq();
|
||||
if (!req)
|
||||
return;
|
||||
@ -401,13 +401,13 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
subject = req->getSubject();
|
||||
intname = req->getIntName();
|
||||
}
|
||||
|
||||
// initially create cert
|
||||
|
||||
// initially create cert
|
||||
cert = new pki_x509();
|
||||
cert->setIntName(intname);
|
||||
cert->setSubject(subject);
|
||||
cert->setPubKey(clientkey);
|
||||
|
||||
|
||||
// Step 2 - select Signing
|
||||
if (dlg->foreignSignRB->isChecked()) {
|
||||
signcert = dlg->getSelectedSigner();
|
||||
@ -419,7 +419,7 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
}
|
||||
#if 0
|
||||
else if (dlg->selfQASignRB->isChecked()){
|
||||
|
||||
|
||||
PassWrite_UI *dlg1 = new PassWrite_UI(NULL, 0, true);
|
||||
dlg1->image->setPixmap( *MainWindow::keyImg );
|
||||
dlg1->title->setText(XCA_TITLE);
|
||||
@ -441,15 +441,15 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
delete dlg1;
|
||||
if (A!=B)
|
||||
throw errorEx(tr("The QA process has been terminated by the user."));
|
||||
signcert = cert;
|
||||
signkey = clientkey;
|
||||
signcert = cert;
|
||||
signkey = clientkey;
|
||||
serial.setHex(A);
|
||||
cert->setTrust(2);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
signcert = cert;
|
||||
signkey = clientkey;
|
||||
signcert = cert;
|
||||
signkey = clientkey;
|
||||
serial.setHex(dlg->serialNr->text());
|
||||
cert->setTrust(2);
|
||||
}
|
||||
@ -463,7 +463,7 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
// set the issuers name
|
||||
cert->setIssuer(signcert->getSubject());
|
||||
cert->setSerial(serial);
|
||||
|
||||
|
||||
// Step 3 - Choose the Date
|
||||
// Date handling
|
||||
cert->setNotBefore( dlg->notBefore->getDate() );
|
||||
@ -476,16 +476,16 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
))
|
||||
throw errorEx("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// STEP 4 handle extensions
|
||||
if (dlg->copyReqExtCB->isChecked() && dlg->fromReqCB->isChecked()) {
|
||||
extList el = req->getV3Ext();
|
||||
int m = el.count();
|
||||
for (int i=0; i<m; i++)
|
||||
cert->addV3ext(el[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cert->addV3ext(dlg->getBasicConstraints());
|
||||
cert->addV3ext(dlg->getSubKeyIdent());
|
||||
cert->addV3ext(dlg->getAuthKeyIdent());
|
||||
@ -500,11 +500,11 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
int m = ne.count();
|
||||
for (int i=0; i<m; i++)
|
||||
cert->addV3ext(ne[i]);
|
||||
|
||||
|
||||
const EVP_MD *hashAlgo = dlg->getHashAlgo();
|
||||
if (signkey->getType() == EVP_PKEY_DSA)
|
||||
hashAlgo = EVP_dss1();
|
||||
#if 0
|
||||
#if 0
|
||||
if (dlg->selfQASignRB->isChecked())
|
||||
{
|
||||
// sign the request intermediately in order to finally fill
|
||||
@ -514,20 +514,20 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
cert->setSerial(cert->hashInfo(EVP_md5()));
|
||||
}
|
||||
#endif
|
||||
// and finally sign the request
|
||||
// and finally sign the request
|
||||
cert->sign(signkey, hashAlgo);
|
||||
insert(cert);
|
||||
updatePKI(signcert);
|
||||
if (tempkey != NULL)
|
||||
delete(tempkey);
|
||||
}
|
||||
|
||||
|
||||
catch (errorEx &err) {
|
||||
MainWindow::Error(err);
|
||||
delete cert;
|
||||
if (tempkey != NULL) delete(tempkey);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void db_x509::showItem()
|
||||
@ -536,7 +536,7 @@ void db_x509::showItem()
|
||||
return;
|
||||
pki_x509 *crt = static_cast<pki_x509*>(currentIdx.internalPointer());
|
||||
CertDetail *dlg;
|
||||
printf("Show Item x509\n");
|
||||
printf("Show Item x509\n");
|
||||
dlg = new CertDetail(mainwin);
|
||||
if (dlg) {
|
||||
dlg->setCert(crt);
|
||||
@ -551,11 +551,11 @@ void db_x509::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
QMenu *subExport, *subCa, *subP7;
|
||||
QAction *itemReq, *itemtca, *itemTemplate, *itemRevoke, *itemExtend,
|
||||
*itemTrust;
|
||||
bool parentCanSign, canSign, hasTemplates, hasPrivkey;
|
||||
currentIdx = QModelIndex();
|
||||
|
||||
bool parentCanSign, canSign, hasTemplates, hasPrivkey;
|
||||
currentIdx = index;
|
||||
|
||||
pki_x509 *cert = static_cast<pki_x509*>(index.internalPointer());
|
||||
|
||||
|
||||
menu->addAction(tr("New Certificate"), this, SLOT(newItem()));
|
||||
menu->addAction(tr("Import"), this, SLOT(load()));
|
||||
menu->addAction(tr("Import PKCS#12"), this, SLOT(loadPKCS12()));
|
||||
@ -578,7 +578,7 @@ void db_x509::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
itemTemplate = subCa->addAction(tr("Signing Template"),
|
||||
this, SLOT(setTemplate()));
|
||||
subCa->addAction(tr("Generate CRL"), this, SLOT(genCrl()));
|
||||
|
||||
|
||||
subP7 = menu->addMenu(tr("PKCS#7"));
|
||||
subP7->addAction(tr("Sign"), this, SLOT(signP7()));
|
||||
subP7->addAction(tr("Encrypt"), this, SLOT(encryptP7()));
|
||||
@ -627,7 +627,7 @@ void db_x509::store()
|
||||
QStringList filt;
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
|
||||
|
||||
pki_x509 *crt = static_cast<pki_x509*>(currentIdx.internalPointer());
|
||||
pki_x509 *oldcrt = NULL;
|
||||
if (!crt)
|
||||
@ -666,7 +666,7 @@ void db_x509::store()
|
||||
case 3: // PEM all Certificates
|
||||
writeAllCerts(fname,false);
|
||||
break;
|
||||
case 4: // DER
|
||||
case 4: // DER
|
||||
crt->writeCert(fname,false,false);
|
||||
break;
|
||||
case 5: // P7 lonely
|
||||
@ -706,7 +706,7 @@ void db_x509::writePKCS12(pki_x509 *cert, QString s, bool chain)
|
||||
QMessageBox::warning(mainwin, tr(XCA_TITLE),
|
||||
tr("There was no key found for the Certificate: ") +
|
||||
cert->getIntName() );
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (s.isEmpty())
|
||||
return;
|
||||
@ -732,7 +732,7 @@ void db_x509::writePKCS7(pki_x509 *cert, QString s, int type)
|
||||
pki_pkcs7 *p7 = NULL;
|
||||
QList<pki_base> list;
|
||||
pki_base *cer;
|
||||
try {
|
||||
try {
|
||||
p7 = new pki_pkcs7("");
|
||||
if ( type == P7_CHAIN ) {
|
||||
while (cert != NULL) {
|
||||
@ -743,12 +743,12 @@ void db_x509::writePKCS7(pki_x509 *cert, QString s, int type)
|
||||
}
|
||||
if ( type == P7_ONLY ) {
|
||||
p7->addCert(cert);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (type == P7_TRUSTED) {
|
||||
list = db->getContainer();
|
||||
if (!list.isEmpty()) {
|
||||
for ( cer = list.first(); cer != NULL; cer = list.next() ) {
|
||||
for ( cer = list.first(); cer != NULL; cer = list.next() ) {
|
||||
if (((pki_x509*)cer)->getTrust() == 2)
|
||||
p7->addCert((pki_x509 *)cer);
|
||||
}
|
||||
@ -762,7 +762,7 @@ void db_x509::writePKCS7(pki_x509 *cert, QString s, int type)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else
|
||||
#warning P7_TRUSTED P7_ALL
|
||||
#endif
|
||||
p7->writeP7(s, false);
|
||||
@ -772,9 +772,9 @@ void db_x509::writePKCS7(pki_x509 *cert, QString s, int type)
|
||||
}
|
||||
if (p7 != NULL )
|
||||
delete p7;
|
||||
|
||||
|
||||
}
|
||||
# if 0
|
||||
# if 0
|
||||
void ::signP7()
|
||||
{
|
||||
QStringList filt;
|
||||
@ -784,9 +784,9 @@ void ::signP7()
|
||||
pki_key *privkey = cert->getRefKey();
|
||||
if (!privkey || privkey->isPubKey()) {
|
||||
QMessageBox::warning(this,tr(XCA_TITLE),
|
||||
tr("There was no key found for the Certificate: ") +
|
||||
tr("There was no key found for the Certificate: ") +
|
||||
cert->getIntName());
|
||||
return;
|
||||
return;
|
||||
}
|
||||
filt.append("All Files ( *.* )");
|
||||
QString s="";
|
||||
@ -813,7 +813,7 @@ void ::signP7()
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CertView::encryptP7()
|
||||
{
|
||||
@ -826,7 +826,7 @@ void CertView::encryptP7()
|
||||
QMessageBox::warning(this,tr(XCA_TITLE),
|
||||
tr("There was no key found for the Certificate: ") +
|
||||
cert->getIntName()) ;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
filt.append("All Files ( *.* )");
|
||||
QString s="";
|
||||
@ -853,5 +853,52 @@ void CertView::encryptP7()
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void db_x509::setMultiTrust(QAbstractItemView* view)
|
||||
{
|
||||
QItemSelectionModel *selectionModel = view->selectionModel();
|
||||
QModelIndexList indexes = selectionModel->selectedIndexes();
|
||||
QString items;
|
||||
|
||||
foreach(currentIdx, indexes) {
|
||||
setTrust();
|
||||
}
|
||||
currentIdx = QModelIndex();
|
||||
}
|
||||
|
||||
void db_x509::setTrust()
|
||||
{
|
||||
int state, newstate;
|
||||
Ui::TrustState ui;
|
||||
printf("Trust UI\n");
|
||||
pki_x509 *cert = static_cast<pki_x509*>(currentIdx.internalPointer());
|
||||
if (!cert)
|
||||
return;
|
||||
QDialog *dlg = new QDialog(mainwin);
|
||||
ui.setupUi(dlg);
|
||||
|
||||
ui.image->setPixmap(*MainWindow::certImg);
|
||||
state = cert->getTrust();
|
||||
if (cert->getSigner() == cert) {
|
||||
if (state == 1)
|
||||
state = 0;
|
||||
ui.trust1->setDisabled(true);
|
||||
}
|
||||
if (state == 0 ) ui.trust0->setChecked(true);
|
||||
if (state == 1 ) ui.trust1->setChecked(true);
|
||||
if (state == 2 ) ui.trust2->setChecked(true);
|
||||
ui.certName->setText(cert->getIntName());
|
||||
if (dlg->exec()) {
|
||||
if (ui.trust0->isChecked()) newstate = 0;
|
||||
if (ui.trust1->isChecked()) newstate = 1;
|
||||
if (ui.trust2->isChecked()) newstate = 2;
|
||||
if (newstate!=state) {
|
||||
cert->setTrust(newstate);
|
||||
updatePKI(cert);
|
||||
}
|
||||
}
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
@ -13,7 +13,7 @@
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
@ -34,10 +34,10 @@
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
@ -45,7 +45,7 @@
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DB_X509_H
|
||||
@ -63,10 +63,10 @@
|
||||
class db_x509: public db_x509super
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
protected:
|
||||
QPixmap *certicon[4];
|
||||
|
||||
|
||||
public:
|
||||
db_x509(QString DBfile, MainWindow *mw);
|
||||
pki_base *newPKI();
|
||||
@ -91,7 +91,6 @@ class db_x509: public db_x509super
|
||||
void writePKCS7(pki_x509 *cert, QString s, int type);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
void inToCont(pki_base *pki);
|
||||
|
||||
|
||||
public slots:
|
||||
void load(void);
|
||||
@ -99,6 +98,8 @@ class db_x509: public db_x509super
|
||||
void revokeCert(const x509rev &revok, const pki_x509 *issuer);
|
||||
void store();
|
||||
void showItem();
|
||||
void setMultiTrust(QAbstractItemView* view);
|
||||
void setTrust();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -2,14 +2,14 @@
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>TrustState_UI</class>
|
||||
<widget class="QDialog" name="TrustState_UI" >
|
||||
<class>TrustState</class>
|
||||
<widget class="QDialog" name="TrustState" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>267</height>
|
||||
<width>435</width>
|
||||
<height>288</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -17,7 +17,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>11</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
@ -44,7 +44,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Set Trustment of the Certificate</string>
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-size:14pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Set trustment of the Certificate</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -93,13 +93,10 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@ -112,25 +109,22 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Q3ButtonGroup" name="ButtonGroup2" >
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Select the Truststate</string>
|
||||
<string>Trustment</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>11</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
@ -203,21 +197,47 @@
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Q3ButtonGroup</class>
|
||||
<extends></extends>
|
||||
<header>Qt3Support/Q3ButtonGroup</header>
|
||||
<container>1</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ClickLabel</class>
|
||||
<extends></extends>
|
||||
<header>clicklabel.h</header>
|
||||
<header>widgets/clicklabel.h</header>
|
||||
<container>0</container>
|
||||
<pixmap></pixmap>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>PushButton5</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>TrustState</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>66</x>
|
||||
<y>258</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>171</x>
|
||||
<y>251</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>PushButton4</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>TrustState</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>383</x>
|
||||
<y>247</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>238</x>
|
||||
<y>247</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
1083
view/CertView.cpp
1083
view/CertView.cpp
File diff suppressed because it is too large
Load Diff
121
view/CertView.h
121
view/CertView.h
@ -1,121 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CERTVIEW_H
|
||||
#define CERTVIEW_H
|
||||
|
||||
#include "XcaListView.h"
|
||||
/*
|
||||
#include "lib/pki_x509.h"
|
||||
#include "lib/pki_pkcs12.h"
|
||||
#include "widgets/NewX509.h"
|
||||
*/
|
||||
class pki_pkcs12;
|
||||
class NewX509;
|
||||
class pki_base;
|
||||
class Q3ListViewItem;
|
||||
class pki_x509req;
|
||||
class pki_temp;
|
||||
|
||||
class CertView : public XcaListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
int viewState;
|
||||
bool mkDir(QString dir);
|
||||
|
||||
public:
|
||||
CertView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f=0);
|
||||
void showItem(pki_base *item, bool import);
|
||||
void newItem();
|
||||
void deleteItem();
|
||||
void updateViewItem(pki_base *);
|
||||
void load();
|
||||
// pki_base* insert(pki_base *item);
|
||||
void store();
|
||||
void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
void newCert(NewX509 *dlg);
|
||||
void writePKCS12(QString s, bool chain);
|
||||
void writePKCS7(QString s, int type);
|
||||
void changeView(QPushButton *b);
|
||||
|
||||
public slots:
|
||||
void loadPKCS12();
|
||||
void loadPKCS7();
|
||||
void extendCert();
|
||||
void signP7();
|
||||
void encryptP7();
|
||||
void setTrust();
|
||||
void toRequest();
|
||||
void revoke();
|
||||
void unRevoke();
|
||||
void setSerial();
|
||||
void setCrlDays();
|
||||
void setTemplate();
|
||||
void toTinyCA();
|
||||
void updateView();
|
||||
void updateViewAll();
|
||||
void newCert(pki_x509req *req);
|
||||
void newCert(pki_temp *req);
|
||||
void genCrl();
|
||||
void importKey(pki_key *key);
|
||||
void importCert(pki_x509 *cert);
|
||||
void showKey(pki_key *key);
|
||||
void showKey(QString name);
|
||||
|
||||
signals:
|
||||
void genCrl(pki_x509 *);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
277
view/CrlView.cpp
277
view/CrlView.cpp
@ -1,277 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "CrlView.h"
|
||||
#include <Qt/q3popupmenu.h>
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/qlineedit.h>
|
||||
#include "widgets/CrlDetail.h"
|
||||
#include "widgets/KeyDetail.h"
|
||||
#include "widgets/CertDetail.h"
|
||||
#include "lib/pki_crl.h"
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/clicklabel.h"
|
||||
|
||||
CrlView::CrlView(QWidget * parent, const char * name, Qt::WFlags f)
|
||||
:XcaListView(parent, name, f)
|
||||
{
|
||||
addColumn(tr("Internal Name"));
|
||||
addColumn(tr("Issuer Common Name"));
|
||||
addColumn(tr("Revoked"));
|
||||
}
|
||||
|
||||
|
||||
void CrlView::showCert(Q3ListViewItem *i)
|
||||
{
|
||||
showCert(i->text(0));
|
||||
}
|
||||
|
||||
void CrlView::showCert(QString name)
|
||||
{
|
||||
pki_base *item = MainWindow::certs->getByName(name);
|
||||
if (!item) return;
|
||||
CertDetail *dlg=NULL;
|
||||
CHECK_DB
|
||||
try {
|
||||
dlg = new CertDetail(this,0,true);
|
||||
dlg->setCert((pki_x509 *)item);
|
||||
connect( dlg->privKey, SIGNAL( doubleClicked(QString) ),
|
||||
this, SLOT( showKey(QString) ));
|
||||
connect( dlg->signCert, SIGNAL( doubleClicked(QString) ),
|
||||
this, SLOT( showCert(QString) ));
|
||||
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
return ;
|
||||
}
|
||||
|
||||
void CrlView::showKey(QString name)
|
||||
{
|
||||
pki_key *key = (pki_key *)MainWindow::keys->getByName(name);
|
||||
KeyDetail *dlg = NULL;
|
||||
if (!key) return;
|
||||
CHECK_DB
|
||||
try {
|
||||
dlg = new KeyDetail(this, 0, true, 0 );
|
||||
dlg->setKey(key);
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void CrlView::showItem(pki_base *item, bool import)
|
||||
{
|
||||
if (!item) return;
|
||||
CrlDetail *dlg;
|
||||
CHECK_DB
|
||||
try {
|
||||
dlg = new CrlDetail(this,0,true);
|
||||
dlg->setCrl((pki_crl *)item);
|
||||
connect( dlg->certList, SIGNAL( doubleClicked(Q3ListViewItem*) ),
|
||||
this, SLOT( showCert(Q3ListViewItem *) ));
|
||||
connect( dlg->issuerIntName, SIGNAL( doubleClicked(QString) ),
|
||||
this, SLOT( showCert(QString) ));
|
||||
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CrlView::deleteItem()
|
||||
{
|
||||
deleteItem_default(tr("The Revocation list"),
|
||||
tr("is going to be deleted"));
|
||||
}
|
||||
|
||||
void CrlView::load()
|
||||
{
|
||||
load_crl l;
|
||||
load_default(l);
|
||||
}
|
||||
|
||||
void CrlView::writeCrl_pem()
|
||||
{
|
||||
store(true);
|
||||
}
|
||||
void CrlView::writeCrl_der()
|
||||
{
|
||||
store(false);
|
||||
}
|
||||
|
||||
void CrlView::store(bool pem)
|
||||
{
|
||||
pki_crl *crl;
|
||||
CHECK_DB
|
||||
|
||||
try {
|
||||
crl = (pki_crl *)getSelected();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!crl) return;
|
||||
QStringList filt;
|
||||
filt.append("Revocation Lists ( *.crl *.pem)");
|
||||
filt.append("All Files ( *.* )");
|
||||
QString s="";
|
||||
Q3FileDialog *dlg = new Q3FileDialog(this,0,true);
|
||||
dlg->setCaption(tr("Export Certificate revokation list"));
|
||||
dlg->setFilters(filt);
|
||||
dlg->setMode( Q3FileDialog::AnyFile );
|
||||
dlg->setSelection( (crl->getIntName() + ".crl") );
|
||||
dlg->setDir(MainWindow::getPath());
|
||||
|
||||
if (dlg->exec()) {
|
||||
s = dlg->selectedFile();
|
||||
MainWindow::setPath(dlg->dirPath());
|
||||
}
|
||||
delete dlg;
|
||||
if (s.isEmpty()) return;
|
||||
s=QDir::convertSeparators(s);
|
||||
try {
|
||||
crl->writeCrl(s.latin1(), pem);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CrlView::popupMenu(Q3ListViewItem *item, const QPoint &pt, int x) {
|
||||
Q3PopupMenu *menu = new Q3PopupMenu(this);
|
||||
Q3PopupMenu *subExport = new Q3PopupMenu(this);
|
||||
|
||||
if (!item) {
|
||||
menu->insertItem(tr("Import"), this, SLOT(load()));
|
||||
}
|
||||
else {
|
||||
CHECK_DB
|
||||
menu->insertItem(tr("Rename"), this, SLOT(startRename()));
|
||||
menu->insertItem(tr("Show Details"), this, SLOT(showItem()));
|
||||
menu->insertItem(tr("Export"), subExport);
|
||||
subExport->insertItem(tr("PEM"), this, SLOT(writeCrl_pem()));
|
||||
subExport->insertItem(tr("DER"), this, SLOT(writeCrl_der()));
|
||||
menu->insertItem(tr("Delete"), this, SLOT(deleteItem()));
|
||||
}
|
||||
menu->exec(pt);
|
||||
delete menu;
|
||||
delete subExport;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pki_crl *CrlView::newItem(pki_x509 *cert)
|
||||
{
|
||||
if (!cert) return NULL;
|
||||
QList<pki_x509> list;
|
||||
a1time time;
|
||||
pki_x509 *issuedcert = NULL;
|
||||
pki_crl *crl = NULL;
|
||||
CHECK_DB_NULL
|
||||
x509v3ext e;
|
||||
X509V3_CTX ext_ctx;
|
||||
X509V3_set_ctx(&ext_ctx, cert->getCert() , NULL, NULL, NULL, 0);
|
||||
X509V3_set_ctx_nodb((&ext_ctx));
|
||||
|
||||
try {
|
||||
crl = new pki_crl();
|
||||
crl->createCrl(cert->getIntName(), cert);
|
||||
|
||||
list = MainWindow::certs->getIssuedCerts(cert);
|
||||
if (!list.isEmpty()) {
|
||||
for ( issuedcert = list.first();
|
||||
issuedcert != NULL; issuedcert = list.next() )
|
||||
{
|
||||
if (issuedcert->isRevoked() ) {
|
||||
crl->addRev(issuedcert->getRev());
|
||||
}
|
||||
}
|
||||
}
|
||||
crl->addV3ext(e.create(NID_authority_key_identifier,
|
||||
"keyid,issuer", &ext_ctx));
|
||||
if (cert->hasSubAltName()) {
|
||||
crl->addV3ext(e.create(NID_issuer_alt_name,
|
||||
"issuer:copy", &ext_ctx));
|
||||
}
|
||||
crl->setLastUpdate(time.now());
|
||||
crl->setNextUpdate(time.now(60*60*24*cert->getCrlDays()));
|
||||
cert->setLastCrl(time);
|
||||
crl->sign(cert->getRefKey(), EVP_md5());
|
||||
MainWindow::certs->updatePKI(cert);
|
||||
// FIXME: set Last update
|
||||
db->insert(crl);
|
||||
updateView();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
return crl;
|
||||
}
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRLVIEW_H
|
||||
#define CRLVIEW_H
|
||||
|
||||
#include "XcaListView.h"
|
||||
|
||||
class pki_crl;
|
||||
class Q3ListViewItem;
|
||||
|
||||
class CrlView : public XcaListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
static const int sizeList[];
|
||||
|
||||
public:
|
||||
CrlView(QWidget * parent = NULL, const char * name = 0, Qt::WFlags f = 0);
|
||||
void showItem(pki_base *item, bool import);
|
||||
void deleteItem();
|
||||
void load();
|
||||
pki_base *loadItem(QString fname);
|
||||
void store(bool);
|
||||
void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
|
||||
public slots:
|
||||
pki_crl *newItem(pki_x509 *cert);
|
||||
void writeCrl_pem();
|
||||
void writeCrl_der();
|
||||
|
||||
private slots:
|
||||
void showCert(Q3ListViewItem *i);
|
||||
void showCert(QString name);
|
||||
void showKey(QString name);
|
||||
};
|
||||
|
||||
#endif
|
||||
314
view/KeyView.cpp
314
view/KeyView.cpp
@ -1,314 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "KeyView.h"
|
||||
#include "ui/NewKey.h"
|
||||
#include "ui/PassRead.h"
|
||||
#include "ui/PassWrite.h"
|
||||
#include "widgets/KeyDetail.h"
|
||||
#include "widgets/ExportKey.h"
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/clicklabel.h"
|
||||
#include "lib/pki_key.h"
|
||||
#include <Qt/qcombobox.h>
|
||||
#include <Qt/qregexp.h>
|
||||
#include <Qt/qlabel.h>
|
||||
#include <Qt/qpushbutton.h>
|
||||
#include <Qt/qlineedit.h>
|
||||
#include <Qt/q3textview.h>
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/q3popupmenu.h>
|
||||
#include <Qt/qcheckbox.h>
|
||||
|
||||
const int KeyView::sizeList[] = {512, 1024, 2048, 4096, 0 };
|
||||
|
||||
KeyView::KeyView(QWidget * parent, const char * name, Qt::WFlags f)
|
||||
:XcaListView(parent, name, f)
|
||||
{
|
||||
addColumn(tr("Internal name"));
|
||||
addColumn(tr("Keylength"));
|
||||
addColumn(tr("Use count"));
|
||||
addColumn(tr("Key type"));
|
||||
}
|
||||
|
||||
void KeyView::newItem()
|
||||
{
|
||||
CHECK_DB
|
||||
NewKey_UI *dlg = new NewKey_UI(this,0,true,0);
|
||||
pki_key *nkey = NULL;
|
||||
QString x;
|
||||
int keytypes[] = {EVP_PKEY_RSA, EVP_PKEY_DSA };
|
||||
dlg->keyLength->setEditable(true);
|
||||
for (int i=0; sizeList[i] != 0; i++ ) {
|
||||
dlg->keyLength->insertItem( x.number(sizeList[i]) +" bit");
|
||||
}
|
||||
dlg->keyLength->setCurrentItem(1);
|
||||
dlg->image->setPixmap(*MainWindow::keyImg);
|
||||
if (dlg->exec()) {
|
||||
try {
|
||||
QString ksizes = dlg->keyLength->currentText();
|
||||
ksizes.replace( QRegExp("[^0-9]"), "" );
|
||||
int ksize = ksizes.toInt();
|
||||
if (ksize < 32) throw errorEx(tr("Key size too small !"));
|
||||
if (ksize < 512 || ksize > 4096)
|
||||
if (!QMessageBox::warning(this, XCA_TITLE, tr("You are sure to create a key of the size: ")
|
||||
+QString::number(ksize) + " ?", tr("Cancel"), tr("Create") ))
|
||||
return;
|
||||
nkey = new pki_key(dlg->keyDesc->text());
|
||||
nkey->generate(ksize, keytypes[dlg->keyType->currentItem()] );
|
||||
|
||||
db->insert(nkey);
|
||||
x = nkey->getIntNameWithType();
|
||||
emit keyDone(x);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
delete dlg;
|
||||
updateView();
|
||||
}
|
||||
|
||||
void KeyView::deleteItem()
|
||||
{
|
||||
deleteItem_default(tr("The key"), tr("is going to be deleted"));
|
||||
}
|
||||
|
||||
void KeyView::showItem(pki_base *item, bool import)
|
||||
{
|
||||
pki_key *key = (pki_key *)item;
|
||||
KeyDetail *dlg = NULL;
|
||||
if (!key) return;
|
||||
try {
|
||||
dlg = new KeyDetail(this, 0, true, 0 );
|
||||
dlg->setKey(key);
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void KeyView::load()
|
||||
{
|
||||
CHECK_DB
|
||||
load_key l;
|
||||
load_default(l);
|
||||
}
|
||||
|
||||
void KeyView::store()
|
||||
{
|
||||
bool PEM = false;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
pki_key *targetKey = NULL;
|
||||
targetKey = (pki_key *)getSelected();
|
||||
if (!targetKey) return;
|
||||
ExportKey *dlg = new ExportKey((targetKey->getIntName() + ".pem"),
|
||||
targetKey->isPubKey(), MainWindow::getPath(), this);
|
||||
dlg->image->setPixmap(*MainWindow::keyImg);
|
||||
|
||||
if (!dlg->exec()) {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
MainWindow::setPath(dlg->dirPath);
|
||||
QString fname = dlg->filename->text();
|
||||
if (fname.isEmpty()) {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (dlg->exportFormat->currentText() == "PEM") PEM = true;
|
||||
if (dlg->exportFormat->currentText() == "PKCS#8")
|
||||
targetKey->writePKCS8(fname, &MainWindow::passWrite);
|
||||
else if (dlg->exportPrivate->isChecked()) {
|
||||
if (dlg->encryptKey->isChecked())
|
||||
enc = EVP_des_ede3_cbc();
|
||||
targetKey->writeKey(fname, enc, &MainWindow::passWrite, PEM);
|
||||
}
|
||||
else {
|
||||
targetKey->writePublic(fname, PEM);
|
||||
}
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void KeyView::popupMenu(Q3ListViewItem *item, const QPoint &pt, int x) {
|
||||
Q3PopupMenu *menu = new Q3PopupMenu(this);
|
||||
if (!item) {
|
||||
menu->insertItem(tr("New Key"), this, SLOT(newItem()));
|
||||
menu->insertItem(tr("Import"), this, SLOT(load()));
|
||||
}
|
||||
else {
|
||||
CHECK_DB
|
||||
menu->insertItem(tr("Rename"), this, SLOT(startRename()));
|
||||
menu->insertItem(tr("Show Details"), this, SLOT(showItem()));
|
||||
menu->insertItem(tr("Export"), this, SLOT(store()));
|
||||
menu->insertItem(tr("Delete"), this, SLOT(deleteItem()));
|
||||
menu->insertItem(tr("Change password"), this, SLOT(setOwnPass()));
|
||||
menu->insertItem(tr("Reset password"), this, SLOT(resetOwnPass()));
|
||||
}
|
||||
menu->exec(pt);
|
||||
delete menu;
|
||||
return;
|
||||
}
|
||||
|
||||
void KeyView::importKey(pki_key *k)
|
||||
{
|
||||
CHECK_DB
|
||||
db->insert(k);
|
||||
}
|
||||
|
||||
void KeyView::setOwnPass()
|
||||
{
|
||||
try {
|
||||
__setOwnPass(1);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyView::resetOwnPass()
|
||||
{
|
||||
try {
|
||||
__setOwnPass(0);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyView::__setOwnPass(int x)
|
||||
{
|
||||
pki_key *targetKey;
|
||||
targetKey = (pki_key *)getSelected();
|
||||
targetKey->setOwnPass(x);
|
||||
db->updatePKI(targetKey);
|
||||
}
|
||||
|
||||
void KeyView::changePasswd()
|
||||
{
|
||||
QString passHash;
|
||||
QString pass;
|
||||
bool ret;
|
||||
DbTxn *tid;
|
||||
|
||||
CHECK_DB
|
||||
|
||||
passHash = MainWindow::settings->getString("pwhash");
|
||||
PassRead_UI *dlg = new PassRead_UI(NULL, 0, true);
|
||||
dlg->image->setPixmap( *MainWindow::keyImg );
|
||||
dlg->title->setText(XCA_TITLE);
|
||||
dlg->description->setText(tr("Please enter the old password of the database."));
|
||||
dlg->pass->setFocus();
|
||||
dlg->setCaption(XCA_TITLE);
|
||||
|
||||
ret = dlg->exec();
|
||||
if (ret) {
|
||||
pass = dlg->pass->text();
|
||||
}
|
||||
delete dlg;
|
||||
if (!ret) return;
|
||||
if (MainWindow::md5passwd(pass.latin1()) != passHash) {
|
||||
QMessageBox::warning(this, XCA_TITLE, tr("Database password verify error."));
|
||||
return;
|
||||
}
|
||||
|
||||
PassWrite_UI *dlg1 = new PassWrite_UI(NULL, 0, true);
|
||||
dlg1->image->setPixmap( *MainWindow::keyImg );
|
||||
dlg1->title->setText(XCA_TITLE);
|
||||
dlg1->description->setText(tr("Please enter the new password for the database."));
|
||||
dlg1->passA->setFocus();
|
||||
dlg1->setCaption(XCA_TITLE);
|
||||
QString A = "Irgendwas", B="";
|
||||
ret = dlg1->exec();
|
||||
if (ret) {
|
||||
A = dlg1->passA->text();
|
||||
B = dlg1->passB->text();
|
||||
}
|
||||
delete dlg1;
|
||||
if (!ret) return;
|
||||
if (A != B) {
|
||||
QMessageBox::warning(this, XCA_TITLE, tr("Database password verify error."));
|
||||
return;
|
||||
}
|
||||
if (A.length() >= MAX_PASS_LENGTH) {
|
||||
QMessageBox::warning(this, XCA_TITLE, tr("Database password too long: ") +
|
||||
QString::number(MAX_PASS_LENGTH));
|
||||
return;
|
||||
}
|
||||
MainWindow::dbenv->txn_begin(NULL, &tid, 0);
|
||||
B = pki_key::passwd;
|
||||
strncpy(pki_key::passwd, A.latin1(), MAX_PASS_LENGTH);
|
||||
try {
|
||||
db->writeAll(tid);
|
||||
MainWindow::settings->putString( "pwhash", MainWindow::md5passwd(pki_key::passwd), tid );
|
||||
}
|
||||
catch (DbException &err) {
|
||||
QString e = err.what();
|
||||
/* recover the old password */
|
||||
tid->abort();
|
||||
strncpy(pki_key::passwd, B.latin1(), MAX_PASS_LENGTH);
|
||||
errorEx er(e);
|
||||
Qt::SocketError(er);
|
||||
}
|
||||
tid->commit(0);
|
||||
QMessageBox::information(this, XCA_TITLE, tr("Database password changed successfully.") );
|
||||
}
|
||||
|
||||
@ -1,86 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEYVIEW_H
|
||||
#define KEYVIEW_H
|
||||
|
||||
#include "XcaListView.h"
|
||||
|
||||
class pki_base;
|
||||
|
||||
class KeyView : public XcaListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
static const int sizeList[];
|
||||
void __setOwnPass(int x);
|
||||
public:
|
||||
KeyView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
|
||||
void showItem(pki_base *item, bool import);
|
||||
void newItem();
|
||||
void deleteItem();
|
||||
void load();
|
||||
// pki_base *insert(pki_base *item);
|
||||
void store();
|
||||
void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
public slots:
|
||||
void importKey(pki_key *k);
|
||||
void changePasswd();
|
||||
void setOwnPass();
|
||||
void resetOwnPass();
|
||||
signals:
|
||||
void keyDone(QString);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,18 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
ifeq ($(TOPDIR),)
|
||||
TOPDIR=..
|
||||
endif
|
||||
|
||||
NAMES=CertView CrlView KeyView ReqView TempView XcaListView
|
||||
OBJS=$(patsubst %, moc_%.o, $(NAMES)) $(patsubst %, %.o, $(NAMES))
|
||||
DELFILES=$(patsubst %, moc_%.cpp, $(NAMES))
|
||||
|
||||
include $(TOPDIR)/Rules.mak
|
||||
|
||||
ifeq ($(DEP), yes)
|
||||
sinclude .depend
|
||||
endif
|
||||
250
view/ReqView.cpp
250
view/ReqView.cpp
@ -1,250 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ReqView.h"
|
||||
#include "widgets/ReqDetail.h"
|
||||
#include "widgets/KeyDetail.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <Qt/q3popupmenu.h>
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/q3filedialog.h>
|
||||
#include <Qt/qdir.h>
|
||||
#include <Qt/qlabel.h>
|
||||
#include <Qt/qlineedit.h>
|
||||
#include <Qt/qcombobox.h>
|
||||
#include <Qt/qpushbutton.h>
|
||||
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/NewX509.h"
|
||||
#include "widgets/distname.h"
|
||||
#include "widgets/clicklabel.h"
|
||||
|
||||
|
||||
ReqView::ReqView(QWidget * parent, const char * name, Qt::WFlags f)
|
||||
:XcaListView(parent, name, f)
|
||||
{
|
||||
addColumn(tr("Internal name"));
|
||||
addColumn(tr("Common Name"));
|
||||
}
|
||||
|
||||
void ReqView::newItem()
|
||||
{
|
||||
newItem(NULL);
|
||||
}
|
||||
|
||||
void ReqView::newItem(pki_temp *temp)
|
||||
{
|
||||
CHECK_DB
|
||||
pki_x509req *req;
|
||||
NewX509 *dlg = new NewX509(this,0,true);
|
||||
emit connNewX509(dlg);
|
||||
|
||||
if (temp) {
|
||||
dlg->defineTemplate(temp);
|
||||
}
|
||||
dlg->setRequest();
|
||||
if (! dlg->exec()){
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const EVP_MD *hashAlgo = dlg->getHashAlgo();
|
||||
pki_key *key = dlg->getSelectedKey();
|
||||
x509name xn = dlg->getX509name();
|
||||
req = new pki_x509req();
|
||||
|
||||
req->setIntName(dlg->description->text());
|
||||
if (key->getType() == EVP_PKEY_DSA)
|
||||
hashAlgo = EVP_dss1();
|
||||
|
||||
req->createReq(key, xn, hashAlgo, dlg->getAllExt());
|
||||
db->insert(req);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
delete req;
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReqView::showItem(pki_base *item, bool import)
|
||||
{
|
||||
if (!item) return;
|
||||
ReqDetail *dlg = NULL;
|
||||
try {
|
||||
dlg = new ReqDetail(this,0,true);
|
||||
dlg->setReq((pki_x509req *)item);
|
||||
connect(dlg->privKey, SIGNAL(doubleClicked(QString)),
|
||||
this, SLOT(showKey(QString)));
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void ReqView::deleteItem()
|
||||
{
|
||||
deleteItem_default(tr("The Certificate signing request"),
|
||||
tr("is going to be deleted"));
|
||||
}
|
||||
|
||||
void ReqView::load()
|
||||
{
|
||||
load_req l;
|
||||
load_default(l);
|
||||
}
|
||||
|
||||
void ReqView::writeReq_pem() { store(true); }
|
||||
void ReqView::writeReq_der() { store(false); }
|
||||
|
||||
void ReqView::store(bool pem)
|
||||
{
|
||||
pki_x509req *req;
|
||||
try {
|
||||
req = (pki_x509req *)getSelected();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!req) return;
|
||||
QStringList filt;
|
||||
filt.append("PKCS#10 CSR ( *.pem *.der *.csr )");
|
||||
filt.append("All Files ( *.* )");
|
||||
QString s="";
|
||||
Q3FileDialog *dlg = new Q3FileDialog(this,0,true);
|
||||
dlg->setCaption(tr("Export Certificate signing request"));
|
||||
dlg->setFilters(filt);
|
||||
dlg->setMode( Q3FileDialog::AnyFile );
|
||||
dlg->setSelection( req->getIntName() + ".csr" );
|
||||
dlg->setDir(MainWindow::getPath());
|
||||
if (dlg->exec()) {
|
||||
s = dlg->selectedFile();
|
||||
MainWindow::setPath(dlg->dirPath());
|
||||
}
|
||||
delete dlg;
|
||||
if (s.isEmpty()) return;
|
||||
s=QDir::convertSeparators(s);
|
||||
try {
|
||||
req->writeReq(s, pem);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void ReqView::signReq()
|
||||
{
|
||||
pki_x509req *req;
|
||||
try {
|
||||
req = (pki_x509req *)getSelected();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
return;
|
||||
}
|
||||
newCert(req);
|
||||
}
|
||||
|
||||
void ReqView::popupMenu(Q3ListViewItem *item, const QPoint &pt, int x) {
|
||||
Q3PopupMenu *menu = new Q3PopupMenu(this);
|
||||
Q3PopupMenu *subExport = new Q3PopupMenu(this);
|
||||
int itemExport;
|
||||
|
||||
if (!item) {
|
||||
menu->insertItem(tr("New Request"), this, SLOT(newItem()));
|
||||
menu->insertItem(tr("Import"), this, SLOT(load()));
|
||||
}
|
||||
else {
|
||||
CHECK_DB
|
||||
pki_x509req *req = (pki_x509req *)db->getByName(item->text(0));
|
||||
menu->insertItem(tr("Rename"), this, SLOT(startRename()));
|
||||
menu->insertItem(tr("Show Details"), this, SLOT(showItem()));
|
||||
menu->insertItem(tr("Sign"), this, SLOT(signReq()));
|
||||
itemExport = menu->insertItem(tr("Export"), subExport);
|
||||
subExport->insertItem(tr("PEM"), this, SLOT(writeReq_pem()));
|
||||
subExport->insertItem(tr("DER"), this, SLOT(writeReq_der()));
|
||||
menu->insertItem(tr("Delete"), this, SLOT(deleteItem()));
|
||||
menu->setItemEnabled(itemExport, ! req->isSpki());
|
||||
}
|
||||
menu->exec(pt);
|
||||
delete menu;
|
||||
delete subExport;
|
||||
return;
|
||||
}
|
||||
|
||||
void ReqView::showKey(QString name)
|
||||
{
|
||||
pki_key *key = (pki_key *)MainWindow::keys->getByName(name);
|
||||
showKey(key);
|
||||
}
|
||||
|
||||
void ReqView::showKey(pki_key *key)
|
||||
{
|
||||
KeyDetail *dlg = NULL;
|
||||
if (!key) return;
|
||||
try {
|
||||
dlg = new KeyDetail(this, 0, true, 0 );
|
||||
dlg->setKey(key);
|
||||
dlg->exec();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
if (dlg)
|
||||
delete dlg;
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef REQVIEW_H
|
||||
#define REQVIEW_H
|
||||
|
||||
#include "XcaListView.h"
|
||||
#include "lib/pki_x509req.h"
|
||||
#include "lib/pki_temp.h"
|
||||
#include "widgets/NewX509.h"
|
||||
|
||||
|
||||
class ReqView : public XcaListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReqView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
|
||||
void showItem(pki_base *item, bool import);
|
||||
void newItem();
|
||||
void deleteItem();
|
||||
void load();
|
||||
void updateViewItem(pki_base *);
|
||||
pki_base *loadItem(QString fname);
|
||||
void store(bool pem);
|
||||
void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
public slots:
|
||||
void writeReq_pem();
|
||||
void writeReq_der();
|
||||
void signReq();
|
||||
void newItem(pki_temp *temp);
|
||||
void showKey(pki_key *key);
|
||||
void showKey(QString name);
|
||||
signals:
|
||||
void newCert(pki_x509req *req);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,225 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "TempView.h"
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/NewX509.h"
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/q3popupmenu.h>
|
||||
|
||||
TempView::TempView(QWidget * parent, const char * name, Qt::WFlags f)
|
||||
:XcaListView(parent, name, f)
|
||||
{
|
||||
addColumn(tr("Internal name"));
|
||||
addColumn(tr("Type"));
|
||||
}
|
||||
|
||||
bool TempView::runTempDlg(pki_temp *temp)
|
||||
{
|
||||
NewX509 *dlg = new NewX509(this, NULL, true);
|
||||
emit connNewX509(dlg);
|
||||
|
||||
dlg->setTemp(temp);
|
||||
dlg->fromTemplate(temp);
|
||||
if (!dlg->exec()) {
|
||||
delete dlg;
|
||||
return false;
|
||||
}
|
||||
dlg->toTemplate(temp);
|
||||
delete dlg;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TempView::newEmptyTemp()
|
||||
{
|
||||
newItem(pki_temp::EMPTY);
|
||||
}
|
||||
|
||||
void TempView::newCaTemp()
|
||||
{
|
||||
newItem(pki_temp::CA);
|
||||
}
|
||||
|
||||
void TempView::newClientTemp()
|
||||
{
|
||||
newItem(pki_temp::CLIENT);
|
||||
}
|
||||
|
||||
void TempView::newServerTemp()
|
||||
{
|
||||
newItem(pki_temp::SERVER);
|
||||
}
|
||||
|
||||
void TempView::newItem(int type)
|
||||
{
|
||||
CHECK_DB
|
||||
pki_temp *temp = new pki_temp("--", type);
|
||||
if (runTempDlg(temp)) {
|
||||
db->insert(temp);
|
||||
}
|
||||
else {
|
||||
delete temp;
|
||||
}
|
||||
}
|
||||
|
||||
void TempView::alterTemp()
|
||||
{
|
||||
alterTemp((pki_temp *)getSelected());
|
||||
}
|
||||
|
||||
bool TempView::alterTemp(pki_temp *temp)
|
||||
{
|
||||
QString oldname = temp->getIntName();
|
||||
if (!runTempDlg(temp)) return false;
|
||||
QString newname = temp->getIntName();
|
||||
if (newname!= oldname) {
|
||||
temp->setIntName(oldname);
|
||||
MainWindow::temps->renamePKI(temp, newname);
|
||||
}
|
||||
MainWindow::temps->updatePKI(temp);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TempView::showItem(pki_base *item, bool import)
|
||||
{
|
||||
pki_temp *temp = (pki_temp *)item;
|
||||
if (!temp) return;
|
||||
alterTemp(temp);
|
||||
}
|
||||
|
||||
|
||||
void TempView::deleteItem()
|
||||
{
|
||||
deleteItem_default(tr("The Template"), tr("is going to be deleted"));
|
||||
}
|
||||
|
||||
void TempView::load()
|
||||
{
|
||||
load_temp l;
|
||||
load_default(l);
|
||||
}
|
||||
|
||||
void TempView::store()
|
||||
{
|
||||
pki_temp *temp;
|
||||
try {
|
||||
temp = (pki_temp *)getSelected();
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!temp) return;
|
||||
QStringList filt;
|
||||
filt.append("XCA Templates ( *.xca )");
|
||||
filt.append("All Files ( *.* )");
|
||||
QString s="";
|
||||
Q3FileDialog *dlg = new Q3FileDialog(this,0,true);
|
||||
dlg->setCaption(tr("Export Template"));
|
||||
dlg->setFilters(filt);
|
||||
dlg->setMode( Q3FileDialog::AnyFile );
|
||||
dlg->setSelection( temp->getIntName() + ".xca" );
|
||||
dlg->setDir(MainWindow::getPath());
|
||||
if (dlg->exec()) {
|
||||
s = dlg->selectedFile();
|
||||
MainWindow::setPath(dlg->dirPath());
|
||||
}
|
||||
delete dlg;
|
||||
if (s.isEmpty()) return;
|
||||
s=QDir::convertSeparators(s);
|
||||
try {
|
||||
temp->writeTemp(s);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void TempView::certFromTemp()
|
||||
{
|
||||
pki_temp *temp = (pki_temp *)getSelected();
|
||||
newCert(temp);
|
||||
}
|
||||
|
||||
void TempView::reqFromTemp()
|
||||
{
|
||||
pki_temp *temp = (pki_temp *)getSelected();
|
||||
newReq(temp);
|
||||
}
|
||||
|
||||
void TempView::popupMenu(Q3ListViewItem *item, const QPoint &pt, int x)
|
||||
{
|
||||
Q3PopupMenu *menu = new Q3PopupMenu(this);
|
||||
Q3PopupMenu *subMenu = new Q3PopupMenu(this);
|
||||
if (!item) {
|
||||
menu->insertItem(tr("New Template"), subMenu);
|
||||
subMenu->insertItem(tr("Empty"), this, SLOT(newEmptyTemp()));
|
||||
subMenu->insertItem(tr("CA"), this, SLOT(newCaTemp()));
|
||||
subMenu->insertItem(tr("Client"), this, SLOT(newClientTemp()));
|
||||
subMenu->insertItem(tr("Server"), this, SLOT(newServerTemp()));
|
||||
menu->insertItem(tr("Import"), this, SLOT(load()));
|
||||
|
||||
}
|
||||
else {
|
||||
menu->insertItem(tr("Rename"), this, SLOT(startRename()));
|
||||
menu->insertItem(tr("Export"), this, SLOT(store()));
|
||||
menu->insertItem(tr("Change"), this, SLOT(alterTemp()));
|
||||
menu->insertItem(tr("Delete"), this, SLOT(deleteItem()));
|
||||
menu->insertItem(tr("Create certificate"), this, SLOT(certFromTemp()));
|
||||
menu->insertItem(tr("Create request"), this, SLOT(reqFromTemp()));
|
||||
}
|
||||
menu->exec(pt);
|
||||
delete menu;
|
||||
delete subMenu;
|
||||
return;
|
||||
}
|
||||
100
view/TempView.h
100
view/TempView.h
@ -1,100 +0,0 @@
|
||||
|
||||
//Added by the Qt porting tool:
|
||||
#include <QPixmap>
|
||||
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TEMPVIEW_H
|
||||
#define TEMPVIEW_H
|
||||
|
||||
#include "XcaListView.h"
|
||||
#include "lib/pki_temp.h"
|
||||
#ifdef qt4
|
||||
#include <Qt/q3listview.h>
|
||||
#else
|
||||
#include <Qt/q3listview.h>
|
||||
#endif
|
||||
|
||||
|
||||
class TempView : public XcaListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QPixmap *keyicon;
|
||||
bool runTempDlg(pki_temp *);
|
||||
public:
|
||||
TempView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
|
||||
void showItem(pki_base *item, bool import);
|
||||
void newItem(int type);
|
||||
void updateViewItem(pki_base *);
|
||||
bool alterTemp(pki_temp *);
|
||||
void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
pki_base *loadItem(QString fname);
|
||||
public slots:
|
||||
void newEmptyTemp();
|
||||
void newCaTemp();
|
||||
void newClientTemp();
|
||||
void newServerTemp();
|
||||
void certFromTemp();
|
||||
void reqFromTemp();
|
||||
void alterTemp();
|
||||
void deleteItem();
|
||||
void store();
|
||||
void load();
|
||||
signals:
|
||||
void newReq(pki_temp *);
|
||||
void newCert(pki_temp *);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,266 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "XcaListView.h"
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/ImportMulti.h"
|
||||
#include <Qt/qinputdialog.h>
|
||||
#include <Qt/q3filedialog.h>
|
||||
#include <Qt/qmessagebox.h>
|
||||
|
||||
XcaListView::XcaListView( QWidget * parent, const char * name, Qt::WFlags f)
|
||||
:Q3ListView(parent, name, f)
|
||||
{
|
||||
#ifdef qt3
|
||||
connect( this, SIGNAL(itemRenamed(Q3ListViewItem *, int, const QString &)),
|
||||
this, SLOT(rename(Q3ListViewItem *, int, const QString &)));
|
||||
#endif
|
||||
connect( this, SIGNAL(rightButtonPressed(Q3ListViewItem *, const QPoint &, int)),
|
||||
this, SLOT(popupMenu(Q3ListViewItem *, const QPoint &, int))) ;
|
||||
|
||||
connect( this, SIGNAL(doubleClicked(Q3ListViewItem *)),
|
||||
this, SLOT(showItem(Q3ListViewItem *))) ;
|
||||
}
|
||||
|
||||
void XcaListView::setDB(db_base *mydb)
|
||||
{
|
||||
db = mydb;
|
||||
updateView();
|
||||
}
|
||||
|
||||
void XcaListView::rmDB(db_base *mydb)
|
||||
{
|
||||
db = NULL;
|
||||
clear();
|
||||
}
|
||||
|
||||
void XcaListView::loadCont()
|
||||
{
|
||||
CHECK_DB
|
||||
db->loadContainer();
|
||||
updateView();
|
||||
}
|
||||
|
||||
pki_base *XcaListView::getSelected()
|
||||
{
|
||||
CHECK_DB_NULL
|
||||
Q3ListViewItem *lvi = selectedItem();
|
||||
if (!lvi) return NULL;
|
||||
QString name = lvi->text(0);
|
||||
return db->getByName(name);
|
||||
}
|
||||
|
||||
void XcaListView::showItem()
|
||||
{
|
||||
showItem(getSelected(), false);
|
||||
}
|
||||
|
||||
void XcaListView::showItem(QString name)
|
||||
{
|
||||
showItem(db->getByName(name), false);
|
||||
}
|
||||
|
||||
void XcaListView::showItem(Q3ListViewItem *item)
|
||||
{
|
||||
showItem(db->getByName(item->text(0)), false);
|
||||
}
|
||||
|
||||
void XcaListView::rename(Q3ListViewItem *item, int col, const QString &text)
|
||||
{
|
||||
CHECK_DB
|
||||
try {
|
||||
pki_base *pki = db->getByPtr(item);
|
||||
db->renamePKI(pki, text);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void XcaListView::startRename()
|
||||
{
|
||||
CHECK_DB
|
||||
try {
|
||||
#ifdef qt3
|
||||
Q3ListViewItem *item = selectedItem();
|
||||
if (item == NULL) return;
|
||||
item->startRename(0);
|
||||
#else
|
||||
renameDialog();
|
||||
#endif
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void XcaListView::renameDialog()
|
||||
{
|
||||
pki_base * pki = getSelected();
|
||||
if (!pki) return;
|
||||
QString name= pki->getIntName();
|
||||
bool ok;
|
||||
QString nname = QInputDialog::getText (XCA_TITLE, "Please enter the new name",
|
||||
QLineEdit::Normal, name, &ok, this );
|
||||
if (ok && name != nname) {
|
||||
db->renamePKI(pki, nname);
|
||||
pki->getLvi()->setText(0, pki->getIntName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void XcaListView::deleteItem_default(QString t1, QString t2)
|
||||
{
|
||||
pki_base *del = getSelected();
|
||||
if (!del) return;
|
||||
if (QMessageBox::information(this,tr(XCA_TITLE),
|
||||
t1 + ": '" + del->getIntName() + "'\n" + t2,
|
||||
tr("Delete"), tr("Cancel"))
|
||||
) return;
|
||||
try {
|
||||
db->deletePKI(del);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
}
|
||||
updateView();
|
||||
}
|
||||
|
||||
void XcaListView::load_default(load_base &load)
|
||||
{
|
||||
#if 0
|
||||
CRYPTO_remove_all_info();
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
|
||||
fprintf(stderr, "loadContainer:\n");
|
||||
CRYPTO_mem_leaks_fp(stderr);
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF);
|
||||
#endif
|
||||
QStringList slist;
|
||||
|
||||
Q3FileDialog *dlg = new Q3FileDialog(this,0,true);
|
||||
CHECK_DB
|
||||
|
||||
dlg->setCaption(load.caption);
|
||||
dlg->setFilters(load.filter);
|
||||
dlg->setMode( Q3FileDialog::ExistingFiles );
|
||||
dlg->setDir(MainWindow::getPath());
|
||||
if (dlg->exec()) {
|
||||
slist = dlg->selectedFiles();
|
||||
MainWindow::setPath(dlg->dirPath());
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
ImportMulti *dlgi = NULL;
|
||||
dlgi = new ImportMulti(this, NULL, true);
|
||||
for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) {
|
||||
QString s = *it;
|
||||
s = QDir::convertSeparators(s);
|
||||
pki_base *item = NULL;
|
||||
try {
|
||||
item = load.loadItem(s);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Qt::SocketError(err);
|
||||
if (item) {
|
||||
delete item;
|
||||
item = NULL;
|
||||
}
|
||||
}
|
||||
dlgi->addItem(item);
|
||||
}
|
||||
dlgi->execute();
|
||||
delete dlgi;
|
||||
updateView();
|
||||
}
|
||||
|
||||
void XcaListView::Error(errorEx &err)
|
||||
{
|
||||
MainWindow::Error(err);
|
||||
}
|
||||
|
||||
bool XcaListView::Error(pki_base *pki)
|
||||
{
|
||||
if (!pki) {
|
||||
QMessageBox::warning(this,tr(XCA_TITLE), tr("The system detected a NULL pointer, maybe the system is out of memory" ));
|
||||
qFatal("NULL pointer detected - Exiting");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void XcaListView::updateView()
|
||||
{
|
||||
CHECK_DB
|
||||
clear();
|
||||
QList<pki_base> container;
|
||||
pki_base *pki;
|
||||
container = db->getContainer();
|
||||
if (container.isEmpty()) return;
|
||||
for ( pki = container.first(); pki != NULL; pki = container.next() ) pki->delLvi();
|
||||
QListIterator<pki_base> it(container);
|
||||
for ( ; it.current(); ++it ) {
|
||||
pki = it.current();
|
||||
Q3ListViewItem *lvi = new Q3ListViewItem(this, pki->getIntName());
|
||||
insertItem(lvi);
|
||||
pki->setLvi(lvi);
|
||||
pki->updateView();
|
||||
}
|
||||
}
|
||||
|
||||
void XcaListView::newItem(void) { }
|
||||
void XcaListView::deleteItem(void) { }
|
||||
void XcaListView::load(void) { }
|
||||
void XcaListView::store(void) { }
|
||||
void XcaListView::popupMenu(Q3ListViewItem *, QPoint const &, int) { }
|
||||
void XcaListView::showItem(pki_base *, bool) { }
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2001 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XCALISTVIEW_H
|
||||
#define XCALISTVIEW_H
|
||||
#include <Qt/qlistview.h>
|
||||
#include "lib/db_base.h"
|
||||
#include "lib/load_obj.h"
|
||||
#include "lib/exception.h"
|
||||
#include "widgets/NewX509.h"
|
||||
|
||||
#define CHECK_DB emit init_database(); if (!MainWindow::dbenv) return;
|
||||
#define CHECK_DB_NULL emit init_database(); if (!MainWindow::dbenv) return NULL;
|
||||
|
||||
class XcaListView : public Q3ListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
db_base *db;
|
||||
|
||||
public:
|
||||
XcaListView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0);
|
||||
void setDB(db_base *mydb);
|
||||
void rmDB(db_base *mydb);
|
||||
virtual pki_base *getSelected();
|
||||
virtual void showItem(pki_base *item, bool import);
|
||||
void deleteItem_default(QString t1, QString t2);
|
||||
void load_default(QStringList &filter, QString caption);
|
||||
void load_default(load_base &load);
|
||||
void setDB(db_base *mydb, QPixmap *myimage);
|
||||
void Qt::SocketError(errorEx &err);
|
||||
bool Qt::SocketError(pki_base *pki);
|
||||
void loadCont();
|
||||
public slots:
|
||||
virtual void newItem();
|
||||
virtual void deleteItem();
|
||||
void showItem();
|
||||
void showItem(QString name);
|
||||
void showItem(Q3ListViewItem *item);
|
||||
virtual void load();
|
||||
virtual void store();
|
||||
virtual void popupMenu(Q3ListViewItem *item, const QPoint &pt, int x);
|
||||
void startRename();
|
||||
void renameDialog();
|
||||
void rename(Q3ListViewItem *item, int col, const QString &text);
|
||||
virtual void updateView();
|
||||
signals:
|
||||
void init_database();
|
||||
void connNewX509(NewX509 *);
|
||||
void showKey(QString name);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -423,7 +423,7 @@ int MainWindow::passWrite(char *buf, int size, int rwflag, void *userdata)
|
||||
dlg->show();
|
||||
dlg->activateWindow();
|
||||
ui.passA->setFocus();
|
||||
|
||||
|
||||
if (dlg->exec()) {
|
||||
QString A = ui.passA->text();
|
||||
QString B = ui.passB->text();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
@ -13,7 +13,7 @@
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* - Neither the name of the author nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
@ -34,12 +34,12 @@
|
||||
* This program links to software with different licenses from:
|
||||
*
|
||||
* http://www.openssl.org which includes cryptographic software
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
* written by Eric Young (eay@cryptsoft.com)"
|
||||
*
|
||||
* http://www.sleepycat.com
|
||||
*
|
||||
* http://www.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
@ -47,7 +47,7 @@
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef CLICKLABEL_H
|
||||
#define CLICKLABEL_H
|
||||
@ -57,18 +57,18 @@
|
||||
class QMouseEvent;
|
||||
|
||||
class ClickLabel : public QLabel
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ClickLabel(QWidget *parent);
|
||||
void setRed();
|
||||
void setGreen();
|
||||
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent ( QMouseEvent * e );
|
||||
void setColor(const QColor &col);
|
||||
|
||||
|
||||
signals:
|
||||
void doubleClicked(QString text);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user