4
0
mirror of https://github.com/QuasarApp/qca.git synced 2025-05-12 18:49:34 +00:00

some initial reworking

svn path=/trunk/kdesupport/qca/; revision=669398
This commit is contained in:
Justin Karneges 2007-05-29 08:16:00 +00:00
parent 03fba990fe
commit ca70140633
13 changed files with 865 additions and 317 deletions

@ -24,3 +24,19 @@ store icons
pgp keyring
unknown store/entry icon (can use the same icon for both i think)
when verifying a signature:
if the key is valid, import it and ask the user for a friendly name and
import into keyring
if the key is self-signed, ask the user to verify the fingerprint. if
validated, ask user for friendly name and import into keyring
ability to view CertItems, showing cert values and issuer hierarchy
report all 3 kinds of diagnostic text somewhere (plugin, keystore, secmessage)
integrated logger window? also allow setting the log level
items in loadstore ui should not be editable
don't show systemstore or pgpkeyrings
respect !usable state for items

@ -5,8 +5,8 @@ QT += gui
include(pkcs11configdlg/pkcs11configdlg.pri)
HEADERS += mylistview.h keystoreview.h
SOURCES += main.cpp
HEADERS += prompter.h mylistview.h keystoreview.h
SOURCES += prompter.cpp main.cpp
FORMS += mainwin.ui loadstore.ui
RESOURCES += cmssigner.qrc

@ -1,5 +1,9 @@
<RCC>
<qresource prefix="/gfx" >
<file>key.png</file>
<file>icons/cert16.png</file>
<file>icons/crl16.png</file>
<file>icons/keybundle16.png</file>
<file>icons/keypair16.png</file>
<file>icons/publickey16.png</file>
</qresource>
</RCC>

Binary file not shown.

After

(image error) Size: 670 B

Binary file not shown.

After

(image error) Size: 726 B

Binary file not shown.

After

(image error) Size: 815 B

Binary file not shown.

After

(image error) Size: 866 B

Binary file not shown.

After

(image error) Size: 627 B

Binary file not shown.

Before

(image error) Size: 693 B

File diff suppressed because it is too large Load Diff

@ -21,54 +21,43 @@
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>Keyring</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Identities:</string>
</property>
</widget>
</item>
<item>
<widget class="MyListView" name="lv_identities" />
<widget class="MyListView" name="lv_users" />
</item>
</layout>
</item>
<item>
</widget>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<string>Authorities</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Known Peers:</string>
</property>
</widget>
</item>
<item>
<widget class="MyListView" name="lv_known" />
<widget class="MyListView" name="lv_authorities" />
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
@ -168,33 +157,34 @@
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="actionLoad_Identity_From_File" />
<addaction name="actionLoad_Identity_From_Storage_Device" />
<addaction name="separator" />
<addaction name="actionConfigure_PKCS_11_Modules" />
<addaction name="separator" />
<addaction name="actionQuit" />
</widget>
<widget class="QMenu" name="menuHelp" >
<property name="title" >
<string>&amp;Help</string>
</property>
<addaction name="actionAbout_CMS_Signer" />
<addaction name="actionAbout" />
</widget>
<widget class="QMenu" name="menuFile" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="actionLoadIdentityFile" />
<addaction name="actionLoadIdentityEntry" />
<addaction name="actionLoadAuthority" />
<addaction name="separator" />
<addaction name="actionConfigurePkcs11" />
<addaction name="separator" />
<addaction name="actionQuit" />
</widget>
<addaction name="menuFile" />
<addaction name="menuHelp" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<action name="actionLoad_Identity_From_File" >
<action name="actionLoadIdentityFile" >
<property name="text" >
<string>Load Identity From &amp;File...</string>
</property>
</action>
<action name="actionLoad_Identity_From_Storage_Device" >
<action name="actionLoadIdentityEntry" >
<property name="text" >
<string>Load Identity From &amp;Storage Device...</string>
</property>
@ -204,16 +194,21 @@
<string>&amp;Quit</string>
</property>
</action>
<action name="actionAbout_CMS_Signer" >
<action name="actionAbout" >
<property name="text" >
<string>About CMS Signer</string>
</property>
</action>
<action name="actionConfigure_PKCS_11_Modules" >
<action name="actionConfigurePkcs11" >
<property name="text" >
<string>Configure &amp;PKCS#11 Modules...</string>
</property>
</action>
<action name="actionLoadAuthority" >
<property name="text" >
<string>Load &amp;Authority...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -222,6 +217,15 @@
<header>mylistview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>lv_users</tabstop>
<tabstop>lv_authorities</tabstop>
<tabstop>te_data</tabstop>
<tabstop>te_sig</tabstop>
<tabstop>pb_sign</tabstop>
<tabstop>pb_verify</tabstop>
</tabstops>
<resources>
<include location="cmssigner.qrc" />
</resources>

