add information to requests, wether they are already signed or not

- look for a certificate with the public key of the request
   to decide whether it is already handled or not.
This commit is contained in:
Christian Hohnstaedt 2009-11-29 12:28:31 +01:00
parent 205fa72305
commit 838fb6924d
23 changed files with 85 additions and 31 deletions

BIN
img/done.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

View File

@ -21,5 +21,6 @@
<file>template.png</file>
<file>validcertkey.png</file>
<file>validcert.png</file>
<file>done.png</file>
</qresource>
</RCC>

View File

@ -395,8 +395,7 @@ QVariant db_base::data(const QModelIndex &index, int role) const
case Qt::DisplayRole:
return item->column_data(index.column());
case Qt::DecorationRole:
if (!index.column())
return item->getIcon();
return item->getIcon(index.column());
}
return QVariant();
}

View File

@ -186,6 +186,12 @@ void db_x509::inToCont(pki_base *pki)
}
}
findKey(cert);
pki_key *pub = cert->getPubKey();
pki_x509req *req = (pki_x509req *)mainwin->reqs->findByByPubKey(pub);
delete pub;
if (req) {
req->setDone();
}
calcEffTrust();
}

View File

@ -18,7 +18,7 @@
db_x509req::db_x509req(QString DBfile, MainWindow *mw)
:db_x509super(DBfile, mw)
{
headertext << "Name" << "Subject";
headertext << tr("Name") << tr("Subject") << tr("Signed");
delete_txt = tr("Delete the request(s)");
view = mw->reqView;
class_name = "requests";
@ -81,6 +81,21 @@ void db_x509req::newItem(pki_temp *temp)
}
}
void db_x509req::inToCont(pki_base *pki)
{
pki_x509req *req = (pki_x509req *)pki;
db_base::inToCont(pki);
findKey(req);
if (!mainwin->certs)
return;
pki_key *pub = req->getPubKey();
pki_x509super *cert = mainwin->certs->findByByPubKey(pub);
delete pub;
if (cert) {
req->setDone();
}
}
void db_x509req::load(void)
{
load_req l;

View File

@ -23,6 +23,7 @@ class db_x509req: public db_x509super
pki_base* insert(pki_base *item);
pki_base *newPKI(db_header_t *head = NULL);
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
void inToCont(pki_base *pki);
public slots:
void newItem(pki_temp *temp = NULL);

View File

@ -44,9 +44,16 @@ pki_key *db_x509super::findKey(pki_x509super *ref)
return key;
}
void db_x509super::inToCont(pki_base *pki)
pki_x509super *db_x509super::findByByPubKey(pki_key *refkey)
{
db_base::inToCont(pki);
findKey((pki_x509super *)pki);
FOR_ALL_pki(pki, pki_x509super) {
pki_key *key = pki->getPubKey();
if (!key)
continue;
bool match = refkey->compare(key);
delete key;
if (match)
return pki;
}
return NULL;
}

View File

@ -19,7 +19,7 @@ class db_x509super: public db_base
public:
db_x509super(QString db, MainWindow *mw);
pki_key *findKey(pki_x509super *ref);
void inToCont(pki_base *pki);
pki_x509super *findByByPubKey(pki_key *refkey);
public slots:
void delKey(pki_key *delkey);

View File

@ -206,7 +206,7 @@ QVariant pki_base::column_data(int col)
{
return QVariant("invalid");
}
QVariant pki_base::getIcon()
QVariant pki_base::getIcon(int column)
{
return QVariant();
}

View File

@ -63,7 +63,7 @@ class pki_base : public QObject
pki_base *takeFirst();
int columns();
virtual QVariant column_data(int col);
virtual QVariant getIcon();
virtual QVariant getIcon(int column);
const char *className() { return class_name; };
uint32_t intFromData(const unsigned char **p);
virtual void fromPEM_BIO(BIO *, QString) {};

View File

@ -286,9 +286,9 @@ QVariant pki_crl::column_data(int col)
return QVariant();
}
QVariant pki_crl::getIcon()
QVariant pki_crl::getIcon(int column)
{
return QVariant(*icon);
return column == 0 ? QVariant(*icon) : QVariant();
}
void pki_crl::oldFromData(unsigned char *p, int size)

View File

@ -56,7 +56,7 @@ class pki_crl: public pki_base
x509v3ext getExtByNid(int nid);
a1int getVersion();
QVariant column_data(int col);
QVariant getIcon();
QVariant getIcon(int column);
};
#endif

View File

@ -710,8 +710,10 @@ QVariant pki_evp::column_data(int col)
return QVariant();
}
QVariant pki_evp::getIcon()
QVariant pki_evp::getIcon(int column)
{
if (column != 0)
return QVariant();
int pixnum= isPubKey() ? 1 : 0;
return QVariant(*icon[pixnum]);
}

View File

