mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Export and Context menu for CRLs added
Export for CSRs
This commit is contained in:
parent
9a6a1169b6
commit
f585e8fd07
@ -53,6 +53,8 @@
|
||||
#include "widgets/MainWindow.h"
|
||||
#include "widgets/CrlDetail.h"
|
||||
#include <Qt/qmessagebox.h>
|
||||
#include <Qt/qevent.h>
|
||||
|
||||
|
||||
db_crl::db_crl(QString db, MainWindow *mw)
|
||||
:db_base(db,mw)
|
||||
@ -142,6 +144,35 @@ void db_crl::showItem(const QModelIndex &index)
|
||||
}
|
||||
}
|
||||
|
||||
void db_crl::store()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
|
||||
pki_crl *crl = static_cast<pki_crl*>(currentIdx.internalPointer());
|
||||
if (!crl)
|
||||
return;
|
||||
|
||||
ExportDer *dlg = new ExportDer(mainwin, crl->getUnderlinedName() + ".pem",
|
||||
mainwin->getPath(), tr("CRL ( *.pem *.der *.crl )") );
|
||||
dlg->image->setPixmap(*MainWindow::csrImg);
|
||||
dlg->label->setText(tr("Revokation list export"));
|
||||
int dlgret = dlg->exec();
|
||||
|
||||
if (!dlgret) {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
mainwin->setPath(dlg->dirPath);
|
||||
QString fname = dlg->filename->text();
|
||||
bool pem = dlg->exportFormat->currentIndex() == 0 ? true : false;
|
||||
delete dlg;
|
||||
if (fname == "") {
|
||||
return;
|
||||
}
|
||||
crl->writeCrl(fname, pem);
|
||||
}
|
||||
|
||||
pki_crl *db_crl::newItem(pki_x509 *cert)
|
||||
{
|
||||
if (!cert)
|
||||
@ -186,3 +217,19 @@ pki_crl *db_crl::newItem(pki_x509 *cert)
|
||||
return crl;
|
||||
}
|
||||
|
||||
void db_crl::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
currentIdx = index;
|
||||
|
||||
menu->addAction(tr("Import"), this, SLOT(load()));
|
||||
if (index != QModelIndex()) {
|
||||
menu->addAction(tr("Rename"), this, SLOT(edit()));
|
||||
menu->addAction(tr("Export"), this, SLOT(store()));
|
||||
menu->addAction(tr("Delete"), this, SLOT(delete_ask()));
|
||||
}
|
||||
menu->exec(e->globalPos());
|
||||
delete menu;
|
||||
currentIdx = QModelIndex();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,8 +48,10 @@
|
||||
|
||||
#include "db_x509.h"
|
||||
#include "pki_crl.h"
|
||||
#include "widgets/ExportDer.h"
|
||||
#include <Qt/qobject.h>
|
||||
#include <Qt/qpixmap.h>
|
||||
#include <Qt/qevent.h>
|
||||
|
||||
#ifndef DB_CRL_H
|
||||
#define DB_CRL_H
|
||||
@ -68,9 +70,12 @@ class db_crl: public db_base
|
||||
void preprocess();
|
||||
void inToCont(pki_base *pki);
|
||||
pki_base *insert(pki_base *item);
|
||||
void load();
|
||||
void showItem(const QModelIndex &index);
|
||||
pki_crl *newItem(pki_x509 *cert);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
public slots:
|
||||
void store();
|
||||
void load();
|
||||
signals:
|
||||
void updateCertView();
|
||||
};
|
||||
|
||||
@ -651,10 +651,10 @@ void db_x509::store()
|
||||
}
|
||||
mainwin->setPath(dlg->dirPath);
|
||||
QString fname = dlg->filename->text();
|
||||
if (fname == "") {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
if (fname == "") {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
switch (dlg->exportFormat->currentIndex()) {
|
||||
case 0: // PEM
|
||||
|
||||
@ -157,16 +157,37 @@ void db_x509req::showItem(QString descr)
|
||||
showItem(req);
|
||||
}
|
||||
|
||||
void db_x509req::store(bool pem)
|
||||
|
||||
void db_x509req::store()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
return;
|
||||
|
||||
pki_x509req *req = static_cast<pki_x509req*>(currentIdx.internalPointer());
|
||||
if (!req)
|
||||
return;
|
||||
|
||||
req->writeReq(req->getUnderlinedName(), pem);
|
||||
ExportDer *dlg = new ExportDer(mainwin, req->getUnderlinedName() + ".pem",
|
||||
mainwin->getPath(), tr("Certificate request ( *.pem *.der *.crl )") );
|
||||
dlg->image->setPixmap(*MainWindow::csrImg);
|
||||
dlg->label->setText(tr("Certificate request export"));
|
||||
int dlgret = dlg->exec();
|
||||
|
||||
if (!dlgret) {
|
||||
delete dlg;
|
||||
return;
|
||||
}
|
||||
mainwin->setPath(dlg->dirPath);
|
||||
QString fname = dlg->filename->text();
|
||||
bool pem = dlg->exportFormat->currentIndex() == 0 ? true : false;
|
||||
delete dlg;
|
||||
if (fname == "") {
|
||||
return;
|
||||
}
|
||||
req->writeReq(fname, pem);
|
||||
}
|
||||
|
||||
|
||||
void db_x509req::signReq()
|
||||
{
|
||||
if (!currentIdx.isValid())
|
||||
@ -179,7 +200,7 @@ void db_x509req::signReq()
|
||||
void db_x509req::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
{
|
||||
QMenu *menu = new QMenu(mainwin);
|
||||
QMenu *subExport;
|
||||
QAction *expItem;
|
||||
currentIdx = index;
|
||||
|
||||
pki_x509req *req = static_cast<pki_x509req*>(index.internalPointer());
|
||||
@ -190,11 +211,9 @@ void db_x509req::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
menu->addAction(tr("Rename"), this, SLOT(edit()));
|
||||
menu->addAction(tr("Show Details"), this, SLOT(showItem()));
|
||||
menu->addAction(tr("Sign"), this, SLOT(signReq()));
|
||||
subExport = menu->addMenu(tr("Export"));
|
||||
subExport->addAction(tr("PEM"), this, SLOT(store_pem()));
|
||||
subExport->addAction(tr("DER"), this, SLOT(store_der()));
|
||||
expItem = menu->addAction(tr("Export"), this, SLOT(store()));
|
||||
expItem->setEnabled(! req->isSpki());
|
||||
menu->addAction(tr("Delete"), this, SLOT(delete_ask()));
|
||||
subExport->setEnabled(! req->isSpki());
|
||||
}
|
||||
menu->exec(e->globalPos());
|
||||
delete menu;
|
||||
|
||||
@ -64,14 +64,12 @@ class db_x509req: public db_x509super
|
||||
db_x509req(QString DBfile, MainWindow *mw);
|
||||
pki_base* insert(pki_base *item);
|
||||
pki_base *newPKI();
|
||||
void store(bool pem);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
|
||||
public slots:
|
||||
void newItem(pki_temp *temp = NULL);
|
||||
void store_pem() {store(true);}
|
||||
void store_der() {store(false);}
|
||||
void load();
|
||||
void store();
|
||||
void showItem(QString descr);
|
||||
void showItem(pki_x509req *req);
|
||||
void showItem(const QModelIndex &index);
|
||||
|
||||
@ -190,7 +190,7 @@ pki_base * load_temp::loadItem(QString s)
|
||||
load_crl::load_crl()
|
||||
:load_base()
|
||||
{
|
||||
filter.prepend(QObject::tr("Revocation lists ( *.pem *.crl )"));
|
||||
filter.prepend(QObject::tr("Revocation lists ( *.pem *.der *.crl )"));
|
||||
caption = QObject::tr("Import Certificate Revocation List");
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ void pki_crl::sign(pki_key *key, const EVP_MD *md)
|
||||
|
||||
void pki_crl::writeDefault(const QString fname)
|
||||
{
|
||||
writeCrl(fname + QDir::separator() + getIntName() + ".crl", true);
|
||||
writeCrl(fname + QDir::separator() + getUnderlinedName() + ".crl", true);
|
||||
}
|
||||
|
||||
void pki_crl::writeCrl(const QString fname, bool pem)
|
||||
|
||||
@ -252,7 +252,7 @@ void x509name::write_fp(FILE *fp) const
|
||||
int cnt = entryCount();
|
||||
for (int i=0; i<cnt; i++) {
|
||||
QStringList sl = entryList(i);
|
||||
fprintf(fp, "%s=%s\n",sl[0].data(), sl[2].data());
|
||||
fprintf(fp, "%s=%s\n",CCHAR(sl[0]), CCHAR(sl[2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
HOST=w32
|
||||
QTDIR=/D/qt/4.2.1
|
||||
OPENSSLDIR=/D/openssl-0.9.8d
|
||||
MAKENSIS=/D/nsis/makensis.exe
|
||||
#CROSS=i586-mingw32msvc-
|
||||
MAKENSIS=wine /D/nsis/makensis.exe
|
||||
CROSS=i586-mingw32msvc-
|
||||
|
||||
QTDIR_DOS=d:\\qt\\4.2.1\\bin
|
||||
OPENSSLDIR_DOS=d:\\openssl-0.9.8d
|
||||
|
||||
#CONSOLE=-mwindows
|
||||
CONSOLE=-mconsole
|
||||
CPPFLAGS=-I. -I.. -I$(QTDIR)/include -I$(OPENSSLDIR)/outinc
|
||||
#CFLAGS=-Wall -g -ggdb -mthreads -mwindows
|
||||
CFLAGS=-Wall -g -ggdb -mthreads -mno-cygwin
|
||||
#CFLAGS=-Wall -g -ggdb -mthreads -mconsole
|
||||
CFLAGS=-Wall -g -ggdb -mthreads -mno-cygwin $(CONSOLE)
|
||||
|
||||
LDFLAGS= -L$(OPENSSLDIR)/out -L$(QTDIR)/lib \
|
||||
-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import \
|
||||
@ -23,15 +22,12 @@ LIBS=-lQtGui4 -lQtCore4 -lqtmain -lstdc++ -lws2_32 -lcrypto -lwsock32 -lgdi32
|
||||
# we use the native tools, because they are much faster than the wine's
|
||||
#MOC=wine $(QTDIR)/bin/moc
|
||||
#UIC=wine $(QTDIR)/bin/uic
|
||||
#RCC=wine $(QTDIR)/bin/rcc
|
||||
#LRELEASE=wine $(QTDIR)/bin/lrelease
|
||||
#MOC=moc-qt4
|
||||
#UIC=uic-qt4
|
||||
#RCC=rcc
|
||||
#LRELEASE=lrelease
|
||||
MOC=$(QTDIR)/bin/moc
|
||||
UIC=$(QTDIR)/bin/uic
|
||||
RCC=$(QTDIR)/bin/rcc
|
||||
LRELEASE=$(QTDIR)/bin/lrelease
|
||||
MOC=moc-qt4
|
||||
UIC=uic-qt4
|
||||
RCC=rcc
|
||||
LRELEASE=lrelease
|
||||
|
||||
CC=$(CROSS)gcc
|
||||
LD=$(CROSS)ld
|
||||
|
||||
293
ui/ExportDer.ui
Normal file
293
ui/ExportDer.ui
Normal file
@ -0,0 +1,293 @@
|
||||
<ui version="4.0" >
|
||||
<class>ExportDer</class>
|
||||
<widget class="QDialog" name="ExportDer" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>378</width>
|
||||
<height>238</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="font" >
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
<underline>false</underline>
|
||||
<strikeout>false</strikeout>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:14pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Export</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="image" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>95</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>95</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="scaledContents" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_2" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="TextLabel14" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filename" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fileBut" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="TextLabel1" >
|
||||
<property name="text" >
|
||||
<string>Export Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="exportFormat" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="PushButton9" >
|
||||
<property name="text" >
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="PushButton7" >
|
||||
<property name="text" >
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
|
||||
<tabstops>
|
||||
<tabstop>filename</tabstop>
|
||||
<tabstop>PushButton7</tabstop>
|
||||
<tabstop>PushButton9</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>PushButton9</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>ExportDer</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>81</x>
|
||||
<y>227</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>180</x>
|
||||
<y>237</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>PushButton7</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>ExportDer</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>367</x>
|
||||
<y>227</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>304</x>
|
||||
<y>237</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
106
widgets/ExportDer.cpp
Normal file
106
widgets/ExportDer.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ExportDer.h"
|
||||
#include "lib/base.h"
|
||||
|
||||
#include <Qt/qcombobox.h>
|
||||
#include <Qt/qlineedit.h>
|
||||
#include <Qt/qfiledialog.h>
|
||||
|
||||
ExportDer::ExportDer(QWidget *parent, QString fname, QString dpath,
|
||||
QString _filter)
|
||||
:QDialog(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
filename->setText(fname);
|
||||
setWindowTitle(tr(XCA_TITLE));
|
||||
QStringList sl;
|
||||
sl << "PEM" << "DER";
|
||||
|
||||
exportFormat->addItems(sl);
|
||||
dirPath = dpath;
|
||||
filter = _filter;
|
||||
}
|
||||
|
||||
void ExportDer::on_fileBut_clicked()
|
||||
{
|
||||
QStringList filt;
|
||||
filt.append(filter);
|
||||
filt.append(tr("All Files ( *.* )"));
|
||||
QString s = "", fn;
|
||||
QFileDialog *dlg = new QFileDialog(this);
|
||||
dlg->setWindowTitle(tr("Save as"));
|
||||
dlg->setFilters(filt);
|
||||
dlg->setFileMode( QFileDialog::AnyFile );
|
||||
fn = filename->text();
|
||||
fn = fn.mid(fn.lastIndexOf(QDir::separator()) +1, -1);
|
||||
dlg->selectFile( fn );
|
||||
dlg->setDirectory(dirPath);
|
||||
if (dlg->exec())
|
||||
if (!dlg->selectedFiles().isEmpty())
|
||||
s = dlg->selectedFiles()[0];
|
||||
if (! s.isEmpty()) {
|
||||
QDir::convertSeparators(s);
|
||||
filename->setText(s);
|
||||
}
|
||||
dirPath = dlg->directory().path();
|
||||
on_exportFormat_activated(0);
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void ExportDer::on_exportFormat_activated(int)
|
||||
{
|
||||
char *suffix[] = { "pem", "der" };
|
||||
int selected = exportFormat->currentIndex();
|
||||
QString fn = filename->text();
|
||||
QString nfn = fn.left(fn.lastIndexOf('.')+1) + suffix[selected];
|
||||
filename->setText(nfn);
|
||||
}
|
||||
|
||||
71
widgets/ExportDer.h
Normal file
71
widgets/ExportDer.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.trolltech.com
|
||||
*
|
||||
*
|
||||
*
|
||||
* http://www.hohnstaedt.de/xca
|
||||
* email: christian@hohnstaedt.de
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EXPORTDER_H
|
||||
#define __EXPORTDER_H
|
||||
|
||||
#include "ui/ExportDer.h"
|
||||
|
||||
class ExportDer: public QDialog, public Ui::ExportDer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QString filter;
|
||||
|
||||
public:
|
||||
ExportDer(QWidget *parent, QString fname, QString dpath,
|
||||
QString _filter);
|
||||
QString dirPath;
|
||||
|
||||
public slots:
|
||||
void on_fileBut_clicked();
|
||||
void on_exportFormat_activated(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -357,6 +357,11 @@ void MainWindow::on_BNimportCrl_clicked(void)
|
||||
if (crls)
|
||||
crls->load();
|
||||
}
|
||||
void MainWindow::on_BNexportCrl_clicked(void)
|
||||
{
|
||||
if (crls)
|
||||
crls->storeSelectedItems(crlView);
|
||||
}
|
||||
void MainWindow::on_BNdetailsCrl_clicked(void)
|
||||
{
|
||||
if(crls)
|
||||
|
||||
@ -155,5 +155,6 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
void on_BNdeleteCrl_clicked(void);
|
||||
void on_BNdetailsCrl_clicked(void);
|
||||
void on_BNimportCrl_clicked(void);
|
||||
void on_BNexportCrl_clicked(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -13,7 +13,7 @@ endif
|
||||
|
||||
MOC_NAMES=MainWindow KeyDetail clicklabel XcaTreeView ExportKey NewX509 \
|
||||
validity v3ext ReqDetail distname CertDetail CertExtend ExportCert \
|
||||
ImportMulti CrlDetail
|
||||
ImportMulti CrlDetail ExportDer
|
||||
|
||||
#NAMES=$(MOC_NAMES) NewX509_ext MW_menu MW_help MW_database
|
||||
NAMES=$(MOC_NAMES) NewX509_ext MW_menu MW_help MW_database
|
||||
|
||||
Loading…
Reference in New Issue
Block a user