@ -0,0 +1,246 @@
/*
* Copyright (C) 2007 Justin Karneges <justin@affinix.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "prompter.h"
#include <QtCore>
#include <QtGui>
#include <QtCrypto>
class Prompter::Private : public QObject
{
Q_OBJECT
public:
Prompter *q;
class Item
{
public:
int id;
QCA::Event event;
};
QCA::EventHandler handler;
QList<Item> pending;
bool prompting;
QMessageBox *token_prompt;
QCA::KeyStoreManager ksm;
QList<QCA::KeyStore*> keyStores;
Private(Prompter *_q) :
QObject(_q),
q(_q),
handler(this),
prompting(false),
token_prompt(0),
ksm(this)
{
connect(&handler, SIGNAL(eventReady(int, const QCA::Event &)), SLOT(ph_eventReady(int, const QCA::Event &)));
handler.start();
connect(&ksm, SIGNAL(keyStoreAvailable(const QString &)), SLOT(ks_available(const QString &)));
foreach(const QString &keyStoreId, ksm.keyStores())
ks_available(keyStoreId);
}
~Private()
{
qDeleteAll(keyStores);
while(!pending.isEmpty())
handler.reject(pending.takeFirst().id);
}
private slots:
void ph_eventReady(int id, const QCA::Event &event)
{
Item i;
i.id = id;
i.event = event;
pending += i;
nextEvent();
}
void nextEvent()
{
if(prompting || pending.isEmpty())
return;
prompting = true;
const Item &i = pending.first();
const int &id = i.id;
const QCA::Event &event = i.event;
if(event.type() == QCA::Event::Password)
{
QCA::SecureArray known = q->knownPassword(event);
if(!known.isEmpty())
{
handler.submitPassword(id, known);
goto end;
}
QString type = Prompter::tr("password");
if(event.passwordStyle() == QCA::Event::StylePassphrase)
type = Prompter::tr("passphrase");
else if(event.passwordStyle() == QCA::Event::StylePIN)
type = Prompter::tr("PIN");
QString str;
if(event.source() == QCA::Event::KeyStore)
{
QString name;
QCA::KeyStoreEntry entry = event.keyStoreEntry();
if(!entry.isNull())
{
name = entry.name();
}
else
{
if(event.keyStoreInfo().type() == QCA::KeyStore::SmartCard)
name = Prompter::tr("the '%1' token").arg(event.keyStoreInfo().name());
else
name = event.keyStoreInfo().name();
}
str = Prompter::tr("Enter %1 for %2").arg(type, name);
}
else if(!event.fileName().isEmpty())
{
QFileInfo fi(event.fileName());
str = Prompter::tr("Enter %1 for %2:").arg(type, fi.fileName());
}
else
str = Prompter::tr("Enter %1:").arg(type);
bool ok;
QString pass = QInputDialog::getText(0, QApplication::instance()->applicationName() + ": " + tr("Prompt"), str, QLineEdit::Password, QString(), &ok);
if(ok)
{
QCA::SecureArray password = pass.toUtf8();
q->userSubmitted(password, event);
handler.submitPassword(id, password);
}
else
handler.reject(id);
}
else if(event.type() == QCA::Event::Token)
{
// even though we're being prompted for a missing token,
// we should still check if the token is present, due to
// a possible race between insert and token request.
bool found = false;
foreach(QCA::KeyStore *ks, keyStores)
{
if(ks->id() == event.keyStoreInfo().id())
{
found = true;
break;
}
}
if(found)
{
// auto-accept
handler.tokenOkay(id);
return;
}
QCA::KeyStoreEntry entry = event.keyStoreEntry();
QString name;
if(!entry.isNull())
{
name = Prompter::tr("the '%1' token for %2").arg(entry.storeName(), entry.name());
}
else
{
name = Prompter::tr("the '%1' token").arg(event.keyStoreInfo().name());
}
QString str = Prompter::tr("Please insert %1 and click OK.").arg(name);
QMessageBox msgBox(QMessageBox::Information, QApplication::instance()->applicationName() + ": " + tr("Prompt"), str, QMessageBox::Ok | QMessageBox::Cancel, 0);
token_prompt = &msgBox;
if(msgBox.exec() == QDialog::Accepted)
handler.tokenOkay(id);
else
handler.reject(id);
token_prompt = 0;
}
else
handler.reject(id);
end:
pending.removeFirst();
prompting = false;
if(!pending.isEmpty())
QMetaObject::invokeMethod(this, "nextEvent", Qt::QueuedConnection);
}
void ks_available(const QString &keyStoreId)
{
QCA::KeyStore *ks = new QCA::KeyStore(keyStoreId, &ksm);
connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
keyStores += ks;
// are we currently in a token prompt?
if(token_prompt && pending.first().event.type() == QCA::Event::Token)
{
// was the token we're looking for just inserted?
if(pending.first().event.keyStoreInfo().id() == keyStoreId)
{
// auto-accept
token_prompt->accept();
}
}
}
void ks_unavailable()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
keyStores.removeAll(ks);
delete ks;
}
};
Prompter::Prompter(QObject *parent) :
QObject(parent)
{
d = new Private(this);
}
Prompter::~Prompter()
{
delete d;
}
QCA::SecureArray Prompter::knownPassword(const QCA::Event &event)
{
Q_UNUSED(event);
return QCA::SecureArray();
}
void Prompter::userSubmitted(const QCA::SecureArray &password, const QCA::Event &event)
{
Q_UNUSED(password);
Q_UNUSED(event);
}
#include "prompter.moc"

@ -0,0 +1,54 @@
/*
* Copyright (C) 2007 Justin Karneges <justin@affinix.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#ifndef PROMPTER_H
#define PROMPTER_H
#include <QObject>
namespace QCA
{
class SecureArray;
class Event;
}
class Prompter : public QObject
{
Q_OBJECT
public:
Prompter(QObject *parent = 0);
~Prompter();
protected:
// called with every password event, to check for a known value.
// reimplement it to provide known/cached passwords.
virtual QCA::SecureArray knownPassword(const QCA::Event &event);
// called when a user-entered password is submitted. note that this
// does not mean the password was correct. to know if the password
// was correct, you'll have to match up the event information with
// the operation that triggered it.
virtual void userSubmitted(const QCA::SecureArray &password, const QCA::Event &event);
private:
class Private;
Private *d;
};
#endif