@ -76,7 +76,7 @@ class pki_evp: public pki_key
int verify();
const EVP_MD *getDefaultMD();
QVariant column_data(int col);
QVariant getIcon();
QVariant getIcon(int column);
};
#endif

View File

@ -607,8 +607,8 @@ QString pki_scard::length()
return bit_length + " bit";
}
QVariant pki_scard::getIcon()
QVariant pki_scard::getIcon(int column)
{
return QVariant(*icon[0]);
return column == 0 ? QVariant(*icon[0]) : QVariant();
}

View File

@ -52,7 +52,7 @@ class pki_scard: public pki_key
void changeSoPin();
int verify();
bool isScard();
QVariant getIcon();
QVariant getIcon(int column);
QList<CK_MECHANISM_TYPE> getMech_list() { return mech_list; };
void setMech_list(QList<CK_MECHANISM_TYPE> ml) { mech_list = ml; };
QList<int> possibleHashNids();

View File

@ -298,9 +298,9 @@ QVariant pki_temp::column_data(int col)
return QVariant();
}
QVariant pki_temp::getIcon()
QVariant pki_temp::getIcon(int column)
{
return QVariant(*icon);
return column == 0 ? QVariant(*icon) : QVariant();
}
void pki_temp::oldFromData(unsigned char *p, int size )

View File

@ -43,7 +43,7 @@ class pki_temp: public pki_base
bool compare(pki_base *ref);
void writeTemp(QString fname);
QVariant column_data(int col);
QVariant getIcon();
QVariant getIcon(int column);
};
#endif

View File

@ -716,9 +716,11 @@ QVariant pki_x509::column_data(int col)
}
QVariant pki_x509::getIcon()
QVariant pki_x509::getIcon(int column)
{
int pixnum = 0;
if (column != 0)
return QVariant();
if (getRefKey()) {
pixnum += 1;

View File

@ -105,7 +105,7 @@ class pki_x509 : public pki_x509super
const EVP_MD *getDigest();
extList getExt();
QVariant column_data(int col);
QVariant getIcon();
QVariant getIcon(int column);
};
#endif

View File

@ -16,7 +16,7 @@
#include <openssl/err.h>
#include <qdir.h>
QPixmap *pki_x509req::icon[3] = { NULL, NULL, NULL };
QPixmap *pki_x509req::icon[4] = { NULL, NULL, NULL, NULL };
pki_x509req::pki_x509req(const QString name)
: pki_x509super(name)
@ -28,7 +28,8 @@ pki_x509req::pki_x509req(const QString name)
spki = NULL;
dataVersion=1;
pkiType=x509_req;
cols=2;
cols=3;
done = false;
}
pki_x509req::~pki_x509req()
@ -445,14 +446,30 @@ QVariant pki_x509req::column_data(int col)
return QVariant(getIntName());
case 1:
return QVariant(getSubject().getEntryByNid(NID_commonName));
case 2:
return QVariant(done ? tr("Signed") : tr("Unhandled"));
}
return QVariant();
}
QVariant pki_x509req::getIcon()
QVariant pki_x509req::getIcon(int column)
{
int pixnum = 0;
if (getRefKey() != NULL ) pixnum = 1;
if (spki != NULL) pixnum = 2;
int pixnum = -1;
switch (column) {
case 0:
pixnum = 0;
if (getRefKey() != NULL )
pixnum = 1;
if (spki != NULL)
pixnum = 2;
break;
case 2:
if (done)
pixnum = 3;
break;
}
if (pixnum == -1)
return QVariant();
return QVariant(*icon[pixnum]);
}

View File

@ -29,10 +29,11 @@ class pki_x509req : public pki_x509super
protected:
X509_REQ *request;
NETSCAPE_SPKI *spki;
bool done;
public:
extList getV3ext();
static QPixmap *icon[3];
static QPixmap *icon[4];
pki_x509req(QString name = "");
void fromPEM_BIO(BIO *bio, QString name);
void fload(const QString fname);
@ -60,7 +61,9 @@ class pki_x509req : public pki_x509super
void set_spki(NETSCAPE_SPKI *_spki);
ASN1_IA5STRING *spki_challange();
QVariant column_data(int col);
QVariant getIcon();
QVariant getIcon(int column);
void setDone() { done = true; }
bool getDone() { return done; }
};
#endif

View File

@ -247,6 +247,7 @@ void MainWindow::init_images()
pki_x509req::icon[0] = loadImg("req.png");
pki_x509req::icon[1] = loadImg("reqkey.png");
pki_x509req::icon[2] = loadImg("spki.png");
pki_x509req::icon[3] = loadImg("done.png");
pki_x509::icon[0] = loadImg("validcert.png");
pki_x509::icon[1] = loadImg("validcertkey.png");
pki_x509::icon[2] = loadImg("invalidcert.png");