mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
SF Feat. Req. #70 ability to search certificates
Add a Search line into the status bar to quickly limit the view of items to those matching the wildcard pattern case insensitive.
This commit is contained in:
parent
f5434dd6f3
commit
cb6dc4427d
@ -1,3 +1,4 @@
|
||||
* SF Feat. Req. #70 ability to search certificates
|
||||
* SF Feat. Req. #75 show SHA-256 digest
|
||||
* RedHat Bug #1164340 - segfault when viewing a
|
||||
RHEL entitlement certificate
|
||||
|
||||
@ -579,9 +579,10 @@ QVariant db_base::data(const QModelIndex &index, int role) const
|
||||
return QVariant(QFont("Monospace"));
|
||||
return QVariant(QApplication::font());
|
||||
}
|
||||
case Qt::BackgroundRole: {
|
||||
case Qt::BackgroundRole:
|
||||
return item->bg_color(hd);
|
||||
}
|
||||
case Qt::UserRole:
|
||||
return item->visible();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
int pki_base::pki_counter = 0;
|
||||
int pki_base::suppress_messages = 0;
|
||||
QRegExp pki_base::limitPattern;
|
||||
|
||||
pki_base::pki_base(const QString name, pki_base *p)
|
||||
{
|
||||
@ -37,7 +38,7 @@ enum pki_type pki_base::getType()
|
||||
|
||||
pki_base::~pki_base(void)
|
||||
{
|
||||
while((childCount()))
|
||||
while (childItems.size() > 0)
|
||||
delete takeFirst();
|
||||
pki_counter--;
|
||||
}
|
||||
@ -53,6 +54,13 @@ QString pki_base::getUnderlinedName() const
|
||||
return getIntName().replace(QRegExp("[ &;`/\\\\]+"), "_");
|
||||
}
|
||||
|
||||
bool pki_base::visible()
|
||||
{
|
||||
if (limitPattern.isEmpty())
|
||||
return true;
|
||||
return getIntName().contains(limitPattern);
|
||||
}
|
||||
|
||||
int pki_base::get_pki_counter()
|
||||
{
|
||||
return pki_counter;
|
||||
@ -130,7 +138,7 @@ void pki_base::insert(int row, pki_base *item)
|
||||
|
||||
int pki_base::childCount()
|
||||
{
|
||||
return childItems.count();
|
||||
return childItems.size();
|
||||
}
|
||||
|
||||
int pki_base::row(void) const
|
||||
|
||||
@ -32,7 +32,6 @@ class pki_base : public QObject
|
||||
enum pki_type pkiType;
|
||||
/* model data */
|
||||
pki_base *parent;
|
||||
|
||||
void my_error(const QString myerr) const;
|
||||
void fopen_error(const QString fname);
|
||||
|
||||
@ -44,6 +43,7 @@ class pki_base : public QObject
|
||||
msg_create,
|
||||
};
|
||||
static int suppress_messages;
|
||||
static QRegExp limitPattern;
|
||||
QList<pki_base*> childItems;
|
||||
pki_base(const QString d = "", pki_base *p = NULL);
|
||||
virtual void fload(const QString) {};
|
||||
@ -56,6 +56,7 @@ class pki_base : public QObject
|
||||
return QByteArray();
|
||||
}
|
||||
virtual bool compare(pki_base *);
|
||||
virtual bool visible();
|
||||
virtual ~pki_base();
|
||||
QString getIntName() const;
|
||||
QString getUnderlinedName() const;
|
||||
|
||||
@ -168,6 +168,16 @@ void pki_crl::addV3ext(const x509v3ext &e)
|
||||
pki_openssl_error();
|
||||
}
|
||||
|
||||
bool pki_crl::visible()
|
||||
{
|
||||
extList el;
|
||||
if (pki_x509name::visible())
|
||||
return true;
|
||||
if (getSigAlg().contains(limitPattern))
|
||||
return true;
|
||||
el.setStack(crl->crl->extensions);
|
||||
return el.search(limitPattern);
|
||||
}
|
||||
|
||||
void pki_crl::sign(pki_key *key, const EVP_MD *md)
|
||||
{
|
||||
|
||||
@ -69,6 +69,7 @@ class pki_crl: public pki_x509name
|
||||
void setCrlNumber(a1int num);
|
||||
bool getCrlNumber(a1int *num);
|
||||
BIO *pem(BIO *);
|
||||
bool visible();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -777,3 +777,17 @@ QVariant pki_scard::getIcon(dbheader *hd)
|
||||
return hd->id == HD_internal_name ? QVariant(*icon[0]) : QVariant();
|
||||
}
|
||||
|
||||
bool pki_scard::visible()
|
||||
{
|
||||
QStringList sl;
|
||||
if (pki_base::visible())
|
||||
return true;
|
||||
|
||||
sl << card_serial << card_manufacturer << card_model <<
|
||||
card_label << slot_label << object_id;
|
||||
foreach(QString s, sl) {
|
||||
if (s.contains(limitPattern))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -87,8 +87,9 @@ class pki_scard: public pki_key
|
||||
void deleteFromToken();
|
||||
void deleteFromToken(slotid slot);
|
||||
void store_token(slotid slot, EVP_PKEY *pkey);
|
||||
virtual int renameOnToken(slotid slot, QString name);
|
||||
virtual QString getMsg(msg_type msg);
|
||||
int renameOnToken(slotid slot, QString name);
|
||||
QString getMsg(msg_type msg);
|
||||
bool visible();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -899,6 +899,23 @@ const EVP_MD *pki_x509::getDigest()
|
||||
return EVP_get_digestbyobj(cert->sig_alg->algorithm);
|
||||
}
|
||||
|
||||
bool pki_x509::visible()
|
||||
{
|
||||
if (pki_x509super::visible())
|
||||
return true;
|
||||
if (getIssuer().search(limitPattern))
|
||||
return true;
|
||||
if (fingerprint(EVP_md5()).contains(limitPattern))
|
||||
return true;
|
||||
if (fingerprint(EVP_sha1()).contains(limitPattern))
|
||||
return true;
|
||||
if (fingerprint(EVP_sha256()).contains(limitPattern))
|
||||
return true;
|
||||
if (getSerial().toHex().contains(limitPattern))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant pki_x509::bg_color(dbheader *hd)
|
||||
{
|
||||
#define BG_RED QBrush(QColor(255, 0, 0))
|
||||
|
||||
@ -137,6 +137,7 @@ class pki_x509 : public pki_x509super
|
||||
void setCrlExpiry(const a1time &time);
|
||||
bool hasExtension(int nid);
|
||||
bool cmpIssuerAndSerial(pki_x509 *refcert);
|
||||
bool visible();
|
||||
void updateView();
|
||||
x509rev getRev(bool reason = true);
|
||||
QString getSigAlg();
|
||||
|
||||
@ -442,6 +442,17 @@ QVariant pki_x509req::getIcon(dbheader *hd)
|
||||
return QVariant(*icon[pixnum]);
|
||||
}
|
||||
|
||||
bool pki_x509req::visible()
|
||||
{
|
||||
if (pki_x509super::visible())
|
||||
return true;
|
||||
if (getAttribute(request, NID_pkcs9_unstructuredName).contains(limitPattern))
|
||||
return true;
|
||||
if (getAttribute(request, NID_pkcs9_challengePassword).contains(limitPattern))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void pki_x509req::oldFromData(unsigned char *p, int size)
|
||||
{
|
||||
QByteArray ba((const char *)p, size);
|
||||
|
||||
@ -76,6 +76,7 @@ class pki_x509req : public pki_x509super
|
||||
QByteArray i2d();
|
||||
QByteArray i2d_spki();
|
||||
BIO *pem(BIO *);
|
||||
bool visible();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -121,6 +121,16 @@ void pki_x509super::opensslConf(QString fname)
|
||||
fwrite_ba(fp, ba, fname);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
bool pki_x509super::visible()
|
||||
{
|
||||
if (pki_x509name::visible())
|
||||
return true;
|
||||
if (getSigAlg().contains(limitPattern))
|
||||
return true;
|
||||
return getV3ext().search(limitPattern);
|
||||
}
|
||||
|
||||
// Start class pki_x509name
|
||||
|
||||
pki_x509name::pki_x509name(const QString name)
|
||||
@ -148,3 +158,10 @@ QVariant pki_x509name::column_data(dbheader *hd)
|
||||
}
|
||||
return pki_base::column_data(hd);
|
||||
}
|
||||
|
||||
bool pki_x509name::visible()
|
||||
{
|
||||
if (pki_base::visible())
|
||||
return true;
|
||||
return getSubject().search(limitPattern);
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ class pki_x509name : public pki_base
|
||||
};
|
||||
void autoIntName();
|
||||
QVariant column_data(dbheader *hd);
|
||||
bool visible();
|
||||
};
|
||||
|
||||
class pki_x509super : public pki_x509name
|
||||
@ -55,6 +56,7 @@ class pki_x509super : public pki_x509name
|
||||
void delRefKey(pki_key *ref);
|
||||
QVariant column_data(dbheader *hd);
|
||||
void opensslConf(QString fname);
|
||||
bool visible();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -229,6 +229,16 @@ QString x509name::checkLength() const
|
||||
return warn;
|
||||
}
|
||||
|
||||
bool x509name::search(const QRegExp &pattern)
|
||||
{
|
||||
int i, max = entryCount();
|
||||
for (i=0; i<max; i++) {
|
||||
if (getEntry(i).contains(pattern))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString x509name::taggedValues() const
|
||||
{
|
||||
int i, max = entryCount();
|
||||
|
||||
@ -43,6 +43,7 @@ class x509name
|
||||
QString getMostPopular() const;
|
||||
QString taggedValues() const;
|
||||
QString hash() const;
|
||||
bool search(const QRegExp &pattern);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -794,6 +794,13 @@ STACK_OF(X509_EXTENSION) *extList::getStack()
|
||||
return sk;
|
||||
}
|
||||
|
||||
bool extList::search(const QRegExp &pattern)
|
||||
{
|
||||
for (int i=0; i < size(); i++)
|
||||
if (at(i).getValue(false).contains(pattern))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
QString extList::getHtml(const QString &sep)
|
||||
{
|
||||
x509v3ext e;
|
||||
|
||||
@ -63,5 +63,6 @@ class extList : public QList<x509v3ext>
|
||||
int idxByNid(int nid);
|
||||
bool genConf(int nid, QString *single, QString *adv = NULL);
|
||||
void genGenericConf(QString *adv);
|
||||
bool search(const QRegExp &pattern);
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -57,6 +57,9 @@ int MainWindow::init_database()
|
||||
return ret;
|
||||
}
|
||||
|
||||
searchEdit->setText("");
|
||||
searchEdit->show();
|
||||
statusBar()->addWidget(searchEdit, 1);
|
||||
mandatory_dn = "";
|
||||
explicit_dn = explicit_dn_default;
|
||||
|
||||
@ -290,6 +293,7 @@ void MainWindow::close_database()
|
||||
setting, "mw_geometry");
|
||||
}
|
||||
setItemEnabled(false);
|
||||
statusBar()->removeWidget(searchEdit);
|
||||
dbindex->clear();
|
||||
|
||||
keyView->setModel(NULL);
|
||||
|
||||
@ -133,6 +133,26 @@ MainWindow::MainWindow(QWidget *parent )
|
||||
connect(this, SIGNAL(newURLs(QStringList &)),
|
||||
this, SLOT(openURLs(QStringList &)));
|
||||
setAcceptDrops(true);
|
||||
|
||||
searchEdit = new QLineEdit();
|
||||
// searchEdit->setMinimumWidth(220);
|
||||
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)),
|
||||
keyView, SLOT(setFilter(const QString&)));
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)),
|
||||
reqView, SLOT(setFilter(const QString&)));
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)),
|
||||
certView, SLOT(setFilter(const QString&)));
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)),
|
||||
tempView, SLOT(setFilter(const QString&)));
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)),
|
||||
crlView, SLOT(setFilter(const QString&)));
|
||||
|
||||
keyView->setModel(keys);
|
||||
reqView->setModel(reqs);
|
||||
certView->setModel(certs);
|
||||
tempView->setModel(temps);
|
||||
crlView->setModel(crls);
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event)
|
||||
|
||||
@ -77,6 +77,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
tipMenu *historyMenu;
|
||||
void update_history_menu();
|
||||
void set_geometry(char *p, db_header_t *head);
|
||||
QLineEdit *searchEdit;
|
||||
|
||||
protected:
|
||||
void init_images();
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QRegExp>
|
||||
|
||||
|
||||
XcaTreeView::XcaTreeView(QWidget *parent)
|
||||
@ -147,6 +148,14 @@ void XcaTreeView::editIdx(const QModelIndex &idx)
|
||||
edit(proxy->mapFromSource(idx));
|
||||
}
|
||||
|
||||
void XcaTreeView::setFilter(const QString &pattern)
|
||||
{
|
||||
pki_base::limitPattern = QRegExp(pattern,
|
||||
Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
// Only to tell the model about the changed filter
|
||||
proxy->setFilterFixedString(pattern);
|
||||
}
|
||||
|
||||
XcaProxyModel::XcaProxyModel(QWidget *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
@ -176,6 +185,13 @@ bool XcaProxyModel::lessThan(const QModelIndex &left,
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
bool XcaProxyModel::filterAcceptsRow(int sourceRow,
|
||||
const QModelIndex &sourceParent) const
|
||||
{
|
||||
QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
return sourceModel()->data(idx, Qt::UserRole).toBool();
|
||||
}
|
||||
|
||||
void XcaHeaderView::contextMenuEvent(QContextMenuEvent * e)
|
||||
{
|
||||
XcaTreeView *tv = (XcaTreeView *)parentWidget();
|
||||
|
||||
@ -51,6 +51,7 @@ class XcaTreeView: public QTreeView
|
||||
void sectionMoved(int idx, int oldI, int newI);
|
||||
void columnsResize();
|
||||
void editIdx(const QModelIndex &idx);
|
||||
void setFilter(const QString &pattern);
|
||||
};
|
||||
|
||||
class XcaProxyModel: public QSortFilterProxyModel
|
||||
@ -59,6 +60,8 @@ class XcaProxyModel: public QSortFilterProxyModel
|
||||
public:
|
||||
XcaProxyModel(QWidget *parent = 0);
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
bool filterAcceptsRow(int sourceRow,
|
||||
const QModelIndex &sourceParent) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user