Commit 6ab94469 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Revert: Add "Transfer to Card" action to key list

Andre and me discussed that all card management actions should be
restricted to the card management panel, in particular, to avoid
confusion about which card the action applies to if more than one card
is inserted.

GnuPG-bug-id: 4794
parent a1b782a5
......@@ -63,8 +63,6 @@ public:
MustBeTrustedRoot = 1024 | MustBeRoot,
MustBeUntrustedRoot = 2048 | MustBeRoot,
NeedsSmartCard = 4096,
_AllRestrictions_Helper,
AllRestrictions = 2 * (_AllRestrictions_Helper - 1) - 1
};
......
/* commands/setinitialpincommand.cpp
/* commands/keytocardcommand.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2017 Bundesamt für Sicherheit in der Informationstechnik
......@@ -49,7 +49,6 @@ class KeyToCardCommand::Private : public Command::Private
return static_cast<KeyToCardCommand *>(q);
}
public:
explicit Private(KeyToCardCommand *qq, KeyListController *c);
explicit Private(KeyToCardCommand *qq, const GpgME::Subkey &key, const std::string &serialno);
explicit Private(KeyToCardCommand *qq, const std::string &cardSlot, const std::string &serialno);
~Private();
......@@ -87,11 +86,6 @@ const KeyToCardCommand::Private *KeyToCardCommand::d_func() const
#define d d_func()
KeyToCardCommand::Private::Private(KeyToCardCommand *qq, KeyListController *c)
: Command::Private(qq, c)
{
}
KeyToCardCommand::Private::Private(KeyToCardCommand *qq,
const GpgME::Subkey &key,
const std::string &serialno)
......@@ -152,14 +146,6 @@ void KeyToCardCommand::Private::start()
}
namespace {
static GpgME::Subkey getSubkeyToTransferToOpenPGPCard(const std::vector<Key> &keys)
{
if (keys.size() == 1 && keys.front().hasSecret()) {
return keys.front().subkey(0);
}
return GpgME::Subkey();
}
static int getOpenPGPCardSlotForKey(const GpgME::Subkey &subKey, QWidget *parent)
{
// Check if we need to ask the user for the slot
......@@ -206,9 +192,6 @@ void KeyToCardCommand::Private::startTransferToOpenPGPCard() {
return;
}
if (mSubkey.isNull()) {
mSubkey = getSubkeyToTransferToOpenPGPCard(keys());
}
if (mSubkey.isNull()) {
finished();
return;
......@@ -264,7 +247,7 @@ void KeyToCardCommand::Private::startTransferToOpenPGPCard() {
}
namespace {
static GpgME::Subkey getSubkeyToTransferToPIVCard(const std::vector<Key> &keys, const std::string &cardSlot, const std::shared_ptr<PIVCard> &card)
static GpgME::Subkey getSubkeyToTransferToPIVCard(const std::string &cardSlot, const std::shared_ptr<PIVCard> &card)
{
if (!cardSlot.empty()) {
if (cardSlot == PIVCard::digitalSignatureKeyRef()) {
......@@ -281,9 +264,6 @@ static GpgME::Subkey getSubkeyToTransferToPIVCard(const std::vector<Key> &keys,
return GpgME::Subkey();
}
if (keys.size() == 1) {
return keys.front().subkey(0);
}
return GpgME::Subkey();
}
......@@ -335,7 +315,7 @@ void KeyToCardCommand::Private::startTransferToPIVCard()
}
if (mSubkey.isNull()) {
mSubkey = getSubkeyToTransferToPIVCard(keys(), cardSlot, pivCard);
mSubkey = getSubkeyToTransferToPIVCard(cardSlot, pivCard);
}
if (mSubkey.isNull()) {
if (!cardSlot.empty()) {
......@@ -482,21 +462,6 @@ void KeyToCardCommand::Private::authenticationCanceled()
canceled();
}
KeyToCardCommand::KeyToCardCommand(KeyListController *c)
: Command(new Private(this, c))
{
}
KeyToCardCommand::KeyToCardCommand(QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
}
KeyToCardCommand::KeyToCardCommand(const GpgME::Key &key)
: Command(key, new Private(this, nullptr))
{
}
KeyToCardCommand::KeyToCardCommand(const GpgME::Subkey &key, const std::string &serialno)
: Command(new Private(this, key, serialno))
{
......
......@@ -24,18 +24,10 @@ class KeyToCardCommand : public Command
{
Q_OBJECT
public:
explicit KeyToCardCommand(KeyListController *parent);
explicit KeyToCardCommand(QAbstractItemView *view, KeyListController *parent);
explicit KeyToCardCommand(const GpgME::Key &key);
KeyToCardCommand(const GpgME::Subkey &key, const std::string &serialno);
KeyToCardCommand(const std::string& cardSlot, const std::string &serialno);
~KeyToCardCommand() override;
/* reimp */ static Restrictions restrictions()
{
return OnlyOneKey | NeedSecretKey | NeedsSmartCard;
}
static bool supported();
public Q_SLOTS:
......
......@@ -47,8 +47,6 @@
<Action name="certificates_change_passphrase"/>
<Action name="certificates_add_userid"/>
<Separator/>
<Action name="certificates_transfer_to_card"/>
<Separator/>
<Action name="certificates_delete"/>
</Menu>
<Menu name="tools">
......@@ -116,8 +114,6 @@
<Action name="certificates_change_passphrase"/>
<Action name="certificates_add_userid"/>
<Separator/>
<Action name="certificates_transfer_to_card"/>
<Separator/>
<Action name="certificates_delete"/>
<Separator/>
<Action name="file_export_certificates"/>
......
......@@ -45,13 +45,11 @@
#include "commands/checksumverifyfilescommand.h"
#include "commands/checksumcreatefilescommand.h"
#include "commands/exportpaperkeycommand.h"
#include "commands/keytocardcommand.h"
#include <Libkleo/KeyCache>
#include <Libkleo/KeyListModel>
#include <Libkleo/Formatting>
#include <gpgme++/gpgmepp_version.h>
#include <gpgme++/key.h>
#include <KActionCollection>
......@@ -441,10 +439,6 @@ void KeyListController::createActions(KActionCollection *coll)
"certificates_add_userid", i18n("Add User-ID..."), QString(),
nullptr, nullptr, nullptr, QString(), false, true
},
{
"certificates_transfer_to_card", i18n("Transfer to Smartcard"), QString(),
"send-to-symbolic", nullptr, nullptr, QString(), false, true
},
{
"certificates_dump_certificate", i18n("Technical Details"), QString(),
nullptr, nullptr, nullptr, QString(), false, true
......@@ -524,10 +518,6 @@ void KeyListController::createActions(KActionCollection *coll)
//---
registerActionForCommand<ClearCrlCacheCommand>(coll->action(QStringLiteral("crl_clear_crl_cache")));
registerActionForCommand<DumpCrlCacheCommand>(coll->action(QStringLiteral("crl_dump_crl_cache")));
//---
#if GPGMEPP_VERSION >= 0x10E01 // 1.14.1
registerActionForCommand<KeyToCardCommand>(coll->action(QStringLiteral("certificates_transfer_to_card")));
#endif
enableDisableActions(nullptr);
}
......@@ -748,10 +738,6 @@ Command::Restrictions KeyListController::Private::calculateRestrictionsMask(cons
result |= find_root_restrictions(keys);
if (const ReaderStatus *rs = ReaderStatus::instance()) {
const auto cards = rs->getCards();
if (cards.size() && !cards[0]->serialNumber().empty()) {
result |= Command::NeedsSmartCard;
}
if (rs->anyCardHasNullPin()) {
result |= Command::AnyCardHasNullPin;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment