*** empty log message ***

This commit is contained in:
chris2511 2003-06-24 15:43:03 +00:00
parent f1b9f7432b
commit 53915cf528
25 changed files with 3815 additions and 32 deletions

View File

@ -14,8 +14,8 @@ CC=@CC@
CPPFLAGS=-I. @CPPFLAGS@ @DEFS@
CFLAGS=-Wall @ac_DEBUG@
LDFLAGS=-Llib -Lui -Lwidgets @LDFLAGS@
LIBS=@LIBS@ -lwidget -lpki -lqtui
LDFLAGS=-Llib @LDFLAGS@
LIBS=@LIBS@ -lpki
MOC=@MOC@
UIC=@UIC@
@ -23,24 +23,24 @@ UIC=@UIC@
###################################
NAMES=XcaListView KeyView ReqView TempView CertView validity distname CrlView
OBJS=main.o $(patsubst %,moc_%.o,$(NAMES)) $(patsubst %,%.o,$(NAMES))
#NAMES=XcaListView KeyView ReqView TempView CertView validity distname
#OBJS=main.o $(patsubst %,moc_%.o,$(NAMES)) $(patsubst %,%.o,$(NAMES))
SUBDIRS=lib ui widgets
OBJS=ui/ui.o widgets/widgets.o view/view.o
SUBDIRS=lib ui widgets view
all: $(SUBDIRS) $(OBJS) xca
main.o: ui
all: $(SUBDIRS) xca
re: clean all
%.o: %.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
xca: $(OBJS) lib/libpki.a ui/libqtui.a widgets/libwidget.a
xca: $(OBJS) lib/libpki.a $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o xca
@echo -e "\n\n\nOk, compilation was successfull. \nNow do as root: 'make install'\n"
lib ui widgets:
$(SUBDIRS):
$(MAKE) -C $@ all
clean:

View File

@ -1,5 +1,5 @@
AC_INIT(xca, 0.4.0)
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_SRCDIR([view/main.cpp])
AC_CONFIG_HEADERS([config.h])
if test -z "$CFLAGS"; then
@ -94,7 +94,7 @@ else
ac_DEBUG=
fi], )
AC_CONFIG_FILES([Makefile lib/Makefile lib/base.h ui/Makefile widgets/Makefile results])
AC_CONFIG_FILES([Makefile lib/Makefile lib/base.h ui/Makefile widgets/Makefile view/Makefile results])
AC_OUTPUT
if test "$LDB" != X; then

View File

@ -90,7 +90,7 @@ QString x509name::oneLine() const
QString x509name::getEntryByNid(int nid) const
{
int len = X509_NAME_get_text_by_NID(xn, nid, NULL, 0);
int len = X509_NAME_get_text_by_NID(xn, nid, NULL, 0) + 1;
char *buf = (char *)OPENSSL_malloc(len);
QString s;
X509_NAME_get_text_by_NID(xn, nid, buf, len);

View File

@ -15,7 +15,7 @@ UIC=@UIC@
AR=@AR@
RANLIB=@RANLIB@
CPPFLAGS=-I.. @CPPFLAGS@ @DEFS@
CPPFLAGS=-I.. -I../widgets -I../view @CPPFLAGS@ @DEFS@
CFLAGS=-Wall @ac_DEBUG@
##############################################
@ -30,11 +30,10 @@ MOC_CPP=$(patsubst %,moc_%.cpp,$(MOCNAMES))
UI_CPP=$(patsubst %, %.cpp, $(UINAMES))
UI_H=$(patsubst %, %.h, $(UINAMES))
all: libqtui.a
all: ui.o
libqtui.a: $(UIOBJS)
$(AR) rc $@ $(UIOBJS)
$(RANLIB) $@
ui.o: $(UIOBJS)
$(LD) -r $(UIOBJS) -o $@
%.o: %.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

View File

@ -11,8 +11,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<height>405</height>
<width>544</width>
<height>298</height>
</rect>
</property>
<property stdset="1">
@ -113,7 +113,7 @@
<spacer>
<property>
<name>name</name>
<cstring>Spacer7</cstring>
<cstring>Spacer12</cstring>
</property>
<property stdset="1">
<name>orientation</name>
@ -725,7 +725,7 @@
<spacer>
<property>
<name>name</name>
<cstring>Spacer5_2</cstring>
<cstring>Spacer13</cstring>
</property>
<property stdset="1">
<name>orientation</name>
@ -753,7 +753,7 @@
<spacer>
<property>
<name>name</name>
<cstring>Spacer6_2</cstring>
<cstring>Spacer14</cstring>
</property>
<property stdset="1">
<name>orientation</name>
@ -852,7 +852,7 @@
<images>
<image>
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
</image>
</images>
<connections>

1292
view/CertView.cpp Normal file

File diff suppressed because it is too large Load Diff

104
view/CertView.h Normal file
View File

@ -0,0 +1,104 @@
/*
* 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 <qlistview.h>
#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

236
view/CrlView.cpp Normal file
View File

@ -0,0 +1,236 @@
/*
* 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 <qpopupmenu.h>
#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<pki_x509> 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;
}

79
view/CrlView.h Normal file
View File

@ -0,0 +1,79 @@
/*
* 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 <qlistview.h>
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

283
view/KeyView.cpp Normal file
View File

@ -0,0 +1,283 @@
/*
* 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 <qcombobox.h>
#include <qlabel.h>
#include <qprogressdialog.h>
#include <qtextview.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
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);
}

82
view/KeyView.h Normal file
View File

@ -0,0 +1,82 @@
/*
* 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 <qlistview.h>
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

356
view/MainWindowCrl.cpp Normal file
View File

@ -0,0 +1,356 @@
/*
* 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; i<numc; i++) {
CERR("SERIAL: "<< crl->getSerial(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<pki_x509> 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);
}
}

46
view/Makefile.in Normal file
View File

@ -0,0 +1,46 @@
#
# @configure_input@
#
# $Id$
VERSION=@PACKAGE_VERSION@
TARGET=xca-$(VERSION)
GCC=@CXX@
CC=@CC@
MOC=@MOC@
UIC=@UIC@
AR=@AR@
RANLIB=@RANLIB@
CPPFLAGS=-I.. @CPPFLAGS@ @DEFS@
CFLAGS=-Wall @ac_DEBUG@
##############################################
NAMES= XcaListView KeyView ReqView TempView CertView #CrlView
OBJS=$(patsubst %,moc_%.o,$(NAMES)) $(patsubst %,%.o,$(NAMES)) main.o
MOC_CPP=$(patsubst %,moc_%.cpp,$(NAMES))
all: view.o
view.o: $(OBJS)
$(LD) -r -o $@ $(OBJS)
%.o: %.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
clean:
rm -rf *~ *.o *.a $(MOC_CPP)
distclean: clean
rm -f Makefile
moc_%.cpp: %.h %.cpp
$(MOC) $< -o $@
.SECONDARY: $(UI_CPP) $(UI_H) $(MOC_CPP)

295
view/ReqView.cpp Normal file
View File

@ -0,0 +1,295 @@
/*
* 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 <qpopupmenu.h>
#include <qmessagebox.h>
#include <qfiledialog.h>
#include <qdir.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include "widgets/MainWindow.h"
#include "widgets/NewX509.h"
#include "widgets/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;
}

87
view/ReqView.h Normal file
View File

@ -0,0 +1,87 @@
/*
* 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

151
view/TempView.cpp Normal file
View File

@ -0,0 +1,151 @@
/*
* 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 <qmessagebox.h>
#include <qpopupmenu.h>
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;
}

85
view/TempView.h Normal file
View File

@ -0,0 +1,85 @@
/*
* 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 <qlistview.h>
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

272
view/XcaListView.cpp Normal file
View File

@ -0,0 +1,272 @@
/*
* 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 <qinputdialog.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#ifdef WIN32
#include <windows.h>
#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<pki_base> container;
pki_base *pki;
container = db->getContainer();
if (container.isEmpty()) return;
for ( pki = container.first(); pki != NULL; pki = container.next() ) pki->delLvi();
QListIterator<pki_base> 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);
}

95
view/XcaListView.h Normal file
View File

@ -0,0 +1,95 @@
/*
* 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 <qlistview.h>
#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

88
view/main.cpp Normal file
View File

@ -0,0 +1,88 @@
/*
* 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 <qapplication.h>
#include <qtranslator.h>
#include <qtextcodec.h>
#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;
}

View File

@ -55,6 +55,7 @@
#include <qcheckbox.h>
#include <qlineedit.h>
#include "lib/pki_base.h"
#include <iostream>
#ifndef EXPORTKEY_H
#define EXPORTKEY_H

View File

@ -54,10 +54,10 @@
#include <qmessagebox.h>
#include <qlabel.h>
#include "lib/pki_pkcs12.h"
#include "KeyView.h"
#include "ReqView.h"
#include "CertView.h"
#include "TempView.h"
#include "view/KeyView.h"
#include "view/ReqView.h"
#include "view/CertView.h"
#include "view/TempView.h"
#include "lib/pass_info.h"
#include "lib/func.h"
#include "ui/PassRead.h"

View File

@ -20,17 +20,17 @@ CFLAGS=-Wall @ac_DEBUG@
##############################################
NAMES= MainWindow ExportCert ExportKey ExportTinyCA NewX509 CrlDetail
NAMES= ExportCert ExportKey ExportTinyCA NewX509 CrlDetail \
MainWindow validity distname
OBJS=$(patsubst %,moc_%.o,$(NAMES)) $(patsubst %,%.o,$(NAMES))
MOC_CPP=$(patsubst %,moc_%.cpp,$(NAMES))
all: libwidget.a
all: widgets.o
libwidget.a: $(OBJS)
$(AR) rc $@ $(OBJS)
$(RANLIB) $@
widgets.o: $(OBJS)
$(LD) -r -o $@ $(OBJS)
%.o: %.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

149
widgets/validity.cpp Normal file
View File

@ -0,0 +1,149 @@
/*
* 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 <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#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);
}

83
widgets/validity.h Normal file
View File

@ -0,0 +1,83 @@
/*
* 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 <qvariant.h>
#include <qgroupbox.h>
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