diff --git a/CertView.cpp b/CertView.cpp deleted file mode 100644 index 795f5a79..00000000 --- a/CertView.cpp +++ /dev/null @@ -1,1292 +0,0 @@ -/* - * 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 "CertView.h" -#include "widgets/MainWindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ui/CertExtend.h" -#include "widgets/ExportCert.h" -#include "ui/CertDetail.h" -#include "ui/TrustState.h" -#include "widgets/ExportTinyCA.h" -#include "validity.h" -#include "lib/pki_pkcs12.h" -#include "lib/pki_pkcs7.h" - -#ifdef WIN32 -#include // to define mkdir function -#include // to define mkdir function -#else -#include -#include -#include -#endif - -CertView::CertView(QWidget * parent = 0, const char * name = 0, WFlags f = 0) - :XcaListView(parent, name, f) -{ - addColumn(tr("Common Name")); - addColumn(tr("Serial")); - addColumn(tr("not After")); - addColumn(tr("Trust state")); - addColumn(tr("Revokation")); - viewState=1; // Tree View -} - - -void CertView::newItem() -{ - NewX509 *dlg = MainWindow::newX509(MainWindow::certImg); - dlg->setCert(); - if (dlg->exec()) { - newCert(dlg); - } - delete dlg; -} - - -void CertView::newCert(NewX509 *dlg) -{ - pki_x509 *cert = NULL; - pki_x509 *signcert = NULL; - pki_x509req *req = NULL; - pki_key *signkey = NULL, *clientkey = NULL, *tempkey = NULL; - a1int serial; - a1time notBefore, notAfter; - x509name subject; - int i; - const QString critical = "critical"; - - QStringList cont; - - QString ekeyusage[]= {"serverAuth","clientAuth","codeSigning","emailProtection", - "timeStamping","msCodeInd","msCodeCom", - "msCTLSign","msSGC","msEFS","nsSGC","1.3.6.1.4.1.311.10.3.4.1"}; - QString keyusage[] ={"digitalSignature", "nonRepudiation", "keyEncipherment", - "dataEncipherment", "keyAgreement", "keyCertSign", - "cRLSign", "encipherOnly", "decipherOnly"}; - QString certTypeList[] = { "client", "server", "email", "objsign", - "sslCA", "emailCA", "objCA" }; - - QListBoxItem *item; - - emit init_database(); - - try { - // Step 1 - Subject and key - if (!dlg->fromReqCB->isChecked()) { - clientkey = dlg->getSelectedKey(); - subject = dlg->getX509name(); - } - else { - // A PKCS#10 Request was selected - req = (pki_x509req *)MainWindow::reqs->getByName(dlg->reqList->currentText()); - if (Error(req)) return; - clientkey = req->getRefKey(); - if (clientkey == NULL) { - clientkey = req->getPubKey(); - tempkey = clientkey; - } - subject = req->getSubject(); - } - - // Step 2 - select Signing - if (dlg->foreignSignRB->isChecked()) { - signcert = (pki_x509 *)db->getByName(dlg->certList->currentText()); - serial = signcert->getIncCaSerial(); - signkey = signcert->getRefKey(); - // search for serial in database - - } - else { - signkey = clientkey; - bool ok; - serial = dlg->serialNr->text().toInt(&ok); - if (!ok) serial = 0; - } - - - // Step 3 - Choose the Date and all the V3 extensions - - // Date handling - notBefore = dlg->validity->getNotBefore(); - notAfter = dlg->validity->getNotAfter(); - - // initially create cert - cert = new pki_x509(); - if (!signcert) signcert=cert; - cert->setIntName(req->getIntName()); - cert->setPubKey(clientkey); - cert->setSubject(subject); - cert->setIssuer(signcert->getSubject()); - if (cert->resetTimes(signcert) > 0) { - if (QMessageBox::information(this,tr(XCA_TITLE), - tr("The validity times for the certificate need to get adjusted to not exceed those of the signer"), - tr("Continue creation"), tr("Abort") - )) - throw errorEx(""); - } - - // STEP 4 - // handle extensions - - // basic constraints - if (dlg->bcCritical->isChecked()) cont << critical; - cont << (QString)"CA:" + dlg->basicCA->currentText(); - cont << (QString)"pathlen:" + dlg->basicPath->text(); - cert->addV3ext(NID_basic_constraints, cont.join(", ")); - - // Subject Key identifier - if (dlg->subKey->isChecked()) { - cert->addV3ext(NID_subject_key_identifier, "hash"); - } - - // Authority Key identifier - if (dlg->authKey->isChecked()) { - cert->addV3ext(NID_authority_key_identifier, - "keyid:always,issuer:always"); - } - - // key usage - cont.clear(); - if (dlg->kuCritical->isChecked()) cont << critical; - for (i=0; (item = dlg->keyUsage->item(i)); i++) { - if (item->selected()){ - cont << keyusage[i]; - } - } - cert->addV3ext(NID_key_usage, cont.join(", ")); - - // extended key usage - cont.clear(); - if (dlg->ekuCritical->isChecked()) cont << critical; - for (i=0; (item = dlg->ekeyUsage->item(i)); i++) { - if (item->selected()){ - cont << ekeyusage[i]; - } - } - cert->addV3ext(NID_ext_key_usage, cont.join(", ")); - - - // Subject Alternative name - if (dlg->subAltCp->isChecked()) { - if (subject.getEntryByNid(NID_pkcs9_emailAddress).length() == 0) { - if (QMessageBox::information(this,tr(XCA_TITLE), - tr("You requested to copy the subject E-Mail address but it is empty !"), - tr("Continue creation"), tr("Abort") - )) - throw errorEx(""); - } - else { - cont << (QString)"email:copy"; - } - } - cont << dlg->subAltName->text(); - cert->addV3ext(NID_subject_alt_name, cont.join(", ")); - - // issuer alternative name - cont.clear(); - if (dlg->issAltCp->isChecked()) { - if (!signcert->hasSubAltName()) { - if (QMessageBox::information(this,tr(XCA_TITLE), - tr("You requested to copy the issuer alternative name but it is empty !"), - tr("Continue creation"), tr("Abort") - )) - throw errorEx(""); - } - else { - cont << (QString)"issuer:copy"; - } - } - cont << dlg->issAltName->text(); - cert->addV3ext(NID_issuer_alt_name, cont.join(", ")); - - // CRL distribution points - if (!dlg->crlDist->text().isEmpty()) { - CERR("CRL dist. Point: "<< dlg->crlDist->text() ); - cert->addV3ext(NID_crl_distribution_points, dlg->crlDist->text()); - } - - // STEP 5 - // Nestcape extensions - cont.clear(); - for (i=0; (item = dlg->nsCertType->item(i)); i++) { - if (item->selected()){ - cont << certTypeList[i]; - } - } - cert->addV3ext(NID_netscape_cert_type, cont.join(", ")); - cert->addV3ext(NID_netscape_base_url, dlg->nsBaseUrl->text()); - cert->addV3ext(NID_netscape_revocation_url, dlg->nsRevocationUrl->text()); - cert->addV3ext(NID_netscape_ca_revocation_url, dlg->nsCARevocationUrl->text()); - cert->addV3ext(NID_netscape_renewal_url, dlg->nsRenewalUrl->text()); - cert->addV3ext(NID_netscape_ca_policy_url, dlg->nsCaPolicyUrl->text()); - cert->addV3ext(NID_netscape_ssl_server_name, dlg->nsSslServerName->text()); - cert->addV3ext(NID_netscape_comment, dlg->nsComment->text()); - - // and finally sign the request - cert->sign(signkey); - CERR( "SIGNED"); - insert(cert); - CERR("inserted"); - if (tempkey != NULL) delete(tempkey); - CERR("Dialog deleted" ); - updateView(); - return; - } - catch (errorEx &err) { - Error(err); - delete cert; - if (tempkey != NULL) delete(tempkey); - } - -} - -void CertView::extendCert() -{ - pki_x509 *oldcert = NULL, *signer = NULL, *newcert =NULL; - pki_key *signkey = NULL; - a1time time; - a1int serial; - emit init_database(); - try { - CertExtend_UI *dlg = new CertExtend_UI(this, NULL, true); - dlg->image->setPixmap(*MainWindow::certImg); - dlg->validity->setNotBefore(time.now()); - dlg->validity->setNotAfter(time.now(60 * 60 * 24 * 356)); - - if (!dlg->exec()) { - delete dlg; - return; - } - oldcert = (pki_x509 *)getSelected(); - if (!oldcert || !(signer = oldcert->getSigner()) || !(signkey = signer->getRefKey()) || signkey->isPubKey()) return; - newcert = new pki_x509(oldcert); - serial = signer->getIncCaSerial(); - - // get signers own serial to avoid having the same - if (serial == signer->getSerial()) { - serial = signer->getIncCaSerial(); // just take the next one - } - db->updatePKI(signer); // FIXME::not so pretty .... - - // change date and serial - newcert->setSerial(serial); - newcert->setNotBefore(dlg->validity->getNotBefore()); - newcert->setNotAfter(dlg->validity->getNotAfter()); - - if (newcert->resetTimes(signer) > 0) { - if (QMessageBox::information(this,tr(XCA_TITLE), - tr("The validity times for the certificate need to get adjusted to not exceed those of the signer"), - tr("Continue creation"), tr("Abort") - )) - throw errorEx(""); - } - - - // and finally sign the request - newcert->sign(signkey); - CERR( "SIGNED"); - insert(newcert); - CERR("inserted"); - delete dlg; - } - catch (errorEx &err) { - Error(err); - if (newcert) - delete newcert; - } -} - -void CertView::showItem(pki_base *basecert, bool import) -{ - pki_x509 *cert = (pki_x509 *)basecert; - if (!cert) return; - if (Error(cert)) return ; - try { - CertDetail_UI *dlg = new CertDetail_UI(this,0,true); - bool ret; - dlg->image->setPixmap(*MainWindow::certImg); - dlg->descr->setText(cert->getIntName()); - dlg->setCaption(tr(XCA_TITLE)); - - // examine the key - pki_key *key= cert->getRefKey(); - if (key) - if (key->isPrivKey()) { - dlg->privKey->setText(key->getIntName()); - dlg->privKey->setDisabled(false); - } - - // examine the signature - if ( cert->getSigner() == NULL) { - dlg->verify->setText(tr("SIGNER UNKNOWN")); - } - else if ( cert->compare(cert->getSigner()) ) { - dlg->verify->setText(tr("SELF SIGNED")); - } - - else { - dlg->verify->setText(cert->getSigner()->getIntName()); - } - - // check trust state - if (cert->getEffTrust() == 0) { - dlg->verify->setDisabled(true); - } - CERR( cert->getEffTrust() ); - - // the serial - dlg->serialNr->setText(cert->getSerial().toHex()); - - // details of subject - x509name subj = cert->getSubject(); - QString land = subj.getEntryByNid(NID_countryName); - QString land1 = subj.getEntryByNid(NID_stateOrProvinceName); - if (land != "" && land1 != "") - land += " / " +land1; - else - land+=land1; - - dlg->dnCN->setText(subj.getEntryByNid(NID_commonName)); - dlg->dnC->setText(land); - dlg->dnL->setText(subj.getEntryByNid(NID_localityName)); - dlg->dnO->setText(subj.getEntryByNid(NID_organizationName)); - dlg->dnOU->setText(subj.getEntryByNid(NID_organizationalUnitName)); - dlg->dnEmail->setText(subj.getEntryByNid(NID_pkcs9_emailAddress)); - - // same for issuer.... - x509name iss = cert->getIssuer(); - land = iss.getEntryByNid(NID_countryName); - land1 = iss.getEntryByNid(NID_stateOrProvinceName); - if (land != "" && land1 != "") - land += " / " +land1; - else - land+=land1; - - dlg->dnCN_2->setText(iss.getEntryByNid(NID_commonName) ); - dlg->dnC_2->setText(land); - dlg->dnL_2->setText(iss.getEntryByNid(NID_localityName)); - dlg->dnO_2->setText(iss.getEntryByNid(NID_organizationName)); - dlg->dnOU_2->setText(iss.getEntryByNid(NID_organizationalUnitName)); - dlg->dnEmail_2->setText(iss.getEntryByNid(NID_pkcs9_emailAddress)); - dlg->notBefore->setText(cert->getNotBefore().toPretty()); - dlg->notAfter->setText(cert->getNotAfter().toPretty()); - MARK - - // validation of the Date - if (cert->checkDate() == -1) { - dlg->dateValid->setText(tr("Not valid")); - dlg->dateValid->setDisabled(true); - } - if (cert->checkDate() == +1) { - dlg->dateValid->setText(tr("Not valid")); - dlg->dateValid->setDisabled(true); - } - if (cert->isRevoked()) { - dlg->dateValid->setText(tr("Revoked: ") + - cert->getRevoked().toPretty()); - dlg->dateValid->setDisabled(true); - - } - // the fingerprints - dlg->fpMD5->setText(cert->fingerprint(EVP_md5())); - dlg->fpSHA1->setText(cert->fingerprint(EVP_sha1())); - - // V3 extensions - dlg->v3Extensions->setText(cert->printV3ext()); - - // rename the buttons in case of import - if (import) { - dlg->but_ok->setText(tr("Import")); - dlg->but_cancel->setText(tr("Discard")); - } - - // show it to the user... - QString odesc = cert->getIntName(); - ret = dlg->exec(); - QString ndesc = dlg->descr->text(); - delete dlg; - if (!ret && import) { - delete cert; - } - if (!ret) return; - - emit init_database(); - - if (import) { - cert = (pki_x509 *)insert(cert); - } - if (ndesc != odesc) { - db->renamePKI(cert, ndesc); - return; - } - } - catch (errorEx &err) { - Error(err); - } - return ; -} - -void CertView::deleteItem() -{ - try { - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - if (cert->getSigner() && cert->getSigner() != cert && cert->getSigner()->canSign()) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("It is actually not a good idea to delete a cert that was signed by you") +":\n'" + - cert->getIntName() + "'\n" , - tr("Ok") ); - } - deleteItem_default(tr("The certificate"), tr("is going to be deleted")); - } - catch (errorEx &err) { - Error(err); - } -} - -void CertView::load() -{ - QStringList filter; - filter.append(tr("Certificates ( *.pem *.der *.crt *.cer )")); - filter.append(tr("All files ( *.* )")); - load_default(filter,tr("Certificate import")); -} - -pki_base *CertView::loadItem(QString fname) -{ - pki_x509 *cert = new pki_x509(fname); - return cert; -} - -void CertView::loadPKCS12() -{ - pki_pkcs12 *pk12; - QStringList filt; - filt.append(tr("PKCS#12 Certificates ( *.p12 *.pfx )")); - filt.append(tr("All files ( *.* )")); - QStringList slist; - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Certificate import")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::ExistingFiles ); - dlg->setDir(MainWindow::getPath()); - if (dlg->exec()) { - slist = dlg->selectedFiles(); - MainWindow::setPath(dlg->dirPath()); - } - delete dlg; - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - try { - pk12 = new pki_pkcs12(s, &MainWindow::passRead); - insertP12(pk12); - } - catch (errorEx &err) { - Error(err); - } - delete pk12; - } -} - - -void CertView::insertP12(pki_pkcs12 *pk12) -{ - pki_x509 *acert; - pki_key *akey; - - try { - akey = pk12->getKey(); - acert = pk12->getCert(); -#ifdef INSERT_WO_ASK - insertKey(akey); - insertCert(acert); - for (int i=0; inumCa(); i++) { - acert = pk12->getCa(i); - insertCert(acert); - } -#else - // keyList->show(akey, true); - showItem(acert,true); - for (int i=0; inumCa(); i++) { - acert = pk12->getCa(i); - showItem(acert, true); - } -#endif - //if (keys) - //FIXME:: keys->updateView(); - } - catch (errorEx &err) { - Error(err); - } - MARK -} - - -void CertView::loadPKCS7() -{ - pki_pkcs7 *pk7 = NULL; - pki_x509 *acert; - QStringList filt; - filt.append(tr("PKCS#7 data ( *.p7s *.p7m *.p7b )")); - filt.append(tr("All files ( *.* )")); - QStringList slist; - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Certificate import")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::ExistingFiles ); - dlg->setDir(MainWindow::getPath()); - if (dlg->exec()) { - slist = dlg->selectedFiles(); - MainWindow::setPath(dlg->dirPath()); - } - delete dlg; - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - try { - pk7 = new pki_pkcs7(s); - pk7->readP7(s); - for (int i=0; inumCert(); i++) { - acert = pk7->getCert(i); - showItem(acert, true); - } - // keys->updateView(); - } - catch (errorEx &err) { - Error(err); - } - if (pk7) delete pk7; - } -} - - -pki_base *CertView::insert(pki_base *item) -{ - pki_x509 *cert = (pki_x509 *)item; - emit init_database(); - try { - pki_x509 *oldcert = (pki_x509 *)db->getByReference(cert); - if (oldcert) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The certificate already exists in the database as") +":\n'" + - oldcert->getIntName() + - "'\n" + tr("and so it was not imported"), "OK"); - delete(cert); - return oldcert; - } - CERR( "insertCert: inserting" ); - insert(cert); - } - catch (errorEx &err) { - Error(err); - } - a1int serial; - // check the CA serial of the CA of this cert to avoid serial doubles - if (cert->getSigner() != cert && cert->getSigner()) { - serial = cert->getSerial(); - CERR("OTHER SIGNER" << serial.getLong()); - if (cert->getSigner()->getCaSerial() getSigner()->setCaSerial(serial); - } - } - // check CA serial of this cert - // FIXME: serial = certs->searchSerial(cert); - if ( serial > 0L) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The certificate CA serial is lower than the highest serial of one signed certificate it will be set to ") + - QString::number(serial.getLong()), "OK"); - cert->setCaSerial(serial); - } - db->updatePKI(cert); - return cert; -} - -#define P7_ONLY 0 -#define P7_CHAIN 1 -#define P7_TRUSTED 2 - -void CertView::store() -{ - QStringList filt; - pki_x509 *crt = (pki_x509 *)getSelected(); - pki_x509 *oldcrt = NULL; - emit init_database(); - if (!crt) return; - pki_key *privkey = crt->getRefKey(); - ExportCert *dlg = new ExportCert((crt->getIntName() + ".crt"), - (privkey && privkey->isPrivKey()), MainWindow::getPath(), crt->tinyCAfname() ); - dlg->image->setPixmap(*MainWindow::certImg); - int dlgret = dlg->exec(); - - if (!dlgret) { - delete dlg; - return; - } - QString fname = dlg->filename->text(); - if (fname == "") { - delete dlg; - return; - } - try { - switch (dlg->exportFormat->currentItem()) { - case 0: // PEM - crt->writeCert(fname,true,false); - break; - case 1: // PEM with chain - while(crt && crt != oldcrt) { - crt->writeCert(fname,true,true); - oldcrt = crt; - crt = crt->getSigner(); - } - break; - case 2: // PEM all trusted Certificates - // FIXME: db->writeAllCerts(fname,true); - break; - case 3: // PEM all Certificates - // FIXME: db->writeAllCerts(fname,false); - break; - case 4: // DER - crt->writeCert(fname,false,false); - break; - case 5: // P7 lonely - writePKCS7(fname, P7_ONLY); - break; - case 6: // P12 - writePKCS7(fname, P7_CHAIN); - break; - case 7: // P12 - writePKCS7(fname, P7_TRUSTED); - break; - case 8: // P12 - writePKCS12(fname,false); - break; - case 9: // P12 + cert chain - writePKCS12(fname,true); - break; - - } - } - catch (errorEx &err) { - Error(err); - } - delete dlg; -} - - -void CertView::writePKCS12(QString s, bool chain) -{ - QStringList filt; - try { - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - pki_key *privkey = cert->getRefKey(); - if (!privkey || privkey->isPubKey()) { - QMessageBox::warning(this,tr(XCA_TITLE), - tr("There was no key found for the Certificate: ") + - cert->getIntName() ); - return; - } - if (s.isEmpty()) return; - s = QDir::convertSeparators(s); - pki_pkcs12 *p12 = new pki_pkcs12(cert->getIntName(), cert, privkey, &MainWindow::passWrite); - pki_x509 *signer = cert->getSigner(); - int cnt =0; - while ((signer != NULL ) && (signer != cert) && chain) { - CERR("SIGNER:"<<(int)signer); - p12->addCaCert(signer); - CERR( "signer: " << ++cnt ); - cert=signer; - signer=signer->getSigner(); - } - CERR("start writing" ); - p12->writePKCS12(s); - delete p12; - } - catch (errorEx &err) { - Error(err); - } -} - -void CertView::writePKCS7(QString s, int type) -{ - pki_pkcs7 *p7 = NULL; - QList list; - pki_x509 *cert = (pki_x509 *)getSelected(); - pki_base *cer; - emit init_database(); - try { - p7 = new pki_pkcs7(""); - if ( type == P7_CHAIN ) { - while (cert != NULL) { - p7->addCert(cert); - if (cert->getSigner() == cert) cert = NULL; - else cert = cert->getSigner(); - } - } - if ( type == P7_ONLY ) { - p7->addCert(cert); - } - if (type == P7_TRUSTED) { - list = db->getContainer(); - if (!list.isEmpty()) { - for ( cer = list.first(); cer != NULL; cer = list.next() ) { - p7->addCert((pki_x509 *)cer); - } - } - } - p7->writeP7(s, false); - } - catch (errorEx &err) { - Error(err); - } - if (p7 != NULL ) delete p7; - -} - -void CertView::signP7() -{ - QStringList filt; - try { - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - pki_key *privkey = cert->getRefKey(); - if (!privkey || privkey->isPubKey()) { - QMessageBox::warning(this,tr(XCA_TITLE), - tr("There was no key found for the Certificate: ") + - cert->getIntName()); - return; - } - filt.append("All Files ( *.* )"); - QString s=""; - QStringList slist; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Import Certificate signing request")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::ExistingFiles ); - dlg->setDir(MainWindow::getPath()); - if (dlg->exec()) { - slist = dlg->selectedFiles(); - MainWindow::setPath(dlg->dirPath()); - } - delete dlg; - pki_pkcs7 * p7 = new pki_pkcs7(""); - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - p7->signFile(cert, s); - p7->writeP7((s + ".p7s"), true); - } - delete p7; - } - catch (errorEx &err) { - Error(err); - } -} - -void CertView::encryptP7() -{ - QStringList filt; - try { - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - pki_key *privkey = cert->getRefKey(); - if (!privkey || privkey->isPubKey()) { - QMessageBox::warning(this,tr(XCA_TITLE), - tr("There was no key found for the Certificate: ") + - cert->getIntName()) ; - return; - } - filt.append("All Files ( *.* )"); - QString s=""; - QStringList slist; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Import Certificate signing request")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::ExistingFiles ); - dlg->setDir(MainWindow::getPath()); - if (dlg->exec()) { - slist = dlg->selectedFiles(); - MainWindow::setPath(dlg->dirPath()); - } - delete dlg; - pki_pkcs7 * p7 = new pki_pkcs7(""); - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - p7->encryptFile(cert, s); - p7->writeP7((s + ".p7m"), true); - } - delete p7; - } - catch (errorEx &err) { - Error(err); - } -} - -void CertView::popupMenu(QListViewItem *item, const QPoint &pt, int x) { - CERR( "popup Cert"); - QPopupMenu *menu = new QPopupMenu(this); - QPopupMenu *subCa = new QPopupMenu(this); - QPopupMenu *subP7 = new QPopupMenu(this); - QPopupMenu *subExport = new QPopupMenu(this); - int itemExtend, itemRevoke, itemTrust, itemCA, itemTemplate, itemReq, itemP7, itemtca; - bool canSign, parentCanSign, hasTemplates, hasPrivkey; - - emit init_database(); - if (!item) { - menu->insertItem(tr("New Certificate"), this, SLOT(newCert())); - menu->insertItem(tr("Import"), this, SLOT(loadCert())); - menu->insertItem(tr("Import PKCS#12"), this, SLOT(loadPKCS12())); - menu->insertItem(tr("Import from PKCS#7"), this, SLOT(loadPKCS7())); - } - else { - pki_x509 *cert = (pki_x509 *)db->getByName(item->text(0)); - menu->insertItem(tr("Rename"), this, SLOT(startRenameCert())); - menu->insertItem(tr("Show Details"), this, SLOT(showDetailsCert())); - menu->insertItem(tr("Export"), subExport); - subExport->insertItem(tr("File"), this, SLOT(writeCert())); - itemReq = subExport->insertItem(tr("Request"), this, SLOT(toRequest())); - itemtca = subExport->insertItem(tr("TinyCA"), this, SLOT(toTinyCA())); - - menu->insertItem(tr("Delete"), this, SLOT(deleteCert())); - itemTrust = menu->insertItem(tr("Trust"), this, SLOT(setTrust())); - menu->insertSeparator(); - itemCA = menu->insertItem(tr("CA"), subCa); - subCa->insertItem(tr("Serial"), this, SLOT(setSerial())); - subCa->insertItem(tr("CRL days"), this, SLOT(setCrlDays())); - itemTemplate = subCa->insertItem(tr("Signing Template"), this, SLOT(setTemplate())); - subCa->insertItem(tr("Generate CRL"), this, SLOT(genCrl())); - - itemP7 = menu->insertItem(tr("PKCS#7"), subP7); - subP7->insertItem(tr("Sign"), this, SLOT(signP7())); - subP7->insertItem(tr("Encrypt"), this, SLOT(encryptP7())); - menu->insertSeparator(); - itemExtend = menu->insertItem(tr("Renewal"), this, SLOT(extendCert())); - if (cert) { - if (cert->isRevoked()) { - itemRevoke = menu->insertItem(tr("Unrevoke"), this, SLOT(unRevoke())); - menu->setItemEnabled(itemTrust, false); - } - else - itemRevoke = menu->insertItem(tr("Revoke"), this, SLOT(revoke())); - parentCanSign = (cert->getSigner() && cert->getSigner()->canSign() && (cert->getSigner() != cert)); - canSign = cert->canSign(); - hasTemplates = MainWindow::temps->getDesc().count() > 0 ; - hasPrivkey = cert->getRefKey(); - } - menu->setItemEnabled(itemExtend, parentCanSign); - menu->setItemEnabled(itemRevoke, parentCanSign); - menu->setItemEnabled(itemCA, canSign); - subExport->setItemEnabled(itemReq, hasPrivkey); - subExport->setItemEnabled(itemtca, canSign); - menu->setItemEnabled(itemP7, hasPrivkey); - subCa->setItemEnabled(itemTemplate, hasTemplates); - - } - menu->exec(pt); - delete menu; - delete subCa; - delete subP7; - delete subExport; - - return; -} - -void CertView::setTrust() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - TrustState_UI *dlg = new TrustState_UI(this,0,true); - int state, newstate; - state = cert->getTrust(); - if (cert->getSigner() == cert) { - if (state == 1) state = 0; - dlg->trust1->setDisabled(true); - } - if (state == 0 ) dlg->trust0->setChecked(true); - if (state == 1 ) dlg->trust1->setChecked(true); - if (state == 2 ) dlg->trust2->setChecked(true); - dlg->certName->setText(cert->getIntName()); - if (dlg->exec()) { - if (dlg->trust0->isChecked()) newstate = 0; - if (dlg->trust1->isChecked()) newstate = 1; - if (dlg->trust2->isChecked()) newstate = 2; - if (newstate!=state) { - cert->setTrust(newstate); - db->updatePKI(cert); - updateView(); - } - } - delete dlg; -} - -void CertView::toRequest() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - try { - pki_x509req *req = new pki_x509req(); - req->createReq(cert->getRefKey(), cert->getSubject()); - // FIXME: insert(req); - } - catch (errorEx &err) { - Error(err); - } - -} - -void CertView::revoke() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - cert->setRevoked(true); - CERR("setRevoked..." ); - db->updatePKI(cert); - CERR("updatePKI done"); - updateView(); - CERR("view updated"); -} - -void CertView::unRevoke() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - cert->setRevoked(false); - db->updatePKI(cert); - updateView(); -} - -void CertView::setSerial() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - a1int serial = cert->getCaSerial(); - bool ok; - a1int nserial = QInputDialog::getInteger (tr(XCA_TITLE), - tr("Please enter the new Serial for signing"), - serial.getLong(), serial.getLong(), 2147483647, 1, &ok, this ); - if (ok && nserial > serial) { - cert->setCaSerial(nserial); - db->updatePKI(cert); - } -} - -void CertView::setCrlDays() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - int crlDays = cert->getCrlDays(); - bool ok; - int nCrlDays = QInputDialog::getInteger (tr(XCA_TITLE), - tr("Please enter the CRL renewal periode in days"), - crlDays, 1, 2147483647, 1, &ok, this ); - if (ok && (crlDays != nCrlDays)) { - cert->setCrlDays(nCrlDays); - db->updatePKI(cert); - } -} - -void CertView::setTemplate() -{ - pki_x509 *cert = (pki_x509 *)getSelected(); - if (!cert) return; - QString templ = cert->getTemplate(); - QStringList tempList = MainWindow::temps->getDesc(); - unsigned int i, sel=0; - bool ok; - for (i=0; isetTemplate(nTempl); - db->updatePKI(cert); - } -} - - -void CertView::changeView() -{ - if (viewState == 0) { // Plain view - viewState = 1; - // FIXME: bnViewState->setText(tr("Plain View")); - } - else { // Tree View - viewState = 0; - // FIXME: bnViewState->setText(tr("Tree View")); - } - updateView(); -} - -#define fopenerror(file) \ - QMessageBox::warning(this,tr(XCA_TITLE), \ - tr("The file '") + file + tr("' could not be opened")); - -void CertView::toTinyCA() -{ -#ifndef WIN32 - pki_x509 *crt = (pki_x509 *)getSelected(); - if (!crt) return; - pki_key *key = crt->getRefKey(); - if (!key) return; - FILE *fp, *fpr; - char buf[200]; - QList list; - pki_x509 *issuedcert; - QString dname = crt->getIntName(); - QString tcatempdir = MainWindow::settings->getString("TinyCAtempdir"); - QString tcadir = MainWindow::settings->getString("TinyCAdir"); - if (tcatempdir.isEmpty()) { - tcatempdir = "templates"; - } - if (tcadir.isEmpty()) { - tcadir = QDir::homeDirPath(); - tcadir += QDir::separator(); - tcadir += ".TinyCA"; - } - ExportTinyCA *dlg = new ExportTinyCA( tcatempdir, tcadir, this, NULL); - if (!dlg->exec()) return; - - tcatempdir = dlg->tempdir->text(); - tcadir = dlg->tinycadir->text(); - dname = dlg->dname->text(); - - MainWindow::settings->putString("TinyCAtempdir", tcatempdir); - MainWindow::settings->putString("TinyCAdir", tcadir); - - if (dname.isEmpty()) return; - const EVP_CIPHER *enc = EVP_des_ede3_cbc(); - - - // OK, we have all names now... - tcadir += QDir::separator(); - tcadir += dname; - - //create directory tree - if (! mkDir(tcadir)) return; - chdir(tcadir); - if (! mkDir("certs")) return; - if (! mkDir("crl")) return; - if (! mkDir("keys")) return; - if (! mkDir("newcerts")) return; - if (! mkDir("req")) return; - - // write the CA cert and key - crt->writeCert("cacert.pem", true, false); - key->writeKey("cacert.key", enc, &MainWindow::passWrite, true); - // write the crl - chdir("crl"); - pki_crl *crl; // FIXME: = genCrl(crt); - crl->writeCrl("crl.pem"); - delete crl; - chdir(".."); - // write the serial - fp = fopen("serial", "w"); - if (!fp) { - fopenerror("serial"); - return; - } - fprintf(fp, "%08lx", crt->getCaSerial().getLong()); - fclose(fp); - - // copy openssl.cnf - tcatempdir += QDir::separator(); - tcatempdir += "openssl.cnf"; - fpr = fopen(tcatempdir, "r"); - if (!fpr) { - fopenerror("openssl.cnf" ); - return; - } - fp = fopen("openssl.cnf", "w"); - if (!fp) { - fopenerror("openssl.cnf" ); - fclose(fpr); - return; - } - while (fgets(buf ,200, fpr) != NULL) { - char *x = strstr(buf,"%dir%"); - if (x != 0) { - x[0]='\0'; - fputs(buf, fp); - fputs(tcadir, fp); - fputs(x+5, fp); - } - else { - fputs(buf, fp); - } - } - fclose(fp); - fclose(fpr); - - // store the issued certificates - fp = fopen("index.txt", "w"); - if (!fp) return; - list = ((db_x509 *)db)->getIssuedCerts(crt); - if (!list.isEmpty()) { - for ( issuedcert = list.first(); issuedcert != NULL; issuedcert = list.next() ) { - QString fname = issuedcert->tinyCAfname(); - chdir("certs"); - crt->writeCert(fname, true, false); - chdir(".."); - key = issuedcert->getRefKey(); - if (key) { - chdir("keys"); - key->writeKey(fname, NULL, &MainWindow::passWrite, true); - chdir(".."); - } - fprintf(fp, "%c\t%s\t%s\t%s\tunknown\t%s\n", - issuedcert->isRevoked() ? 'R':'V', - issuedcert->getNotAfter().toPlain().latin1(), - issuedcert->getRevoked().toPlain().latin1(), - issuedcert->getSerial().toHex().latin1(), - issuedcert->getSubject().oneLine().latin1() ); - - } - } - fclose(fp); - -#endif -} - -bool CertView::updateView() -{ - clear(); - setRootIsDecorated(true); - pki_x509 *pki; - pki_base *pkib; - pki_x509 *signer; - QListViewItem *parentitem; - QListViewItem *current; - CERR("myUPDATE"); - QList container = db->getContainer(); - if ( container.isEmpty() ) return false; - QList mycont = container; - for ( pkib = container.first(); pkib != NULL; pkib = container.next() ) pkib->delLvi(); - int f=0; - while (! mycont.isEmpty() ) { - CERR("-----------------------------------------------------------------Round "<< f++); - QListIterator it(mycont); - for ( ; it.current(); ++it ) { - pki = (pki_x509 *)it.current(); - parentitem = NULL; - signer = pki->getSigner(); - if ((signer != pki) && (signer != NULL) && (viewState != 0)) // foreign signed - parentitem = signer->getLvi(); - if (((parentitem != NULL) || (signer == pki) || (signer == NULL) || viewState == 0) && (pki->getLvi() == NULL )) { - // create the listview item - if (parentitem != NULL) { - current = new QListViewItem(parentitem, pki->getIntName()); - CERR("Adding as client: "<getIntName()); - } - else { - current = new QListViewItem(this, pki->getIntName()); - CERR("Adding as parent: "<getIntName()); - } - pki->setLvi(current); - mycont.remove(pki); - pki->updateView(); - it.toFirst(); - } - } - - } - return true; -} - -bool CertView::mkDir(QString dir) -{ -#ifdef WIN32 - int ret = mkdir(dir.latin1()); - // in direct.h declare _CRTIMP int __cdecl mkdir(const char *); -#else - int ret = mkdir(dir.latin1(), S_IRUSR | S_IWUSR | S_IXUSR); -#endif - if (ret) { - QString desc = " ("; - desc += strerror(ret); - desc += ")"; - QMessageBox::critical(this,tr(XCA_TITLE), - tr("Error creating: ") + dir + desc); - return false; - } - return true; - -} - -void CertView::updateViewAll() -{ - emit init_database(); - QList c = db->getContainer(); - for (pki_x509 *pki = (pki_x509 *)c.first(); pki != 0; pki = (pki_x509 *)c.next() ) - pki->updateView(); - return; -} - diff --git a/CertView.h b/CertView.h deleted file mode 100644 index 99a54cb7..00000000 --- a/CertView.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 -#include "widgets/NewX509.h" - -class CertView : public XcaListView -{ - Q_OBJECT - - private: - int viewState; - bool mkDir(QString dir); - public: - CertView(QWidget * parent = 0, const char * name = 0, WFlags f = 0); - void showItem(pki_base *item, bool import); - void newItem(); - void deleteItem(); - void updateViewItem(pki_base *); - void load(); - pki_base* loadItem(QString fname); - pki_base* insert(pki_base *item); - void store(); - void popupMenu(QListViewItem *item, const QPoint &pt, int x); - void newCert(); - void newCert(NewX509 *dlg); - void extendCert(); - void loadPKCS12(); - void insertP12(pki_pkcs12 *pk12); - void loadPKCS7(); - void writePKCS12(QString s, bool chain); - void writePKCS7(QString s, int type); - public slots: - void signP7(); - void encryptP7(); - void setTrust(); - void toRequest(); - void revoke(); - void unRevoke(); - void setSerial(); - void setCrlDays(); - void setTemplate(); - void changeView(); - void toTinyCA(); - bool updateView(); - void updateViewAll(); - -}; - -#endif diff --git a/CrlView.cpp b/CrlView.cpp deleted file mode 100644 index 34af6b6c..00000000 --- a/CrlView.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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 -#include "lib/pki_crl.h" -#include "widgets/MainWindow.h" - - -void CrlView::showItem(pki_base *item, bool import) -{ - pki_crl *crl = (pki_crl *)item; - if (!crl) return; - try { - CrlDetail_UI *dlg = new CrlDetail(this,0,true); - connect( dlg->certList, SIGNAL( doubleClicked(QListViewItem*) ), - this, SLOT( showDetailsCert(QListViewItem *) )); - QString odesc = crl->getIntName(); - ret = dlg->exec(); - QString ndesc = dlg->descr->text(); - delete dlg; - if (!ret && import) { - delete crl; - } - if (!ret) return; - if (MainWindow::crls == NULL) { - emit init_database(); - } - if (import) { - crl = insert(crl); - } - - if (ndesc != odesc) { - crls->renamePKI(crl, ndesc); - } - - - } - catch (errorEx &err) { - Error(err); - } - return; -} - -void CrlView::deleteItem() -{ - deleteItem_default(tr("The Revokation list"), - tr("is going to be deleted")); -} - -pki_base *CrlView::loadItem(QString fname) -{ - pki_base *crl = new pki_crl(fname, &MainWindow::passRead); - return crl; -} - -void CrlView::loadCrl() -{ - QStringList filter; - filt.append(tr("Revokation lists ( *.pem *.crl )")); - filt.append(tr("All files ( *.* )")); - load_default(filter, tr("Load CRL")); -} - -pki_crl *CrlView::insert(pki_base *item) -{ - pki_crl * crl = (pki_crl *)item; - try { - MARK - pki_crl *oldcrl = (pki_crl *)crls->findPKI(crl); - MARK - if (oldcrl) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The revokation list already exists in the database as") +":\n'" + - QString::fromLatin1(oldcrl->getDescription().c_str()) + - "'\n" + tr("and so it was not imported"), "OK"); - delete(crl); - return oldcrl; - } - CERR( "insertCrl: inserting" ); - crls->insertPKI(crl); - } - catch (errorEx &err) { - Error(err); - } - return crl; -} - -void CrlView::writeCrl_pem() -{ - store(true); -} -void CrlView::writeCrl_der() -{ - store(false); -} - -void CrlView::store(bool pem) - { - pki_crl *crl; - try { - crl = (pki_crl *)crls->getSelectedPKI(); - } - catch (errorEx &err) { - Error(err); - return; - } - - if (!crl) return; - QStringList filt; - filt.append("Revokation Lists ( *.crl *.pem)"); - filt.append("All Files ( *.* )"); - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Export Certificate revokation list")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::AnyFile ); - dlg->setSelection( (crl->getDescription() + ".crl").c_str() ); - setPath(dlg); - if (dlg->exec()) { - s = dlg->selectedFile(); - newPath(dlg); - } - delete dlg; - if (s.isEmpty()) return; - s=QDir::convertSeparators(s); - try { - crl->writeCrl(s.latin1(), pem); - } - catch (errorEx &err) { - Error(err); - } - -} - - -void CrlView::popupMenu(QListViewItem *item, const QPoint &pt, int x) { - CERR( "popup Crl"); - QPopupMenu *menu = new QPopupMenu(this); - QPopupMenu *subExport = new QPopupMenu(this); - - if (!item) { - menu->insertItem(tr("Import"), this, SLOT(loadCrl())); - } - else { - menu->insertItem(tr("Rename"), this, SLOT(startRenameCrl())); - menu->insertItem(tr("Show Details"), this, SLOT(showDetailsCrl())); - 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(deleteCrl())); - } - menu->exec(pt); - delete menu; - delete subExport; - - return; -} - -pki_crl *CrlView::newItem(pki_x509 *cert) -{ - QList list; - pki_x509 *issuedcert = NULL; - pki_crl *crl = NULL; - try { - crl = new pki_crl(cert->getIntName(), cert); - - list = MainWindow::certs->getIssuedCerts(cert); - if (!list.isEmpty()) { - for ( issuedcert = list.first(); issuedcert != NULL; issuedcert = list.next() ) { - if (issuedcert->isRevoked() ) { - crl->addRevoked(issuedcert); - } - } - } - crl->addV3ext(NID_authority_key_identifier,"keyid,issuer"); - crl->addV3ext(NID_issuer_alt_name,"issuer:copy"); - crl->sign(cert->getKey()); - cert->setLastCrl(crl->getDate()); - certs->updatePKI(cert); - CERR( "CRL done, completely"); - } - catch (errorEx &err) { - Error(err); - } - return crl; -} - diff --git a/CrlView.h b/CrlView.h deleted file mode 100644 index 1899a6ae..00000000 --- a/CrlView.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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" -#include - -class CrlView : public XcaListView -{ - Q_OBJECT - - private: - static const int sizeList[]; - static void incProgress(int a, int b, void *progress); - public: - CrlView(QWidget * parent = 0, const char * name = 0, WFlags f = 0); - void showItem(pki_base *item, bool import); - void newItem(); - void deleteItem(); - void load(); - pki_base *loadItem(QString fname); - pki_base* insert(pki_base *item); - void store(bool); - void popupMenu(QListViewItem *item, const QPoint &pt, int x); - void writeCrl_pem(); - void writeCrl_der(); -}; - -#endif diff --git a/KeyView.cpp b/KeyView.cpp deleted file mode 100644 index 09199930..00000000 --- a/KeyView.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * 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/KeyDetail.h" -#include "widgets/ExportKey.h" -#include "widgets/MainWindow.h" -#include -#include -#include -#include -#include -#include - -const int KeyView::sizeList[] = {256, 512, 1024, 2048, 4096, 0 }; - -KeyView::KeyView(QWidget * parent = 0, const char * name = 0, WFlags f = 0) - :XcaListView(parent, name, f) -{ - addColumn(tr("Keysize")); - addColumn(tr("Use count")); -} - -void KeyView::newItem() -{ - NewKey_UI *dlg = new NewKey_UI(this,0,true,0); - QString x; - for (int i=0; sizeList[i] != 0; i++ ) - dlg->keyLength->insertItem( x.number(sizeList[i]) +" bit"); - dlg->keyLength->setCurrentItem(2); - dlg->image->setPixmap(*MainWindow::keyImg); - if (dlg->exec()) { - try { - int sel = dlg->keyLength->currentItem(); - QProgressDialog *progress = new QProgressDialog( - tr("Please wait, Key generation is in progress"), - tr("Cancel"),90, 0, 0, true); - progress->setMinimumDuration(0); - progress->setProgress(0); - progress->setCaption(tr(XCA_TITLE)); - pki_key *nkey = new pki_key (dlg->keyDesc->text(), - &incProgress, - progress, - sizeList[sel]); - progress->cancel(); - delete progress; - insert(nkey); - x = nkey->getIntName(); - emit keyDone(x); - } - catch (errorEx &err) { - Error(err); - } - } - delete dlg; -} - -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; - if (!key) return; - KeyDetail_UI *detDlg = new KeyDetail_UI(this, 0, true, 0 ); - try { - detDlg->setCaption(tr(XCA_TITLE)); - detDlg->keyDesc->setText( key->getIntName() ); - detDlg->keyLength->setText( key->length() ); - detDlg->keyPubEx->setText( key->pubEx() ); - detDlg->keyModulus->setText( key->modulus()); - if (key->isPubKey()) { - detDlg->keyPrivEx->setText(tr("not available") ); - detDlg->keyPrivEx->setDisabled(true); - } - detDlg->image->setPixmap(*MainWindow::keyImg); - if (import) { - detDlg->but_ok->setText(tr("Import")); - detDlg->but_cancel->setText(tr("Discard")); - } - } - catch (errorEx &err) { - Error(err); - delete detDlg; - return; - } - QString odesc = key->getIntName(); - bool ret = detDlg->exec(); - QString ndesc = detDlg->keyDesc->text(); - delete detDlg; - if (!ret && import) { - delete key; - } - if (!ret) return; - - emit init_database(); - - if (import) { - key = (pki_key *)insert(key); - } - CERR(ndesc << " " << key->getIntName()); - if ( ndesc != odesc) { - MARK - try { - db->renamePKI(key, ndesc); - MARK - } - catch (errorEx &err) { - Error(err); - } - return; - } -} - -void KeyView::load() -{ - QStringList filter; - filter.append( "PKI Keys ( *.pem *.der *.key )"); - filter.append( "PKCS#8 Keys ( *.p8 *.pk8 )"); - load_default(filter, tr("Import key")); -} - -pki_base *KeyView::loadItem(QString fname) -{ - pki_base *lkey = new pki_key(fname, &MainWindow::passRead); - return lkey; -} - -pki_base* KeyView::insert(pki_base *item) -{ - pki_key *lkey = (pki_key *)item; - pki_key *oldkey; - emit init_database(); - try { - oldkey = (pki_key *)db->getByReference(lkey); - if (oldkey != NULL) { - if ((oldkey->isPrivKey() && lkey->isPrivKey()) || - lkey->isPubKey()){ - QMessageBox::information(this,tr(XCA_TITLE), - tr("The key is already in the database as") +":\n'" + - oldkey->getIntName() + - "'\n" + tr("and is not going to be imported"), "OK"); - delete(lkey); - return oldkey; - } - else { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The database already contains the public part of the imported key as") +":\n'" + - oldkey->getIntName() + - "'\n" + tr("and will be completed by the new, private part of the key"), "OK"); - CERR( "before deleting pki..."); - db->deletePKI(oldkey); - lkey->setIntName(oldkey->getIntName()); - delete(oldkey); - } - } - CERR( "after findkey"); - db->insertPKI(lkey); - } - catch (errorEx &err) { - Error(err); - } - return lkey; -} - - -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); - int dlgret = dlg->exec(); - MainWindow::setPath(dlg->dirPath); - - if (!dlgret) { - delete dlg; - return; - } - 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) { - Error(err); - } - delete dlg; - -} - - -void KeyView::popupMenu(QListViewItem *item, const QPoint &pt, int x) { - CERR( " popup key" ); - QPopupMenu *menu = new QPopupMenu(this); - if (!item) { - menu->insertItem(tr("New Key"), this, SLOT(newItem())); - menu->insertItem(tr("Import"), this, SLOT(load())); - } - else { - menu->insertItem(tr("Rename"), this, SLOT(startRename())); - menu->insertItem(tr("Show Details"), this, SLOT(show())); - menu->insertItem(tr("Export"), this, SLOT(store())); - menu->insertItem(tr("Delete"), this, SLOT(deleteItem())); - } - menu->exec(pt); - delete menu; - return; -} - -void KeyView::incProgress(int a, int b, void *progress) -{ - int i = ((QProgressDialog *)progress)->progress(); - ((QProgressDialog *)progress)->setProgress(++i); -} - diff --git a/KeyView.h b/KeyView.h deleted file mode 100644 index 98c4bb9a..00000000 --- a/KeyView.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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" -#include "lib/pki_key.h" -#include - -class KeyView : public XcaListView -{ - Q_OBJECT - - private: - static const int sizeList[]; - static void incProgress(int a, int b, void *progress); - public: - KeyView(QWidget * parent = 0, const char * name = 0, WFlags f = 0); - void showItem(pki_base *item, bool import); - void newItem(); - void deleteItem(); - void load(); - pki_base *loadItem(QString fname); - pki_base* insert(pki_base *item); - void store(); - void popupMenu(QListViewItem *item, const QPoint &pt, int x); - signals: - void keyDone(QString &); - void init_database(); - -}; - -#endif diff --git a/MainWindowCrl.cpp b/MainWindowCrl.cpp deleted file mode 100644 index 3a034157..00000000 --- a/MainWindowCrl.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * 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 "MainWindow.h" - - -void MainWindow::showDetailsCrl() -{ - pki_crl *crl = (pki_crl *)crls->getSelectedPKI(); - showDetailsCrl(crl); -} - -void MainWindow::showDetailsCrl(QListViewItem *item) -{ - string crl = item->text(0).latin1(); - showDetailsCrl((pki_crl *)crls->getSelectedPKI(crl)); -} - - -bool MainWindow::showDetailsCrl(pki_crl *crl, bool import) -{ - if (!crl) return false; - if (opensslError(crl)) return false; - char buf[20]; - bool ret; - int numc, i; - pki_x509 *iss, *rev; - QListViewItem *current; - try { - CrlDetail_UI *dlg = new CrlDetail_UI(this,0,true); - dlg->image->setPixmap(*revImg); - dlg->descr->setText(crl->getDescription().c_str()); - dlg->setCaption(tr(XCA_TITLE)); - iss = certs->getBySubject(crl->getIssuerX509_NAME()); - numc = crl->numRev(); - dlg->certList->clear(); - dlg->certList->addColumn(tr("Name")); - dlg->certList->addColumn(tr("Serial")); - dlg->certList->addColumn(tr("Revokation")); - CERR("NUMBER:" << numc); - for (i=0; igetSerial(i)); - rev = certs->getByIssSerial(iss, crl->getSerial(i)); - if (rev != NULL) { - CERR(rev->getDescription()); - current = new QListViewItem(dlg->certList, - rev->getDescription().c_str()); - } - else { - current = new QListViewItem(dlg->certList, "Unknown certificate" ); - } - current->setText(1, QString::number(crl->getSerial(i)) ); - current->setText(2, pki_x509::asn1TimeToSortable(crl->getRevDate(i)).c_str()); - } - dlg->v3Extensions->setText(crl->printV3ext().c_str()); - dlg->issuer->setText(iss->getDescription().c_str()); - if (crl->verify(iss->getKey()) == 0) { - dlg->signCheck->setText(tr("Success")); - } - sprintf(buf, "%d", ASN1_INTEGER_get(crl->crl->crl->version)+1); - /* yeah, this is really oo programming :-( */ - dlg->lUpdate->setText(pki_x509::asn1TimeToSortable(crl->crl->crl->lastUpdate).c_str()); - dlg->nUpdate->setText(pki_x509::asn1TimeToSortable(crl->crl->crl->nextUpdate).c_str()); - dlg->version->setText(buf); - connect( dlg->certList, SIGNAL( doubleClicked(QListViewItem*) ), - this, SLOT( showDetailsCert(QListViewItem *) )); - string odesc = crl->getDescription(); - ret = dlg->exec(); - string ndesc = dlg->descr->text().latin1(); - delete dlg; - if (!ret && import) { - delete crl; - } - if (!ret) return false; - if (crls == NULL) { - init_database(); - } - if (import) { - crl = insertCrl(crl); - } - - if (ndesc != odesc) { - crls->renamePKI(crl, ndesc); - } - - - } - catch (errorEx &err) { - Error(err); - } - return false; -} - -void MainWindow::deleteCrl() -{ - try { - pki_crl *crl = (pki_crl *)crls->getSelectedPKI(); - if (!crl) return; - if (QMessageBox::information(this,tr(XCA_TITLE), - tr("Really want to delete the Revokation list") +":\n'" + - QString::fromLatin1(crl->getDescription().c_str()) + "'\n" , - tr("Delete"), tr("Cancel") ) - ) return; - crls->deletePKI(crl); - } - catch (errorEx &err) { - Error(err); - } -} - -void MainWindow::loadCrl() -{ - QStringList filt; - filt.append(tr("Revokation lists ( *.pem *.crl )")); - filt.append(tr("All files ( *.* )")); - QStringList slist; - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Certificate import")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::ExistingFiles ); - setPath(dlg); - MARK - if (dlg->exec()) { - slist = dlg->selectedFiles(); - newPath(dlg); - } - delete dlg; - MARK - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - MARK - try { - pki_crl *crl = new pki_crl(s.latin1()); - MARK - insertCrl(crl); - MARK - } - catch (errorEx &err) { - Error(err); - } - } - - -} - - -pki_crl *MainWindow::insertCrl(pki_crl *crl) -{ - try { - MARK - pki_crl *oldcrl = (pki_crl *)crls->findPKI(crl); - MARK - if (oldcrl) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The revokation list already exists in the database as") +":\n'" + - QString::fromLatin1(oldcrl->getDescription().c_str()) + - "'\n" + tr("and so it was not imported"), "OK"); - delete(crl); - return oldcrl; - } - CERR( "insertCrl: inserting" ); - crls->insertPKI(crl); - } - catch (errorEx &err) { - Error(err); - } - return crl; -} - -void MainWindow::writeCrl_pem() -{ - writeCrl(true); -} -void MainWindow::writeCrl_der() -{ - writeCrl(false); -} - -void MainWindow::writeCrl(bool pem) - { - pki_crl *crl; - try { - crl = (pki_crl *)crls->getSelectedPKI(); - } - catch (errorEx &err) { - Error(err); - return; - } - - if (!crl) return; - QStringList filt; - filt.append("Revokation Lists ( *.crl *.pem)"); - filt.append("All Files ( *.* )"); - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Export Certificate revokation list")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::AnyFile ); - dlg->setSelection( (crl->getDescription() + ".crl").c_str() ); - setPath(dlg); - if (dlg->exec()) { - s = dlg->selectedFile(); - newPath(dlg); - } - delete dlg; - if (s.isEmpty()) return; - s=QDir::convertSeparators(s); - try { - crl->writeCrl(s.latin1(), pem); - } - catch (errorEx &err) { - Error(err); - } - -} - - -void MainWindow::showPopupCrl(QListViewItem *item, const QPoint &pt, int x) { - CERR( "popup Crl"); - QPopupMenu *menu = new QPopupMenu(this); - QPopupMenu *subExport = new QPopupMenu(this); - - if (!item) { - menu->insertItem(tr("Import"), this, SLOT(loadCrl())); - } - else { - menu->insertItem(tr("Rename"), this, SLOT(startRenameCrl())); - menu->insertItem(tr("Show Details"), this, SLOT(showDetailsCrl())); - 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(deleteCrl())); - } - menu->exec(pt); - delete menu; - delete subExport; - - return; -} - -void MainWindow::renameCrl(QListViewItem *item, int col, const QString &text) -{ - if (col != 0) return; - try { - pki_base *pki = crls->getSelectedPKI(item); - string txt = text.latin1(); - crls->renamePKI(pki, txt); - } - catch (errorEx &err) { - Error(err); - } -} -void MainWindow::genCrl() -{ - pki_x509 *cert = (pki_x509 *)certs->getSelectedPKI(); - if (!cert) return; - if (cert->getKey()->isPubKey()) return; - pki_crl *crl = genCrl(cert); - crls->insertPKI(crl); -} - -pki_crl *MainWindow::genCrl(pki_x509 *cert) -{ - QList list; - pki_x509 *issuedcert = NULL; - pki_crl *crl = NULL; - try { - crl = new pki_crl(cert->getDescription(), cert); - - list = certs->getIssuedCerts(cert); - if (!list.isEmpty()) { - for ( issuedcert = list.first(); issuedcert != NULL; issuedcert = list.next() ) { - if (issuedcert->isRevoked() ) { - crl->addRevoked(issuedcert); - } - } - } - crl->addV3ext(NID_authority_key_identifier,"keyid,issuer"); - crl->addV3ext(NID_issuer_alt_name,"issuer:copy"); - crl->sign(cert->getKey()); - cert->setLastCrl(crl->getDate()); - certs->updatePKI(cert); - CERR( "CRL done, completely"); - } - catch (errorEx &err) { - Error(err); - } - return crl; -} - -void MainWindow::startRenameCrl() -{ - try { -#ifdef qt3 - pki_base *pki = crls->getSelectedPKI(); - if (!pki) return; - QListViewItem *item = (QListViewItem *)pki->getPointer(); - item->startRename(0); -#else - renamePKI(crls); -#endif - } - catch (errorEx &err) { - Error(err); - } -} diff --git a/Makefile.in b/Makefile.in index 2a18099e..5f127b7e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,12 +44,15 @@ $(SUBDIRS): $(MAKE) -C $@ all clean: - $(MAKE) -C lib clean - $(MAKE) -C ui clean + for x in $(SUBDIRS); do \ + $(MAKE) -C $${x} clean; \ + done rm -f $(MOC_CPP) $(UI_CPP) $(UI_H) *~ *.o xca distclean: clean - $(MAKE) -C lib distclean + for x in $(SUBDIRS); do \ + $(MAKE) -C $${x} distclean; \ + done rm -f Makefile config.cache config.h config.log config.status results rm -rf autom4te.cache @@ -73,9 +76,5 @@ install: xca install -m 755 -o root xca $(prefix)@prefix@/bin install -m 644 -o root img/*.png $(prefix)@prefix@/share/xca install -m 644 -o root xca_??.qm $(prefix)@prefix@/share/xca - -moc_%.cpp: %.h %.cpp - $(MOC) $< -o $@ - .PHONY: $(SUBDIRS) diff --git a/NewX509.cpp b/NewX509.cpp deleted file mode 100644 index 63d117cc..00000000 --- a/NewX509.cpp +++ /dev/null @@ -1,541 +0,0 @@ -/* - * 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 "NewX509.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "MainWindow.h" -#include "lib/x509name.h" - -NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *req, db_x509 *cert, db_temp *temp, QPixmap *image, QPixmap *ns) - :NewX509_UI(parent, name, true, 0) -{ - connect( this, SIGNAL(genKey()), parent, SLOT(newKey()) ); - connect( parent, SIGNAL(keyDone(QString)), this, SLOT(newKeyDone(QString)) ); - setCaption(tr(XCA_TITLE)); - keys = key; - reqs = req; - temps = temp; - certs = cert; - fixtemp = NULL; - if (image) { - bigImg1->setPixmap(*image); - bigImg2->setPixmap(*image); - bigImg3->setPixmap(*image); - bigImg4->setPixmap(*image); - bigImg5->setPixmap(*image); - bigImg6->setPixmap(*image); - nsImg->setPixmap(*ns); - } -#ifdef qt3 - // pretty fat Title :-) - QFont tFont;// = getFont(); - tFont.setPointSize(14); - tFont.setBold(true); - tFont.setUnderline(true); - setTitleFont( tFont ); -#else - //setFont( tFont ); -#endif - serialNr->setValidator( new QIntValidator(0, 32767, this)); - QStringList strings; - // are there any useable private keys ? - if (keys) { - strings = keys->get0PrivateDesc(); - keyList->insertStringList(strings); - } - else { - keyList->setEnabled(false); - genKeyBUT->setEnabled(false); - } - - // any PKCS#10 requests to be used ? - if (reqs) { - strings = reqs->getDesc(); - if (strings.isEmpty()) { - fromReqCB->setDisabled(true); - } - else { - reqList->insertStringList(strings); - } - } - else { - reqList->setEnabled(false); - fromReqCB->setEnabled(false); - } - - // How about signing certificates ? - if (certs) { - strings = certs->getSignerDesc(); - if (strings.isEmpty()) { - foreignSignRB->setDisabled(true); - certList->setDisabled(true); - } - else { - certList->insertStringList(strings); - } - } - else { - foreignSignRB->setDisabled(true); - certList->setDisabled(true); - } - - // settings for the templates .... - if (temps) { - strings = temps->getDesc(); - strings.prepend(tr("Server Template")); - strings.prepend(tr("Client Template")); - strings.prepend(tr("CA Template")); - strings.prepend(tr("Empty Template")); - tempList->insertStringList(strings); - } - else { - templateBox->setEnabled(false); - } - - setFinishEnabled(page7,true); - setNextEnabled(page2,false); - signerChanged(); -} -void NewX509::setRequest() -{ - setAppropriate(page4, false); - setAppropriate(page5, false); - setAppropriate(page6, false); - finishButton()->setEnabled(true); - changeDefault->setEnabled(false); - changeDefault->setChecked(false); - signerBox->setEnabled(false); - startText=tr("\ -Welcome to the settings for certificate signing requests. -A signing request needs a private key, so it will be created \ -if there isn't any unused key available in the key database. \ -This signing request can then be given to a Certification authority \ -while the private key of the request and of the resulting certificate \ -returned from the CA does never leave your computer."); - endText=tr("\ -You are done with entering all parameters for generating a Certificate signing \ -request. The resulting request should be exported and send to an appropriate CA \ -for signing it."); - tText=tr("Certificate request"); - setup(); -} - -NewX509::~NewX509() -{ - -} - -void NewX509::setTemp(pki_temp *temp) -{ - setAppropriate(page1, false); - finishButton()->setEnabled(true); - startText=tr("\ -Welcome to the settings for Templates. -This templates do not refer to any ASN.1 structure but are used to keep default \ -settings for signing requests and certificates. \ -When creating a Request or Certificate the template can preset the needed fields \ -with default settings."); - endText=tr("\ -You are done with entering all parameters for the Template. -After this step the template can be assigned to one of your CAs to be autoatically \ -applied when signing with this CA."); - tText=tr("Template"); - if (temp->getIntName() != "--") { - description->setText(temp->getIntName()); - tText += tr(" change"); - } - setup(); - -} - -void NewX509::setCert() -{ - finishButton()->setEnabled(true); - startText=tr("Welcome to the settings for Certificates. The information for the new Certificate can either be grabbed from a given Certificate-request or be filled in by hand. In the case of not signing a request there needs to be at least one unused key. If this is not the case it will be created. If you want to self-sign a request (unusual but nevertheless possible) you need the private key used to create the request."); - endText=tr("You are done with entering all parameters for creating a Certificate."); - tText=tr("Certificate"); - setup(); -} - -void NewX509::setup() -{ - startLabel->setText(startText); - endLabel->setText(endText); - setTitle(page0, tText + " Wizard"); - setTitle(page1, tText + " template selection"); - setTitle(page2, tText + " personal settings"); - setTitle(page4, tText + " X.509 v3 Extensions"); - setTitle(page5, tText + " key usage setup"); - setTitle(page6, tText + " Netscape extensions"); - setTitle(page7, tText + " Wizard finished"); -} - -void NewX509::defineTemplate(pki_temp *temp) -{ - fromTemplate(temp); - templateChanged(temp); - tempList->setEnabled(false); -} - -void NewX509::defineRequest(pki_x509req *req) -{ - if (!req) return; - fromReqCB->setEnabled(true); - fromReqCB->setChecked(true); - QString reqname = req->getIntName(); -#ifdef qt3 - reqList->setCurrentText(reqname); -#else - for (int i=0; icount(); i++) { - if (reqList->text(i) == reqname) { - reqList->setCurrentItem(i); - break; - } - } -#endif - -} - -void NewX509::defineCert(pki_x509 *defcert) -{ - // suggested from: Andrey Brindeew - if (defcert && defcert->canSign()) { - QString name = defcert->getIntName(); -#ifdef qt3 - certList->setCurrentText(name); -#else - for (int i=0; icount();i++) { - if (certList->text(i) == name) { - certList->setCurrentItem(i); - break; - } - } -#endif - foreignSignRB->setChecked(true); - // certList->setEnabled(true); - } -} - - -int NewX509::lb2int(QListBox *lb) -{ - int x=0; - for (int i=0; lb->item(i); i++) { - if (lb->isSelected(i)){ - x |= 1<item(i); i++) { - lb->setSelected(i, (1<setText(temp->C); - stateOrProvinceName->setText(temp->P); - localityName->setText(temp->L); - organisationName->setText(temp->O); - organisationalUnitName->setText(temp->OU); - commonName->setText(temp->CN); - emailAddress->setText(temp->EMAIL); - subAltName->setText(temp->subAltName); - issAltName->setText(temp->issAltName); - crlDist->setText(temp->crlDist); - nsComment->setText(temp->nsComment); - nsBaseUrl->setText(temp->nsBaseUrl); - nsRevocationUrl->setText(temp->nsRevocationUrl); - nsCARevocationUrl->setText(temp->nsCARevocationUrl); - nsRenewalUrl->setText(temp->nsRenewalUrl); - nsCaPolicyUrl->setText(temp->nsCaPolicyUrl); - nsSslServerName->setText(temp->nsSslServerName); - int2lb(nsCertType, temp->nsCertType); - basicCA->setCurrentItem(temp->ca?1:0); - bcCritical->setChecked(temp->bcCrit); - kuCritical->setChecked(temp->keyUseCrit); - ekuCritical->setChecked(temp->eKeyUseCrit); - subKey->setChecked(temp->subKey); - authKey->setChecked(temp->authKey); - subAltCp->setChecked(temp->subAltCp); - issAltCp->setChecked(temp->issAltCp); - int2lb(keyUsage, temp->keyUse); - int2lb(ekeyUsage, temp->eKeyUse); - //validNumber->setText(QString::number(temp->validN)); - //validRange->setCurrentItem(temp->validM); - if (temp->pathLen) { - basicPath->setText(QString::number(temp->pathLen)); - } - -} - -void NewX509::toTemplate(pki_temp *temp) -{ - temp->setIntName(description->text()); - temp->C = countryName->text(); - temp->P = stateOrProvinceName->text(); - temp->L = localityName->text(); - temp->O = organisationName->text(); - temp->OU = organisationalUnitName->text(); - temp->CN = commonName->text(); - temp->EMAIL = emailAddress->text(); - temp->subAltName = subAltName->text(); - temp->issAltName = issAltName->text(); - temp->crlDist = crlDist->text(); - temp->nsComment = nsComment->text(); - temp->nsBaseUrl = nsBaseUrl->text(); - temp->nsRevocationUrl = nsRevocationUrl->text(); - temp->nsCARevocationUrl = nsCARevocationUrl->text(); - temp->nsRenewalUrl = nsRenewalUrl->text(); - temp->nsCaPolicyUrl = nsCaPolicyUrl->text(); - temp->nsSslServerName = nsSslServerName->text(); - temp->nsCertType = lb2int(nsCertType); - temp->ca = basicCA->currentItem(); - temp->bcCrit = bcCritical->isChecked(); - temp->keyUseCrit = kuCritical->isChecked(); - temp->eKeyUseCrit = ekuCritical->isChecked(); - temp->subKey = subKey->isChecked(); - temp->authKey = authKey->isChecked(); - temp->subAltCp = subAltCp->isChecked(); - temp->issAltCp = issAltCp->isChecked(); - temp->keyUse = lb2int(keyUsage); - temp->eKeyUse = lb2int(ekeyUsage); - //temp->validN = validNumber->text().toInt(); - //temp->validM = validRange->currentItem(); - temp->pathLen = basicPath->text().toInt(); -} - -void NewX509::toggleFromRequest() -{ - if (fromReqCB->isChecked()) { - setAppropriate(page2, false); - reqList->setEnabled(true); - } - else { - setAppropriate(page2, true); - reqList->setEnabled(false); - } -} - - -void NewX509::dataChangeP2() -{ - CERR( "Data changed" ); - if (description->text() != "" && countryName->text().length() !=1 && - (keyList->count() > 0 || !keyList->isEnabled())){ - setNextEnabled(page2,true); - } - else { - setNextEnabled(page2,false); - } -} - -void NewX509::showPage(QWidget *page) -{ - - if (page == page0) { - signerChanged(); - switchExtended(); - toggleFromRequest(); - } - else if ( page == page2 ) { - if (keyList->isEnabled() && keyList->count() == 0 ) { - newKey(); - } - dataChangeP2(); - } - - QWizard::showPage(page); - - if ( page == page2 ) { - description->setFocus(); - } - else if (page == page4) { - basicCA->setFocus(); - } - -} - -void NewX509::signerChanged() -{ - CERR("signer Changed"); - if (!certs) return; - QString name = certList->currentText(); - CERR( "Certificate: " << name); - - if (name.isEmpty()) return; - pki_x509 *cert = (pki_x509 *)certs->getByName(name); - - if (!cert) return; - QString templ = cert->getTemplate(); - - if (templ.isEmpty()) return; - CERR( "set Template: " << templ ); - - templateChanged(templ); - -} - - -void NewX509::templateChanged(QString tempname) -{ - if (!tempList->isEnabled()) return; -#ifdef qt3 - tempList->setCurrentText(tempname); -#else - for (int i=0; icount();i++) { - if (tempList->text(i) == tempname) { - tempList->setCurrentItem(i); - break; - } - } -#endif -} - - -void NewX509::templateChanged(pki_temp *templ) -{ - QString tempname = templ->getIntName(); - templateChanged(tempname); -} - - -void NewX509::templateChanged() -{ - pki_temp *temp = NULL; - int item; - if (!appropriate(page1)) return; - if (!tempList->isEnabled()) return; - if ((item = tempList->currentItem())<4) { - temp = new pki_temp("temp",item); - if (temp) { - fromTemplate(temp); - CERR("using default template: "<< item); - delete (temp); - } - return; - } - QString name = tempList->currentText(); - if (name == "" || !temps) return; - temp = (pki_temp *)temps->getByName(name); - if (!temp) return; - CERR("CHANGING TEMPLATE"); - fromTemplate(temp); -} - -void NewX509::switchExtended() -{ - if ( !appropriate(page1) ) return; - CERR( "SWITCH Extended"); - if (changeDefault->isChecked() || !templateBox->isEnabled()) { - setAppropriate(page4, true); - setAppropriate(page5, true); - setAppropriate(page6, true); - } - else { - setAppropriate(page4, false); - setAppropriate(page5, false); - setAppropriate(page6, false); - } -} - -void NewX509::newKey() -{ - emit genKey(); -} - -void NewX509::newKeyDone(QString name) -{ - keyList->insertItem(name,0); - keyList->setCurrentItem(0); - dataChangeP2(); -} - -void NewX509::helpClicked() -{ - QWhatsThis::enterWhatsThisMode(); -} - -pki_key *NewX509::getSelectedKey() -{ - return (pki_key *)MainWindow::keys->getByName(keyList->currentText()); -} - -x509name NewX509::getX509name() -{ - x509name x; - x.addEntryByNid(NID_commonName, commonName->text()); - x.addEntryByNid(NID_countryName, countryName->text()); - x.addEntryByNid(NID_localityName ,localityName->text()); - x.addEntryByNid(NID_stateOrProvinceName, stateOrProvinceName->text()); - x.addEntryByNid(NID_organizationName, organisationName->text()); - x.addEntryByNid(NID_organizationalUnitName, organisationalUnitName->text()); - x.addEntryByNid(NID_pkcs9_emailAddress, emailAddress->text()); - return x; -} - diff --git a/NewX509.h b/NewX509.h deleted file mode 100644 index 57b4058e..00000000 --- a/NewX509.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 "ui/NewX509.h" -#include "lib/db_key.h" -#include "lib/db_x509req.h" -#include "lib/db_x509.h" -#include "lib/db_temp.h" - -#ifndef NEWX509_H -#define NEWX509_H - -class MainWindow; - -class NewX509: public NewX509_UI -{ - Q_OBJECT - private: - db_x509req *reqs; - db_x509 *certs; - db_key *keys; - db_temp *temps; - pki_temp *fixtemp; - QString startText, endText, tText; - - public: - NewX509(QWidget *parent, const char *name, db_key *key, db_x509req *req, db_x509 *cert, db_temp *temp, QPixmap *image, QPixmap *ns); - ~NewX509(); - void setRequest(); // reduce to request form - void setTemp(pki_temp *temp); // reduce to template form - void setCert(); // reduce to certificate form - void setup(); - void showPage(QWidget *page); - void toTemplate(pki_temp *temp); - void fromTemplate(pki_temp *temp); - void defineTemplate(pki_temp *temp); - void defineRequest(pki_x509req *req); - void defineCert(pki_x509 *defcert); - int lb2int(QListBox *lb); - void int2lb(QListBox *lb, int x); - void templateChanged(pki_temp *templ); - void templateChanged(QString templatename); - pki_key *getSelectedKey(); - x509name getX509name(); - public slots: - void toggleFromRequest(); - void newKey(); - void dataChangeP2(); - void newKeyDone(QString name); - void switchExtended(); - void templateChanged(); - void signerChanged(); - void helpClicked(); - - signals: - void genKey(); -}; - -#endif diff --git a/ReqView.cpp b/ReqView.cpp deleted file mode 100644 index 57314da7..00000000 --- a/ReqView.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * 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 "ui/ReqDetail.h" -#include -#include -#include -#include -#include -#include -#include - -#include "widgets/MainWindow.h" -#include "widgets/NewX509.h" -#include "distname.h" - - -ReqView::ReqView(QWidget * parent = 0, const char * name = 0, WFlags f = 0) - :XcaListView(parent, name, f) -{ - addColumn(tr("Common Name")); - /* - connect(keyl, SIGNAL(delKey(pki_key *)), this, SLOT(delKey(pki_key *))); - connect(keyl, SIGNAL(newKey(pki_key *)), this, SLOT(newKey(pki_key *))); - */ -} - -void ReqView::newItem() -{ - newItem(NULL); -} - -void ReqView::newItem(pki_temp *temp) -{ - NewX509 *dlg = MainWindow::newX509(MainWindow::csrImg); - if (temp) { - dlg->defineTemplate(temp); - } - dlg->setRequest(); - if (! dlg->exec()){ - delete dlg; - return; - } - try { - pki_key *key = dlg->getSelectedKey(); - x509name xn = dlg->getX509name(); - pki_x509req *req = new pki_x509req(); - req->createReq(key, xn); - insert(req); - } - catch (errorEx &err) { - Error(err); - } -} - - - -void ReqView::showItem(pki_base *item, bool import) -{ - if (!item) return; - emit init_database(); - try { - pki_x509req *req = (pki_x509req *)item; - ReqDetail_UI *dlg = new ReqDetail_UI(this,0,true); - dlg->descr->setText(req->getIntName()); - dlg->setCaption(tr(XCA_TITLE)); - if (!req->verify() ) { - dlg->verify->setDisabled(true); - dlg->verify->setText("ERROR"); - } - pki_key *key =req->getRefKey(); - if (key) { - dlg->privKey->setText(key->getIntName()); - dlg->privKey->setDisabled(false); - } - /* - x509name rn = req->getSubject(); - dlg->dnCN->setText(rn.getEntryByNid(NID_commonName)); - dlg->dnC->setText(rn.getEntryByNid(NID_countryName) + " / " - + rn.getEntryByNid(NID_stateOrProvinceName)); - dlg->dnL->setText(rn.getEntryByNid(NID_localityName)); - dlg->dnO->setText(rn.getEntryByNid(NID_organizationName)); - dlg->dnOU->setText(rn.getEntryByNid(NID_organizationalUnitName)); - dlg->dnEmail->setText(rn.getEntryByNid(NID_pkcs9_emailAddress)); - dlg->image->setPixmap(*MainWindow::csrImg); - */ - - dlg->subject->setX509name(req->getSubject()); - - // rename the buttons in case of import - if (import) { - dlg->but_ok->setText(tr("Import")); - dlg->but_cancel->setText(tr("Discard")); - } - - QString odesc = req->getIntName(); - bool ret = dlg->exec(); - QString ndesc = dlg->descr->text(); - delete dlg; - if (!ret && import) { - delete req; - } - if (!ret) return; - - emit init_database(); - - if (import) { - req = (pki_x509req *)insert((pki_x509req *)req); - } - - if (ndesc != odesc) { - db->renamePKI(req, ndesc); - } - } - catch (errorEx &err) { - Error(err); - } -} - -void ReqView::deleteItem() -{ - deleteItem_default(tr("The Certificate signing request"), - tr("is going to be deleted")); -} - -void ReqView::load() -{ - QStringList filter; - filter.append("PKCS#10 CSR ( *.pem *.der *.csr )"); - filter.append("All Files ( *.* )"); - load_default(filter, tr("Import CSR")); -} - -pki_base *ReqView::loadItem(QString fname) -{ - pki_base *req = new pki_x509req(fname); - return req; -} - - -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) { - Error(err); - return; - } - - if (!req) return; - QStringList filt; - filt.append("PKCS#10 CSR ( *.pem *.der *.csr )"); - filt.append("All Files ( *.* )"); - QString s=""; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(tr("Export Certificate signing request")); - dlg->setFilters(filt); - dlg->setMode( QFileDialog::AnyFile ); - dlg->setSelection( req->getIntName() + ".csr" ); - - 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) { - Error(err); - } -} - -void ReqView::signReq() -{ - pki_x509req *req; - try { - req = (pki_x509req *)getSelected(); - } - catch (errorEx &err) { - Error(err); - return; - } - newCert(req); -} - - -pki_base *ReqView::insert(pki_base *item) -{ - pki_x509req *oldreq, *req; - req = (pki_x509req *)item; - emit init_database(); - try { - oldreq = (pki_x509req *)db->getByReference(req); - } - catch (errorEx &err) { - Error(err); - } - if (oldreq) { - QMessageBox::information(this,tr(XCA_TITLE), - tr("The certificate signing request already exists in the database as") +":\n'" + - oldreq->getIntName() + - "'\n" + tr("and thus was not stored"), "OK"); - delete(req); - return oldreq; - } - try { - db->insertPKI(req); - } - catch (errorEx &err) { - Error(err); - } - return req; -} - - -void ReqView::popupMenu(QListViewItem *item, const QPoint &pt, int x) { - CERR("hallo popup Req"); - QPopupMenu *menu = new QPopupMenu(this); - QPopupMenu *subExport = new QPopupMenu(this); - if (!item) { - menu->insertItem(tr("New Request"), this, SLOT(newReq())); - menu->insertItem(tr("Import"), this, SLOT(loadReq())); - } - else { - menu->insertItem(tr("Rename"), this, SLOT(startRenameReq())); - menu->insertItem(tr("Show Details"), this, SLOT(showDetailsReq())); - menu->insertItem(tr("Sign"), this, SLOT(signReq())); - 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->exec(pt); - delete menu; - delete subExport; - return; -} - diff --git a/ReqView.h b/ReqView.h deleted file mode 100644 index d694ceeb..00000000 --- a/ReqView.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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, WFlags f = 0); - void showItem(pki_base *item, bool import); - void newItem(); - void newItem(pki_temp *temp); - void deleteItem(); - void load(); - void updateViewItem(pki_base *); - pki_base *loadItem(QString fname); - pki_base* insert(pki_base *item); - void store(bool pem); - void popupMenu(QListViewItem *item, const QPoint &pt, int x); - public slots: - void writeReq_pem(); - void writeReq_der(); - void signReq(); - signals: - void keyDone(QString &); - void newCert(pki_x509req *req); - -}; - -#endif diff --git a/TempView.cpp b/TempView.cpp deleted file mode 100644 index 3121d40b..00000000 --- a/TempView.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 -#include - -TempView::TempView(QWidget * parent = 0, const char * name = 0, WFlags f = 0) - :XcaListView(parent, name, f) -{ - keyicon = loadImg("template.png"); - addColumn(tr("Type")); -} - -void TempView::newItem(int type) -{ - pki_temp *temp = new pki_temp("--", type); - if (alterTemp(temp)) { - insert(temp); - } -} - -bool TempView::alterTemp(pki_temp *temp) -{ - NewX509 *dlg = MainWindow::newX509(MainWindow::tempImg); - dlg->setTemp(temp); - dlg->fromTemplate(temp); - if (!dlg->exec()) { - delete dlg; - return false; - } - dlg->toTemplate(temp); - delete dlg; - return true; -} - -void TempView::showItem(pki_base *item, bool import) -{ - pki_temp *temp = (pki_temp *)item; - if (!temp) return; - QString oldname = temp->getIntName(); - alterTemp(temp); - QString newname = temp->getIntName(); - if (newname!= oldname) { - temp->setIntName(oldname); - MainWindow::temps->renamePKI(temp, newname); - } - MainWindow::temps->updatePKI(temp); -} - - -void TempView::deleteItem() -{ - deleteItem_default(tr("The Template"), tr("is going to be deleted")); -} - - - -pki_base *TempView::insert(pki_base *temp) -{ - MainWindow::temps->insertPKI(temp); - return temp; -} - -void TempView::certFromTemp() -{ - pki_temp *temp = (pki_temp *)getSelected(); - // FIXME: newCert(temp); -} - -void TempView::reqFromTemp() -{ - pki_temp *temp = (pki_temp *)getSelected(); - // FIXME: newReq(temp); -} - -void TempView::popupMenu(QListViewItem *item, const QPoint &pt, int x) -{ - QPopupMenu *menu = new QPopupMenu(this); - QPopupMenu *subMenu = new QPopupMenu(this); - if (!item) { - menu->insertItem(tr("New Template"), subMenu); - subMenu->insertItem(tr("Empty"), this, SLOT(newEmpTemp())); - subMenu->insertItem(tr("CA"), this, SLOT(newCATemp())); - subMenu->insertItem(tr("Client"), this, SLOT(newCliTemp())); - subMenu->insertItem(tr("Server"), this, SLOT(newSerTemp())); - - } - else { - menu->insertItem(tr("Rename"), this, SLOT(startRenameTemp())); - menu->insertItem(tr("Change"), this, SLOT(alterTemp())); - menu->insertItem(tr("Delete"), this, SLOT(deleteTemp())); - menu->insertItem(tr("Create certificate"), this, SLOT(certFromTemp())); - menu->insertItem(tr("Create request"), this, SLOT(reqFromTemp())); - } - menu->exec(pt); - delete menu; - delete subMenu; - return; -} - diff --git a/TempView.h b/TempView.h deleted file mode 100644 index 82127a4e..00000000 --- a/TempView.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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" -#include - -class TempView : public XcaListView -{ - Q_OBJECT - - private: - QPixmap *keyicon; - public: - TempView(QWidget * parent = 0, const char * name = 0, WFlags f = 0); - void showItem(pki_base *item, bool import); - void newItem(int type); - void deleteItem(); - //void load(); - void updateViewItem(pki_base *); - //pki_base *loadItem(QString fname); - pki_base* insert(pki_base *item); - //void store(); - void popupMenu(QListViewItem *item, const QPoint &pt, int x); - bool alterTemp(pki_temp *temp); - public slots: - void certFromTemp(); - void reqFromTemp(); - signals: - void init_database(); - -}; - -#endif diff --git a/XcaListView.cpp b/XcaListView.cpp deleted file mode 100644 index b1854a6a..00000000 --- a/XcaListView.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * 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 -#include -#include - -#ifdef WIN32 -#include -#endif - -XcaListView::XcaListView( QWidget * parent = 0, - const char * name = 0, WFlags f = 0) - :QListView(parent, name, f) -{ -#ifdef qt3 - connect( this, SIGNAL(itemRenamed(QListViewItem *, int, const QString &)), - this, SLOT(rename(QListViewItem *, int, const QString &))); -#endif - connect( this, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)), - this, SLOT(popupMenu(QListViewItem *, const QPoint &, int))) ; - - connect( this, SIGNAL(doubleClicked(QListViewItem *)), - this, SLOT(showItem(QListViewItem *))) ; -} - -void XcaListView::setDB(db_base *mydb) -{ - db = mydb; - updateView(); -} - -void XcaListView::loadCont() -{ - emit init_database(); - db->loadContainer(); - updateView(); -} - -pki_base *XcaListView::getSelected() -{ - emit init_database(); - QListViewItem *lvi = selectedItem(); - if (!lvi) return NULL; - QString name = lvi->text(0); - return db->getByName(name); -} - -void XcaListView::showItem() -{ - showItem(getSelected(), false); -} - -void XcaListView::showItem(QListViewItem *item) -{ - showItem(db->getByName(item->text(0)), false); -} - -void XcaListView::rename(QListViewItem *item, int col, const QString &text) -{ - emit init_database(); - try { - pki_base *pki = db->getByPtr(item); - db->renamePKI(pki, text); - } - catch (errorEx &err) { - Error(err); - } -} - -void XcaListView::startRename() -{ - try { -#ifdef qt3 - QListViewItem *item = selectedItem(); - if (item == NULL) return; - item->startRename(0); -#else - renameDialog(); -#endif - } - catch (errorEx &err) { - Error(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) { - Error(err); - } -} - -void XcaListView::load_default(QStringList &filter, QString caption) -{ - filter.append( tr("All Files ( *.* )") ); - QString s = ""; - QStringList slist; - QFileDialog *dlg = new QFileDialog(this,0,true); - dlg->setCaption(caption); - dlg->setFilters(filter); - dlg->setMode( QFileDialog::ExistingFiles ); - dlg->setDir(MainWindow::getPath()); - if (dlg->exec()) { - slist = dlg->selectedFiles(); - MainWindow::setPath(dlg->dirPath()); - } - delete dlg; - for ( QStringList::Iterator it = slist.begin(); it != slist.end(); ++it ) { - s = *it; - s = QDir::convertSeparators(s); - try { - pki_base *item = loadItem(s); - insert(item); - } - catch (errorEx &err) { - Error(err); - } - } -} - -void XcaListView::Error(errorEx &err) -{ - if (err.isEmpty()) { - CERR("Empty error Exception silently ignored"); - return; - } - QMessageBox::warning(this,tr(XCA_TITLE), tr("The following error occured:") + "\n" + - QString::fromLatin1(err.getCString())); -} - -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() -{ - clear(); - QList container; - pki_base *pki; - container = db->getContainer(); - if (container.isEmpty()) return; - for ( pki = container.first(); pki != NULL; pki = container.next() ) pki->delLvi(); - QListIterator it(container); - for ( ; it.current(); ++it ) { - pki = it.current(); - QListViewItem *lvi = new QListViewItem(this, pki->getIntName()); - insertItem(lvi); - pki->setLvi(lvi); - pki->updateView(); - } -} - -pki_base *XcaListView::loadItem(QString) { CERR("Virtual called..."); return NULL; } -void XcaListView::newItem(void) { CERR("Virtual called..."); } -void XcaListView::deleteItem(void) { CERR("Virtual called..."); } -void XcaListView::load(void) { CERR("Virtual called..."); } -void XcaListView::store(void) { CERR("Virtual called..."); } -pki_base *XcaListView::insert(pki_base *) { CERR("Virtual called..."); return NULL; } -void XcaListView::popupMenu(QListViewItem *, QPoint const &, int) { CERR("Virtual called..."); } -void XcaListView::showItem(pki_base *, bool) { CERR("Virtual called...");} - -QPixmap *XcaListView::loadImg(const char *name ) -{ -#ifdef WIN32 - static unsigned char PREFIX[100]=""; - if (PREFIX[0] == '\0') { - LONG lRc; - HKEY hKey; - lRc=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\xca",0,KEY_READ, &hKey); - if(lRc!= ERROR_SUCCESS){ - // No key error - QMessageBox::warning(NULL,tr(XCA_TITLE), "Registry Key: 'HKEY_LOCAL_MACHINE->Software->xca' not found"); - PREFIX[0] = '\0'; - } - else { - ULONG dwLength = 100; - lRc=RegQueryValueEx(hKey,"Install_Dir",NULL,NULL, PREFIX, &dwLength); - if(lRc!= ERROR_SUCCESS){ - // No key error - QMessageBox::warning(NULL,tr(XCA_TITLE), "Registry Key: 'HKEY_LOCAL_MACHINE->Software->xca->Install_Dir' not found"); - PREFIX[0] = '\0'; - } - } - lRc=RegCloseKey(hKey); - } -#endif - QString path = (char *)PREFIX; - path += QDir::separator(); - return new QPixmap(path + name); -} diff --git a/XcaListView.h b/XcaListView.h deleted file mode 100644 index b3fcb212..00000000 --- a/XcaListView.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 -#include "lib/db_base.h" -#include "lib/exception.h" - -class XcaListView : public QListView -{ - Q_OBJECT - - protected: - db_base *db; - public: - XcaListView(QWidget * parent = 0, const char * name = 0, WFlags f = 0); - void setDB(db_base *mydb); - virtual pki_base *getSelected(); - virtual void showItem(pki_base *item, bool import); - void deleteItem_default(QString t1, QString t2); - virtual pki_base *loadItem(QString fname); - void load_default(QStringList &filter, QString caption); - void setDB(db_base *mydb, QPixmap *myimage); - void Error(errorEx &err); - bool Error(pki_base *pki); - void loadCont(); - QPixmap *loadImg(const char *name ); - public slots: - virtual void newItem(); - virtual void deleteItem(); - void showItem(); - void showItem(QListViewItem *item); - virtual void load(); - virtual void store(); - virtual pki_base *insert(pki_base *item); - virtual void popupMenu(QListViewItem *item, const QPoint &pt, int x); - void startRename(); - void renameDialog(); - void rename(QListViewItem *item, int col, const QString &text); - void updateView(); - signals: - void init_database(); -}; - -#endif diff --git a/distname.cpp b/distname.cpp deleted file mode 100644 index a3aed1a3..00000000 --- a/distname.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 "distname.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "lib/x509name.h" - -DistName::DistName( QWidget* parent, const char* name ) - : QGroupBox( parent, name ) -{ - if ( !name ) - setName( "DistName" ); - setTitle( tr( "Distinguished Name" ) ); - - DistNameLayout = new QGridLayout( this ); - DistNameLayout->setSpacing( 6 ); - DistNameLayout->setMargin( 11 ); -} - -void DistName::setX509name(const x509name &n) -{ - QLabel *lb; - QLineEdit *le; - QStringList sl; - for (int i=0; isetText(sl[0]); - if (lb->text().isEmpty()) - lb->setText(sl[1]); - le->setText(sl[2]); - DistNameLayout->addWidget( lb, i, 0 ); - DistNameLayout->addWidget( le, i, 1 ); - } - //DistNameLayout->invalidate(); - -} - -DistName::~DistName() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/distname.h b/distname.h deleted file mode 100644 index 6553fa8f..00000000 --- a/distname.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 DISTNAME_H -#define DISTNAME_H - -#include -#include - -class QGridLayout; -class x509name; -class QLabel; -class QComboBox; -class QLineEdit; - -class DistName : public QGroupBox -{ - Q_OBJECT - - public: - DistName( QWidget* parent = 0, const char* name = 0); - ~DistName(); - void setX509name(const x509name &n); - - protected: - QGridLayout* DistNameLayout; - QLabel *Label1, *Label2; - QComboBox *nbDay, *nbMon, *naMon, *naDay; - QLineEdit *nbYear, *naYear; - -}; - -#endif diff --git a/main.cpp b/main.cpp deleted file mode 100644 index ebc42e10..00000000 --- a/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 -#include -#include -#include "widgets/MainWindow.h" - - -int main( int argc, char *argv[] ) -{ - int ret = 0; - QApplication a( argc, argv ); - MainWindow *mw = new MainWindow( NULL, "Main Widget"); - a.setMainWidget( mw ); - // translation file for Qt - QTranslator qtTr( 0 ); - qtTr.load( QString( "qt_" ) + QTextCodec::locale(), "." ); - a.installTranslator( &qtTr ); - //translation file for application strings - QTranslator xcaTr( 0 ); -#ifdef WIN32 - xcaTr.load( QString( "xca_" ) + QTextCodec::locale(), "." ); - a.installTranslator( &xcaTr ); -#else - xcaTr.load( QString( "xca_" ) + QTextCodec::locale(), PREFIX ); - a.installTranslator( &xcaTr ); -#endif - CERR("PKI Counter:" << pki_base::get_pki_counter()); - if (mw->exitApp == 0) { - mw->show(); - ret = a.exec(); - } - MARK - delete mw; - MARK - clog << "PKI Counter: " << pki_base::get_pki_counter() << endl; - clog << "The PKI counter must be 0, if not contact me." << endl; - return ret; -} diff --git a/ui/ReqDetail.ui b/ui/ReqDetail.ui index ceea8aad..6d62be1d 100644 --- a/ui/ReqDetail.ui +++ b/ui/ReqDetail.ui @@ -11,8 +11,8 @@ 0 0 - 544 - 298 + 550 + 369 @@ -744,11 +744,42 @@ - DistName + QGroupBox name - subject + GroupBox2 + + title + Subject + + + layoutMargin + + + + margin + 2 + + + spacing + 0 + + + DistName + + name + subject + + + sizePolicy + + 7 + 7 + + + + @@ -852,7 +883,7 @@ image0 - 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + 789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753 diff --git a/validity.cpp b/validity.cpp deleted file mode 100644 index 77be64c1..00000000 --- a/validity.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 "validity.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "lib/asn1time.h" - -Validity::Validity( QWidget* parent, const char* name ) - : QGroupBox( parent, name ) -{ - QStringList months, days; - months << tr("Jan") << tr("Feb") << tr("Mar") << tr("Apr") - << tr("Mai") << tr("Jun") << tr("Jul") << tr("Aug") - << tr("Sep") << tr("Okt") << tr("Nov") << tr("Dez"); - for (int i=1; i<32; i++) - days += QString::number(i); - - if ( !name ) - setName( "Validity" ); - setTitle( tr( "Validity" ) ); - ValidityLayout = new QGridLayout( this ); - ValidityLayout->setSpacing( 6 ); - ValidityLayout->setMargin( 11 ); - - Label1 = new QLabel( this, "Label1" ); - Label1->setText( tr( "not Before" ) ); - - Label2 = new QLabel( this, "Label2" ); - Label2->setText( tr( "not After" ) ); - - nbDay = new QComboBox( FALSE, this, "nbDay" ); - nbMon = new QComboBox( FALSE, this, "nbMon" ); - nbYear = new QLineEdit( this, "nbYear" ); - - naDay = new QComboBox( FALSE, this, "naDay" ); - naMon = new QComboBox( FALSE, this, "naMon" ); - naYear = new QLineEdit( this, "naYear" ); - - ValidityLayout->addWidget( Label1, 0, 0 ); - ValidityLayout->addWidget( nbDay, 0, 1 ); - ValidityLayout->addWidget( nbMon, 0, 2 ); - ValidityLayout->addWidget( nbYear, 0, 3 ); - - ValidityLayout->addWidget( Label2, 1, 0 ); - ValidityLayout->addWidget( naDay, 1, 1 ); - ValidityLayout->addWidget( naMon, 1, 2 ); - ValidityLayout->addWidget( naYear, 1, 3 ); - - - nbMon->insertStringList(months); - naMon->insertStringList(months); - nbDay->insertStringList(days); - naDay->insertStringList(days); -} - -Validity::~Validity() -{ - // no need to delete child widgets, Qt does it all for us -} - -a1time Validity::getNotBefore() const -{ - a1time date; - date.set(nbYear->text().toInt(), nbMon->currentItem() + 1, - nbDay->currentItem() +1, 0, 0, 0); - return date; -} - -a1time Validity::getNotAfter() const -{ - a1time date; - date.set(naYear->text().toInt(), naMon->currentItem() + 1, - naDay->currentItem() +1, 0, 0, 0); - return date; -} - -void Validity::setNotBefore(const a1time &a) -{ - int y, m, d, g; - a.ymdg(&y,&m,&d,&g); - nbYear->setText(QString::number(y)); - nbMon->setCurrentItem(m-1); - nbDay->setCurrentItem(d-1); -} - -void Validity::setNotAfter(const a1time &a) -{ - int y, m, d, g; - a.ymdg(&y,&m,&d,&g); - naYear->setText(QString::number(y)); - naMon->setCurrentItem(m-1); - naDay->setCurrentItem(d-1); -} - diff --git a/validity.h b/validity.h deleted file mode 100644 index efdc3240..00000000 --- a/validity.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 VALIDITY_H -#define VALIDITY_H - -#include -#include - -class QGridLayout; -class a1time; -class QLabel; -class QComboBox; -class QLineEdit; - -class Validity : public QGroupBox -{ - Q_OBJECT - - public: - Validity( QWidget* parent = 0, const char* name = 0); - ~Validity(); - a1time getNotBefore() const; - a1time getNotAfter() const; - void setNotBefore(const a1time &t); - void setNotAfter(const a1time &t); - - protected: - QGridLayout* ValidityLayout; - QLabel *Label1, *Label2; - QComboBox *nbDay, *nbMon, *naMon, *naDay; - QLineEdit *nbYear, *naYear; - -}; - -#endif // VALIDITY_H diff --git a/widgets/CertDetail.cpp b/widgets/CertDetail.cpp new file mode 100644 index 00000000..2203f613 --- /dev/null +++ b/widgets/CertDetail.cpp @@ -0,0 +1,156 @@ +/* + * 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 "CertDetail.h" +#include "MainWindow.h" +#include +#include +#include + +CertDetail::CertDetail(QWidget *parent, const char *name) + :CertDetail_UI(parent,name,true,0) +{ + setCaption(tr(XCA_TITLE)); + image->setPixmap(*MainWindow::revImg); +} + +CertDetail::setCrt(pki_x509 *cert) +{ + descr->setText(cert->getIntName()); + + // examine the key + pki_key *key= cert->getRefKey(); + if (key && key->isPrivKey()) { + privKey->setText(key->getIntName()); + privKey->setDisabled(false); + } + + // examine the signature + if ( cert->getSigner() == NULL) { + verify->setText(tr("SIGNER UNKNOWN")); + } + else if ( cert == cert->getSigner()) { + verify->setText(tr("SELF SIGNED")); + } + + else { + verify->setText(cert->getSigner()->getIntName()); + } + + // check trust state + if (cert->getEffTrust() == 0) { + verify->setDisabled(true); + } + CERR( cert->getEffTrust() ); + + // the serial + serialNr->setText(cert->getSerial().toHex()); + + // details of subject + x509name subj = cert->getSubject(); + QString land = subj.getEntryByNid(NID_countryName); + QString land1 = subj.getEntryByNid(NID_stateOrProvinceName); + if (land != "" && land1 != "") + land += " / " +land1; + else + land+=land1; + + dlg->dnCN->setText(subj.getEntryByNid(NID_commonName)); + dlg->dnC->setText(land); + dlg->dnL->setText(subj.getEntryByNid(NID_localityName)); + dlg->dnO->setText(subj.getEntryByNid(NID_organizationName)); + dlg->dnOU->setText(subj.getEntryByNid(NID_organizationalUnitName)); + dlg->dnEmail->setText(subj.getEntryByNid(NID_pkcs9_emailAddress)); + + // same for issuer.... + x509name iss = cert->getIssuer(); + land = iss.getEntryByNid(NID_countryName); + land1 = iss.getEntryByNid(NID_stateOrProvinceName); + if (land != "" && land1 != "") + land += " / " +land1; + else + land+=land1; + + dlg->dnCN_2->setText(iss.getEntryByNid(NID_commonName) ); + dlg->dnC_2->setText(land); + dlg->dnL_2->setText(iss.getEntryByNid(NID_localityName)); + dlg->dnO_2->setText(iss.getEntryByNid(NID_organizationName)); + dlg->dnOU_2->setText(iss.getEntryByNid(NID_organizationalUnitName)); + dlg->dnEmail_2->setText(iss.getEntryByNid(NID_pkcs9_emailAddress)); + dlg->notBefore->setText(cert->getNotBefore().toPretty()); + dlg->notAfter->setText(cert->getNotAfter().toPretty()); + MARK + + // validation of the Date + if (cert->checkDate() != 0) { + dateValid->setText(tr("Not valid")); + dateValid->setDisabled(true); + } + if (cert->isRevoked()) { + dateValid->setText(tr("Revoked: ") + + cert->getRevoked().toPretty()); + dateValid->setDisabled(true); + + } + // the fingerprints + fpMD5->setText(cert->fingerprint(EVP_md5())); + fpSHA1->setText(cert->fingerprint(EVP_sha1())); + + // V3 extensions + dlg->v3Extensions->setText(cert->printV3ext()); + +void CertDetail::setImport() +{ + // rename the buttons in case of import + but_ok->setText(tr("Import")); + but_cancel->setText(tr("Discard")); +} + diff --git a/ExportKey.h b/widgets/CertDetail.h similarity index 81% rename from ExportKey.h rename to widgets/CertDetail.h index 34b5a4eb..51fe0a4c 100644 --- a/ExportKey.h +++ b/widgets/CertDetail.h @@ -48,29 +48,19 @@ * */ +#ifndef CERTDETAIL_H +#define CERTDETAIL_H -#include "ui/ExportKey.h" -#include -#include -#include -#include -#include "lib/pki_base.h" -#include +#include "ui/CertDetail.h" +#include "lib/pki_x509.h" -#ifndef EXPORTKEY_H -#define EXPORTKEY_H - - -class ExportKey: public ExportKey_UI +class CertDetail: public CertDetail_UI { Q_OBJECT - bool onlyPub; + public: - ExportKey(QString fname, bool onlypub, QString dpath, - QWidget *parent = 0, const char *name = 0); - QString dirPath; - public slots: - virtual void chooseFile(); - virtual void canEncrypt(); + CertDetail( QWidget *parent = 0, const char *name = 0); + void setCert(pki_crl *crl); }; + #endif diff --git a/widgets/distname.cpp b/widgets/distname.cpp index e57d47a3..d2f66223 100644 --- a/widgets/distname.cpp +++ b/widgets/distname.cpp @@ -62,20 +62,13 @@ #include DistName::DistName( QWidget* parent, const char* name ) - : QGroupBox( parent, name ) + : QWidget( parent, name ) { if ( !name ) setName( "DistName" ); - setTitle( tr( "Distinguished Name" ) ); - setFrameShape( QGroupBox::Box ); - setFrameShadow( QGroupBox::Sunken ); - - setColumnLayout(0, Qt::Vertical ); - layout()->setSpacing( 0 ); - layout()->setMargin( 0 ); - - DistNameLayout = new QGridLayout( this ); + DistNameLayout = new QGridLayout(this); + DistNameLayout->setAlignment( Qt::AlignTop ); DistNameLayout->setSpacing( 6 ); DistNameLayout->setMargin( 11 ); } @@ -85,7 +78,6 @@ void DistName::setX509name(const x509name &n) QLabel *lb; QLineEdit *le; QStringList sl; - for (int i=0; iaddWidget( lb, i, 0 ); DistNameLayout->addWidget( le, i, 1 ); } - DistNameLayout->invalidate(); } DistName::~DistName() diff --git a/widgets/distname.h b/widgets/distname.h index ae27720c..3a53f6d4 100644 --- a/widgets/distname.h +++ b/widgets/distname.h @@ -61,7 +61,7 @@ class QComboBox; class QLineEdit; class myGridlayout; -class DistName : public QGroupBox +class DistName : public QWidget { Q_OBJECT