1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
/* vi: set sw=4 ts=4:
*
* Copyright (C) 2001 - 2012 Christian Hohnstaedt.
*
* All rights reserved.
*/
#include <openssl/objects.h>
#include "OidResolver.h"
#include "lib/oid.h"
#include "lib/base.h"
#include "lib/func.h"
#include "lib/exception.h"
OidResolver::OidResolver(QWidget *parent)
:QWidget(parent)
{
setupUi(this);
setWindowTitle(XCA_TITLE);
}
void OidResolver::searchOid(QString s)
{
bool ok;
int n;
if (input->text() != s) // Avoid moving the cursor at end if unchanged.
input->setText(s);
s = s.trimmed();
n = s.toUInt(&ok);
if (!ok)
n = OBJ_txt2nid(CCHAR(s));
if (n == NID_undef) {
const char *clash = oid_name_clash[s];
if (clash)
n = OBJ_txt2nid(clash);
}
QString lo = s.toLower();
if (n == NID_undef && s != lo)
n = OBJ_txt2nid(CCHAR(lo));
if (n == NID_undef && oid_lower_map.contains(lo))
n = oid_lower_map[lo];
ign_openssl_error();
if (n == NID_undef) {
ln->clear();
sn->clear();
oid->clear();
nid->clear();
} else {
const ASN1_OBJECT *a = OBJ_nid2obj(n);
ln->setText(OBJ_nid2ln(n));
sn->setText(OBJ_nid2sn(n));
nid->setText(QString("%1").arg(n));
if (a) {
try {
oid->setText(OBJ_obj2QString(a, 1));
} catch (errorEx &) {
oid->clear();
}
} else {
oid->clear();
}
}
ign_openssl_error();
show();
raise();
}
|