mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
extend Multi-import dialog to token-manager
- add token information - add "Delete token" button
This commit is contained in:
parent
344f065446
commit
1102308dfc
@ -380,8 +380,8 @@ QString pkcs11::driverInfo()
|
||||
|
||||
return QString(
|
||||
"Cryptoki version: %1.%2\n"
|
||||
"Manufacturer: %3\n"
|
||||
"Library: %4 (%5.%6)\n").
|
||||
"Manufacturer: %3\n"
|
||||
"Library: %4 (%5.%6)\n").
|
||||
arg(info.cryptokiVersion.major).arg(info.cryptokiVersion.minor).
|
||||
arg(UTF8QSTRING(info.manufacturerID, 32)).
|
||||
arg(UTF8QSTRING(info.libraryDescription, 32)).
|
||||
|
||||
@ -6,101 +6,163 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>362</height>
|
||||
<width>516</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
<layout class="QHBoxLayout" name="_2">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="heading">
|
||||
<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>Import PKI Items</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" stdset="0">
|
||||
<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>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butOk">
|
||||
<property name="text">
|
||||
<string>Import &All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butImport">
|
||||
<property name="text">
|
||||
<string>&Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butCancel">
|
||||
<property name="text">
|
||||
<string>&Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butRemove">
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butDetails">
|
||||
<property name="text">
|
||||
<string>Details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>204</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="image">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>94</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="butOk">
|
||||
<property name="text">
|
||||
<string>Import &All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butImport">
|
||||
<property name="text">
|
||||
<string>&Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butCancel">
|
||||
<property name="text">
|
||||
<string>&Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butRemove">
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="butDetails">
|
||||
<property name="text">
|
||||
<string>Details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deleteToken">
|
||||
<property name="text">
|
||||
<string>Delete from token</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>204</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="slotInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@ -28,7 +28,7 @@ ImportMulti::ImportMulti(MainWindow *parent)
|
||||
{
|
||||
mainwin = parent;
|
||||
setupUi(this);
|
||||
setWindowTitle(tr(XCA_TITLE));
|
||||
setWindowTitle(XCA_TITLE);
|
||||
image->setPixmap(*MainWindow::certImg);
|
||||
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
mcont = new db_base("/dev/null", parent);
|
||||
@ -37,7 +37,17 @@ ImportMulti::ImportMulti(MainWindow *parent)
|
||||
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
connect( listView, SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this, SLOT(on_butDetails_clicked()));
|
||||
deleteToken->hide();
|
||||
slotInfo->hide();
|
||||
}
|
||||
|
||||
void ImportMulti::tokenInfo(QString &info)
|
||||
{
|
||||
deleteToken->show();
|
||||
slotInfo->show();
|
||||
slotInfo->setText(info);
|
||||
image->setPixmap(*MainWindow::scardImg);
|
||||
heading->setText(tr("Manage security token"));
|
||||
}
|
||||
|
||||
void ImportMulti::addItem(pki_base *pki)
|
||||
@ -119,6 +129,27 @@ void ImportMulti::on_butImport_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void ImportMulti::on_deleteToken_clicked()
|
||||
{
|
||||
QItemSelectionModel *selectionModel = listView->selectionModel();
|
||||
QModelIndexList indexes = selectionModel->selectedIndexes();
|
||||
QModelIndex index;
|
||||
QString items;
|
||||
|
||||
foreach(index, indexes) {
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
pki_base *pki = static_cast<pki_base*>(index.internalPointer());
|
||||
try {
|
||||
pki->deleteFromToken();
|
||||
mcont->remFromCont(index);
|
||||
delete pki;
|
||||
} catch (errorEx &err) {
|
||||
mainwin->Error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pki_base *ImportMulti::import(QModelIndex &idx)
|
||||
{
|
||||
|
||||
@ -209,9 +240,7 @@ void ImportMulti::on_butDetails_clicked()
|
||||
arg(cn));
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
QMessageBox::warning(this, XCA_TITLE,
|
||||
tr("Error") + pki->getClassName() +
|
||||
err.getString());
|
||||
mainwin->Error(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,12 +30,14 @@ class ImportMulti: public QDialog, private Ui::ImportMulti
|
||||
pki_base *import(QModelIndex &idx);
|
||||
void execute(int force=0);
|
||||
int entries();
|
||||
void tokenInfo(QString &info);
|
||||
|
||||
public slots:
|
||||
void on_butRemove_clicked();
|
||||
void on_butImport_clicked();
|
||||
void on_butDetails_clicked();
|
||||
void on_butOk_clicked();
|
||||
void on_deleteToken_clicked();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ void MainWindow::init_menu()
|
||||
|
||||
token = menuBar()->addMenu(tr("&Token"));
|
||||
token->addAction(tr("&Manage Security token"), this,
|
||||
SLOT(importScard()));
|
||||
SLOT(manageToken()));
|
||||
token->addAction(tr("&Init Security token"), this,
|
||||
SLOT(initToken()));
|
||||
token->addAction(tr("&Change PIN"), this,
|
||||
|
||||
@ -450,7 +450,7 @@ void MainWindow::initPin()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::importScard()
|
||||
void MainWindow::manageToken()
|
||||
{
|
||||
pkcs11 p11;
|
||||
unsigned long slot;
|
||||
@ -466,9 +466,15 @@ void MainWindow::importScard()
|
||||
return;
|
||||
|
||||
ImportMulti *dlgi = new ImportMulti(this);
|
||||
QList<CK_OBJECT_HANDLE> objects;
|
||||
|
||||
p11.startSession(slot);
|
||||
QString info = p11.driverInfo();
|
||||
tkInfo ti = p11.tokenInfo();
|
||||
info += tr("\nName: %1\nModel: %2\nSerial: %3").
|
||||
arg(ti.label()).arg(ti.model()).arg(ti.serial());
|
||||
dlgi->tokenInfo(info);
|
||||
QList<CK_OBJECT_HANDLE> objects;
|
||||
|
||||
QList<CK_MECHANISM_TYPE> ml = p11.mechanismList(slot);
|
||||
if (ml.count() == 0)
|
||||
ml << CKM_SHA1_RSA_PKCS;
|
||||
|
||||
@ -100,7 +100,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
|
||||
private slots:
|
||||
void setOptions();
|
||||
void importScard();
|
||||
void manageToken();
|
||||
void initToken();
|
||||
void changePin(bool so=false);
|
||||
void changeSoPin();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user