From 00eccfe98fc78aee0e5dcc5afcfb8a14e61cef15 Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Tue, 23 Feb 2010 19:17:44 +0100 Subject: [PATCH] add informational messageboxes - for keys, requests, certificates, crls or templates - when successfully created or imported one. --- lang/xca_de.ts | 69 +++++++++++++++++++++++++++++------------ lang/xca_es.ts | 51 +++++++++++++++++++++++++++--- lib/db_base.cpp | 11 +++++++ lib/db_base.h | 1 + lib/db_crl.cpp | 4 +-- lib/db_key.cpp | 4 ++- lib/db_temp.cpp | 1 + lib/db_x509.cpp | 6 ++-- lib/db_x509req.cpp | 4 +-- lib/db_x509super.cpp | 2 +- lib/pki_base.h | 24 ++++++++++---- lib/pki_crl.cpp | 5 +++ lib/pki_crl.h | 1 + lib/pki_evp.cpp | 2 +- lib/pki_key.cpp | 6 ++++ lib/pki_key.h | 2 ++ lib/pki_temp.cpp | 5 +++ lib/pki_temp.h | 2 ++ lib/pki_x509.cpp | 5 +++ lib/pki_x509.h | 1 + lib/pki_x509req.cpp | 4 +++ lib/pki_x509req.h | 17 ++++++++-- ui/CrlDetail.ui | 2 +- widgets/ImportMulti.cpp | 29 +++++++++++------ widgets/ImportMulti.h | 2 +- widgets/MW_database.cpp | 4 +++ 26 files changed, 210 insertions(+), 54 deletions(-) diff --git a/lang/xca_de.ts b/lang/xca_de.ts index b299e044..80638750 100644 --- a/lang/xca_de.ts +++ b/lang/xca_de.ts @@ -10,10 +10,6 @@ CaProperties - - CA properties - CA Einstellungen - Next serial for signing Nächste Seriennummer beim signieren @@ -36,11 +32,11 @@ CA Properties - + CA Einstellungen Use random Serial numbers - + Verwende zufällige Seriennummern @@ -556,6 +552,10 @@ PKCS#8 ist ein offizielles Austauschformat für Passwort gesicherte SchlüsselThe type of the item '%1' is not recognized Unbekannter Typ bei '%1' + + Successfully imported the %1 '%2' + %1 erfolgreich importiert als '%2' + KeyDetail @@ -670,10 +670,6 @@ PKCS#8 ist ein offizielles Austauschformat für Passwort gesicherte SchlüsselThe following error occured: Der folgende Fehler ist aufgetreten: - - &OK - &OK - Copy to Clipboard In die Zwischenablage @@ -938,6 +934,10 @@ PKCS#8 ist ein offizielles Austauschformat für Passwort gesicherte SchlüsselSelect + + Using or exporting private keys will not be possible without providing the correct password + Die Benutzung oder der Export privater Schlüssel ist nur mit dem richtigen Datenbankpasswort möglich + NewCrl @@ -1617,10 +1617,6 @@ though you have declared them as mandatory in the options menu. Advanced Settings Error: %1 - - Organisational unit - - Options @@ -1997,6 +1993,13 @@ Bitte die Zeiten manuell einstellen. &OK + + db_base + + Successfully created the %1 '%2' + %1 erfolgreich erstellt als '%2' + + db_crl @@ -2013,7 +2016,7 @@ Bitte die Zeiten manuell einstellen. No. revoked - Anzahl + Anzahl Next update @@ -2533,6 +2536,10 @@ und wurde daher nicht importiert Unable to load the revokation list in file %1. Tried PEM and DER formatted CRL. Konnte die Sperrliste %1 nicht laden. Ist weder eine PEM noch eine DER formatierte CRL. + + certificate revokation list + Zertifikatssperrliste + pki_evp @@ -2564,10 +2571,6 @@ und wurde daher nicht importiert No password Kein Passwort - - Please enter the database password for decrypting the key - Bitte das Datenbankpasswort zur Entschlüsselung eingeben - Please enter the password to protect the private key: '%1' Bitte geben sie das Passwort zur Verschlüsselung des privaten Schlüssels: '%1' ein @@ -2584,6 +2587,10 @@ und wurde daher nicht importiert Please enter the export password for the private key '%1' Bitte das Passwort zum Schutz des privaten Schlüssels '%1' eingeben + + Please enter the database password for decrypting the key '%1' + Bitte das Datenbankpasswort zur Entschlüsselung des Schlüssels '%1' eingeben + pki_key @@ -2611,6 +2618,14 @@ und wurde daher nicht importiert PIN PIN + + %1 public key + Öffentlicher %1 Schlüssel + + + %1 private key + Privater %1 Schlüssel + pki_multi @@ -2710,6 +2725,10 @@ und wurde daher nicht importiert Template file content error (bad length) :%1 Templatefile ungültig (länge): %1 + + XCA template + XCA Vorlage + pki_x509 @@ -2749,6 +2768,10 @@ und wurde daher nicht importiert Delete the certificate '%1' from the token '%2 (#%3)' ? Das Zertifikat '%1' von der Smartcard '%2 (#%3)' löschen ? + + certificate + Zertifikat + pki_x509req @@ -2768,6 +2791,14 @@ und wurde daher nicht importiert Unhandled Unbehandelt + + SPKAC request + SPKAC Zertifikatsanfrage + + + PKCS#10 request + PKCS#10 Zertifikatsanfrage + v3ext diff --git a/lang/xca_es.ts b/lang/xca_es.ts index c686cdf1..19cc0db0 100644 --- a/lang/xca_es.ts +++ b/lang/xca_es.ts @@ -552,6 +552,10 @@ PKCS#8 es un formato estandar de intercambio de claves The type of the item '%1' is not recognized + + Successfully imported the %1 '%2' + + KeyDetail @@ -930,6 +934,10 @@ PKCS#8 es un formato estandar de intercambio de claves Select + + Using or exporting private keys will not be possible without providing the correct password + + NewCrl @@ -1982,6 +1990,13 @@ You must set it manually. + + db_base + + Successfully created the %1 '%2' + + + db_crl @@ -2507,6 +2522,10 @@ and thus was not stored Unable to load the revokation list in file %1. Tried PEM and DER formatted CRL. + + certificate revokation list + + pki_evp @@ -2538,10 +2557,6 @@ and thus was not stored No password - - Please enter the database password for decrypting the key - - Please enter the password to protect the private key: '%1' @@ -2558,6 +2573,10 @@ and thus was not stored Please enter the export password for the private key '%1' + + Please enter the database password for decrypting the key '%1' + + pki_key @@ -2585,6 +2604,14 @@ and thus was not stored PIN + + %1 public key + + + + %1 private key + + pki_multi @@ -2684,6 +2711,10 @@ and thus was not stored Template file content error (bad length) :%1 + + XCA template + + pki_x509 @@ -2723,6 +2754,10 @@ and thus was not stored Delete the certificate '%1' from the token '%2 (#%3)' ? + + certificate + + pki_x509req @@ -2742,6 +2777,14 @@ and thus was not stored Unhandled + + SPKAC request + + + + PKCS#10 request + + v3ext diff --git a/lib/db_base.cpp b/lib/db_base.cpp index 12cdec49..cbf792b1 100644 --- a/lib/db_base.cpp +++ b/lib/db_base.cpp @@ -39,6 +39,17 @@ pki_base *db_base::newPKI(db_header_t *head){ return new pki_base("rootItem"); } +void db_base::createSuccess(pki_base *pki) +{ + if (!pki) + return; + + QMessageBox::information(mainwin, XCA_TITLE, + tr("Successfully created the %1 '%2'"). + arg(pki->getFriendlyClassName()). + arg(pki->getIntName())); +} + void db_base::remFromCont(QModelIndex &idx) { if (!idx.isValid()) diff --git a/lib/db_base.h b/lib/db_base.h index 1bc52d23..38358081 100644 --- a/lib/db_base.h +++ b/lib/db_base.h @@ -80,6 +80,7 @@ class db_base: public QAbstractItemModel void storeSelectedItems(XcaTreeView *view); void load_default(load_base &load); void insertChild(pki_base *parent, pki_base *child); + void createSuccess(pki_base *pki); public slots: void deletePKI(); diff --git a/lib/db_crl.cpp b/lib/db_crl.cpp index 50362eaf..15af8e32 100644 --- a/lib/db_crl.cpp +++ b/lib/db_crl.cpp @@ -94,7 +94,7 @@ pki_base *db_crl::insert(pki_base *item) QMessageBox::information(mainwin, XCA_TITLE, tr("The revokation list already exists in the database as:\n'%1'\nand so it was not imported").arg(oldcrl->getIntName())); delete(crl); - return oldcrl; + return NULL; } insertPKI(crl); return crl; @@ -211,7 +211,7 @@ pki_crl *db_crl::newItem(pki_x509 *cert) crl->sign(cert->getRefKey(), ui.hashAlgo->currentHash()); mainwin->certs->updatePKI(cert); - insert(crl); + createSuccess(insert(crl)); } catch (errorEx &err) { MainWindow::Error(err); diff --git a/lib/db_key.cpp b/lib/db_key.cpp index 7da0b901..40bff522 100644 --- a/lib/db_key.cpp +++ b/lib/db_key.cpp @@ -96,7 +96,7 @@ pki_base* db_key::insert(pki_base *item) QMessageBox::information(mainwin, XCA_TITLE, tr("The key is already in the database as:\n'%1'\nand is not going to be imported").arg(oldkey->getIntName())); delete(lkey); - return oldkey; + return NULL; } else { QMessageBox::information(mainwin, XCA_TITLE, @@ -162,6 +162,8 @@ void db_key::newItem(QString name) } key = (pki_key*)insert(key); emit keyDone(key->getIntNameWithType()); + createSuccess(key); + } catch (errorEx &err) { delete key; mainwin->Error(err); diff --git a/lib/db_temp.cpp b/lib/db_temp.cpp index f349e395..934d4540 100644 --- a/lib/db_temp.cpp +++ b/lib/db_temp.cpp @@ -136,6 +136,7 @@ void db_temp::newItem() temp->setIntName("--"); if (runTempDlg(temp)) { insertPKI(temp); + createSuccess(temp); return; } } diff --git a/lib/db_x509.cpp b/lib/db_x509.cpp index 5f95b226..b97dcff2 100644 --- a/lib/db_x509.cpp +++ b/lib/db_x509.cpp @@ -315,7 +315,7 @@ pki_base *db_x509::insert(pki_base *item) QMessageBox::information(mainwin, XCA_TITLE, tr("The certificate already exists in the database as:\n'%1'\nand so it was not imported").arg(oldcert->getIntName())); delete(cert); - return oldcert; + return NULL; } cert->setCaSerial((cert->getSerial())); insertPKI(cert); @@ -542,7 +542,7 @@ void db_x509::newCert(NewX509 *dlg) #endif // and finally sign the request cert->sign(signkey, hashAlgo); - insert(cert); + createSuccess(insert(cert)); updatePKI(signcert); if (tempkey != NULL) delete(tempkey); @@ -1048,7 +1048,7 @@ void db_x509::toRequest() req->setIntName(cert->getIntName()); req->createReq(cert->getRefKey(), cert->getSubject(), cert->getRefKey()->getDefaultMD(), cert->getV3ext()); - mainwin->reqs->insert(req); + createSuccess(mainwin->reqs->insert(req)); } catch (errorEx &err) { mainwin->Error(err); diff --git a/lib/db_x509req.cpp b/lib/db_x509req.cpp index be3c687d..c38fdcae 100644 --- a/lib/db_x509req.cpp +++ b/lib/db_x509req.cpp @@ -41,7 +41,7 @@ pki_base *db_x509req::insert(pki_base *item) QMessageBox::information(mainwin, XCA_TITLE, tr("The certificate signing request already exists in the database as\n'%1'\nand thus was not stored").arg(oldreq->getIntName())); delete(req); - return oldreq; + return NULL; } insertPKI(req); return req; @@ -71,7 +71,7 @@ void db_x509req::newItem(pki_temp *temp) dlg->initCtx(NULL, NULL, req); dlg->addReqAttributes(req); req->createReq(key, xn, dlg->hashAlgo->currentHash(), dlg->getAllExt()); - insert(req); + createSuccess(insert(req)); } catch (errorEx &err) { MainWindow::Error(err); diff --git a/lib/db_x509super.cpp b/lib/db_x509super.cpp index 3c93e983..b571e4d6 100644 --- a/lib/db_x509super.cpp +++ b/lib/db_x509super.cpp @@ -86,7 +86,7 @@ void db_x509super::toTemplate() d->exec(); delete d; } - mainwin->temps->insert(temp); + createSuccess(mainwin->temps->insert(temp)); } catch (errorEx &err) { mainwin->Error(err); diff --git a/lib/pki_base.h b/lib/pki_base.h index b14386fe..c53d0781 100644 --- a/lib/pki_base.h +++ b/lib/pki_base.h @@ -37,19 +37,28 @@ class pki_base : public QObject QList childItems; pki_base(const QString d = "", pki_base *p = NULL); virtual void fload(const QString) {}; - virtual void writeDefault(const QString){}; + virtual void writeDefault(const QString) {}; static int get_pki_counter(void); - virtual void fromData(const unsigned char *, db_header_t *){}; + virtual void fromData(const unsigned char *, db_header_t *) {}; virtual void oldFromData(unsigned char *p, int size); - virtual unsigned char *toData(int *) { return NULL; } - virtual bool compare(pki_base *) { return false; }; + virtual unsigned char *toData(int *) + { + return NULL; + } + virtual bool compare(pki_base *) + { + return false; + }; virtual ~pki_base(); QString getIntName() const; QString getUnderlinedName() const; void setIntName(const QString &d); QString getClassName(); static QString rmslashdot(const QString &fname); - + virtual QString getFriendlyClassName() + { + return QString("---"); + }; int getVersion(); enum pki_type getType(); void setParent(pki_base *p); @@ -65,7 +74,10 @@ class pki_base : public QObject int columns(); virtual QVariant column_data(int col); virtual QVariant getIcon(int column); - const char *className() { return class_name; }; + const char *className() + { + return class_name; + }; uint32_t intFromData(const unsigned char **p); virtual void fromPEM_BIO(BIO *, QString) {}; virtual void deleteFromToken() { }; diff --git a/lib/pki_crl.cpp b/lib/pki_crl.cpp index f366718f..8148e7bc 100644 --- a/lib/pki_crl.cpp +++ b/lib/pki_crl.cpp @@ -35,6 +35,11 @@ void pki_crl::fromPEM_BIO(BIO *bio, QString name) setIntName(rmslashdot(name)); } +QString pki_crl::getFriendlyClassName() +{ + return tr("certificate revokation list"); +} + void pki_crl::fload(const QString fname ) { FILE *fp = fopen(QString2filename(fname), "r"); diff --git a/lib/pki_crl.h b/lib/pki_crl.h index 31fed2dc..6dcc969d 100644 --- a/lib/pki_crl.h +++ b/lib/pki_crl.h @@ -57,6 +57,7 @@ class pki_crl: public pki_base a1int getVersion(); QVariant column_data(int col); QVariant getIcon(int column); + virtual QString getFriendlyClassName(); }; #endif diff --git a/lib/pki_evp.cpp b/lib/pki_evp.cpp index 188f3b9e..cfef7a07 100644 --- a/lib/pki_evp.cpp +++ b/lib/pki_evp.cpp @@ -390,7 +390,7 @@ EVP_PKEY *pki_evp::decryptKey() const int ret; //printf("Passhash= '%s', new hash= '%s', passwd= '%s'\n", //CCHAR(passHash), CCHAR(md5passwd(ownPassBuf)), ownPassBuf); - pass_info p(XCA_TITLE, tr("Please enter the database password for decrypting the key")); + pass_info p(XCA_TITLE, tr("Please enter the database password for decrypting the key '%1'").arg(getIntName())); ret = MainWindow::passRead(ownPassBuf, MAX_PASS_LENGTH, 0, &p); if (ret < 0) throw errorEx(tr("Password input aborted"), class_name); diff --git a/lib/pki_key.cpp b/lib/pki_key.cpp index c7853907..21a945f3 100644 --- a/lib/pki_key.cpp +++ b/lib/pki_key.cpp @@ -63,6 +63,12 @@ QString pki_key::getTypeString() return type; } +QString pki_key::getFriendlyClassName() +{ + QString txt = isPubKey() ? tr("%1 public key") : tr("%1 private key"); + return txt.arg(getTypeString()); +} + QString pki_key::getIntNameWithType() { return getIntName() + " (" + getTypeString() + ")"; diff --git a/lib/pki_key.h b/lib/pki_key.h index 6d4d0947..9ffffba1 100644 --- a/lib/pki_key.h +++ b/lib/pki_key.h @@ -44,6 +44,8 @@ class pki_key: public pki_base virtual QString getIntNameWithType(void); virtual QList possibleHashNids() { return QList(); }; + virtual QString getFriendlyClassName(); + void writePublic(const QString fname, bool pem); bool compare(pki_base *ref); diff --git a/lib/pki_temp.cpp b/lib/pki_temp.cpp index eafe0222..58db721f 100644 --- a/lib/pki_temp.cpp +++ b/lib/pki_temp.cpp @@ -90,6 +90,11 @@ pki_temp::pki_temp(const QString d) noWellDefined=false; } +QString pki_temp::getFriendlyClassName() +{ + return tr("XCA template"); +} + static QStringList extVlistToString(extList &el, int nid, bool *crit) { int i = el.idxByNid(nid); diff --git a/lib/pki_temp.h b/lib/pki_temp.h index a43bec48..5e736da7 100644 --- a/lib/pki_temp.h +++ b/lib/pki_temp.h @@ -46,6 +46,8 @@ class pki_temp: public pki_base void writeTemp(QString fname); QVariant column_data(int col); QVariant getIcon(int column); + virtual QString getFriendlyClassName(); + }; #endif diff --git a/lib/pki_x509.cpp b/lib/pki_x509.cpp index bb315cf1..d0c24369 100644 --- a/lib/pki_x509.cpp +++ b/lib/pki_x509.cpp @@ -56,6 +56,11 @@ pki_x509::pki_x509(const QString name) openssl_error(); } +QString pki_x509::getFriendlyClassName() +{ + return tr("certificate"); +} + void pki_x509::fromPEM_BIO(BIO *bio, QString name) { X509 *_cert; diff --git a/lib/pki_x509.h b/lib/pki_x509.h index ed7cbb9d..4402c77b 100644 --- a/lib/pki_x509.h +++ b/lib/pki_x509.h @@ -137,6 +137,7 @@ class pki_x509 : public pki_x509super QVariant getIcon(int column); QByteArray i2d(); void deleteFromToken(); + virtual QString getFriendlyClassName(); }; #endif diff --git a/lib/pki_x509req.cpp b/lib/pki_x509req.cpp index 32e02ace..7633ffc2 100644 --- a/lib/pki_x509req.cpp +++ b/lib/pki_x509req.cpp @@ -75,6 +75,10 @@ void pki_x509req::createReq(pki_key *key, const x509name &dn, const EVP_MD *md, EVP_PKEY_free(privkey); } +QString pki_x509req::getFriendlyClassName() +{ + return isSpki() ? tr("SPKAC request") : tr("PKCS#10 request"); +} void pki_x509req::fromPEM_BIO(BIO *bio, QString name) { diff --git a/lib/pki_x509req.h b/lib/pki_x509req.h index b2bd85f0..cb7b6555 100644 --- a/lib/pki_x509req.h +++ b/lib/pki_x509req.h @@ -46,7 +46,10 @@ class pki_x509req : public pki_x509super x509name getSubject() const; bool isSpki() const; void writeReq(const QString fname, bool pem); - X509_REQ *getReq() {return request;} + X509_REQ *getReq() + { + return request; + } void addAttribute(int nid, QString content); int verify(); @@ -59,8 +62,16 @@ class pki_x509req : public pki_x509super ASN1_IA5STRING *spki_challange(); QVariant column_data(int col); QVariant getIcon(int column); - void setDone() { done = true; } - bool getDone() { return done; } + void setDone() + { + done = true; + } + bool getDone() + { + return done; + } + virtual QString getFriendlyClassName(); + }; #endif diff --git a/ui/CrlDetail.ui b/ui/CrlDetail.ui index a6f9452f..56299cea 100644 --- a/ui/CrlDetail.ui +++ b/ui/CrlDetail.ui @@ -83,7 +83,7 @@ - 3 + 0 diff --git a/widgets/ImportMulti.cpp b/widgets/ImportMulti.cpp index 89ae3b76..1e756bfa 100644 --- a/widgets/ImportMulti.cpp +++ b/widgets/ImportMulti.cpp @@ -119,13 +119,13 @@ void ImportMulti::on_butImport_clicked() } } -void ImportMulti::import(QModelIndex &idx) +pki_base *ImportMulti::import(QModelIndex &idx) { pki_base *pki = static_cast(idx.internalPointer()); if (!pki) - return; + return NULL; if (!mainwin->keys) { mainwin->load_database(); } @@ -134,28 +134,30 @@ void ImportMulti::import(QModelIndex &idx) mcont->remFromCont(idx); if (!mainwin->keys) { delete pki; - return; + return NULL; } if (cn == "pki_x509") { - MainWindow::certs->insert(pki); + pki = MainWindow::certs->insert(pki); } else if (cn == "pki_evp") { ((pki_evp*)pki)->setOwnPass(pki_evp::ptCommon); - MainWindow::keys->insert(pki); + pki = MainWindow::keys->insert(pki); } else if (cn == "pki_scard") { - MainWindow::keys->insert(pki); + pki = MainWindow::keys->insert(pki); } else if (cn == "pki_x509req") { - MainWindow::reqs->insert(pki); + pki = MainWindow::reqs->insert(pki); } else if (cn == "pki_crl") { - MainWindow::crls->insert(pki); + pki = MainWindow::crls->insert(pki); } else if (cn == "pki_temp") { - MainWindow::temps->insert(pki); + pki = MainWindow::temps->insert(pki); } else { QMessageBox::warning(this, XCA_TITLE, tr("The type of the Item '%1' is not recognized"). arg(cn)); delete pki; + return NULL; } + return pki; } void ImportMulti::on_butDetails_clicked() @@ -239,7 +241,14 @@ void ImportMulti::execute(int force) return; /* if there is only 1 item and force is 0 import it silently */ if (entries() == 1 && force == 0) { - on_butOk_clicked(); + QModelIndex idx = mcont->index(0, 0, QModelIndex()); + pki_base *pki = import(idx); + if (pki) + QMessageBox::information(this, XCA_TITLE, + tr("Successfully imported the %1 '%2'"). + arg(pki->getFriendlyClassName()). + arg(pki->getIntName())); + accept(); return; } /* the behavoiour for more than one item */ diff --git a/widgets/ImportMulti.h b/widgets/ImportMulti.h index 302dbfc9..a462221e 100644 --- a/widgets/ImportMulti.h +++ b/widgets/ImportMulti.h @@ -27,7 +27,7 @@ class ImportMulti: public QDialog, private Ui::ImportMulti ~ImportMulti(); void addItem(pki_base *pki); pki_base *getSelected(); - void import(QModelIndex &idx); + pki_base *import(QModelIndex &idx); void execute(int force=0); int entries(); diff --git a/widgets/MW_database.cpp b/widgets/MW_database.cpp index 60daed50..9fd0b164 100644 --- a/widgets/MW_database.cpp +++ b/widgets/MW_database.cpp @@ -121,6 +121,10 @@ void MainWindow::init_database() } setWindowTitle(tr(XCA_TITLE)); setItemEnabled(true); + if (pki_evp::passwd[0] == '\0') + QMessageBox::information(this, XCA_TITLE, + tr("Using or exporting private keys will not be possible without providing the correct password")); + dbindex->setText(tr("Database") + ":" + dbfile); load_engine(); }