Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
66c0a62e
Commit
66c0a62e
authored
Dec 16, 2020
by
Ingo Klöcker
Browse files
Use ChangePinCommand for changing PINs of NetKey cards
parent
9abbbddb
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/smartcard/netkeycard.cpp
View file @
66c0a62e
...
...
@@ -53,6 +53,18 @@ NetKeyCard::NetKeyCard(const Card &card)
setAppName
(
AppName
);
}
// static
std
::
string
NetKeyCard
::
nksPinKeyRef
()
{
return
std
::
string
(
"PW1.CH"
);
}
// static
std
::
string
NetKeyCard
::
sigGPinKeyRef
()
{
return
std
::
string
(
"PW1.CH.SIG"
);
}
void
NetKeyCard
::
setCardInfo
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
&
infos
)
{
qCDebug
(
KLEOPATRA_LOG
)
<<
"Card"
<<
serialNumber
().
c_str
()
<<
"info:"
;
...
...
src/smartcard/netkeycard.h
View file @
66c0a62e
...
...
@@ -26,6 +26,9 @@ public:
static
const
std
::
string
AppName
;
static
std
::
string
nksPinKeyRef
();
static
std
::
string
sigGPinKeyRef
();
void
setCardInfo
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
&
infos
);
bool
hasSigGNullPin
()
const
;
...
...
src/view/netkeywidget.cpp
View file @
66c0a62e
...
...
@@ -16,6 +16,7 @@
#include "smartcard/netkeycard.h"
#include "smartcard/readerstatus.h"
#include "commands/changepincommand.h"
#include "commands/createopenpgpkeyfromcardkeyscommand.h"
#include "commands/learncardkeyscommand.h"
#include "commands/detailscommand.h"
...
...
@@ -145,14 +146,8 @@ NetKeyWidget::NetKeyWidget(QWidget *parent) :
mChangeNKSPINBtn
->
setText
(
i18nc
(
"NKS is an identifier for a type of keys on a NetKey card"
,
"Change NKS PIN"
));
mChangeSigGPINBtn
->
setText
(
i18nc
(
"SigG is an identifier for a type of keys on a NetKey card"
,
"Change SigG PIN"
));
connect
(
mChangeNKSPINBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
]
()
{
mChangeNKSPINBtn
->
setEnabled
(
false
);
doChangePin
(
false
);
});
connect
(
mChangeSigGPINBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
]
()
{
mChangeSigGPINBtn
->
setEnabled
(
false
);
doChangePin
(
true
);
});
connect
(
mChangeNKSPINBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
]
()
{
doChangePin
(
NetKeyCard
::
nksPinKeyRef
());
});
connect
(
mChangeSigGPINBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
]
()
{
doChangePin
(
NetKeyCard
::
sigGPinKeyRef
());
});
actionLayout
->
addWidget
(
mChangeNKSPINBtn
);
actionLayout
->
addWidget
(
mChangeSigGPINBtn
);
...
...
@@ -210,45 +205,16 @@ void NetKeyWidget::setCard(const NetKeyCard* card)
}
}
void
NetKeyWidget
::
handleResult
(
const
GpgME
::
Error
&
err
,
QPushButton
*
btn
)
{
btn
->
setEnabled
(
true
);
if
(
err
.
isCanceled
())
{
return
;
}
if
(
err
)
{
KMessageBox
::
error
(
this
,
i18nc
(
"@info"
,
"Failed to set PIN: %1"
,
QString
::
fromLatin1
(
err
.
asString
())),
i18nc
(
"@title"
,
"Error"
));
return
;
}
}
void
NetKeyWidget
::
setSigGPinSettingResult
(
const
GpgME
::
Error
&
err
)
{
handleResult
(
err
,
mChangeSigGPINBtn
);
}
void
NetKeyWidget
::
setNksPinSettingResult
(
const
GpgME
::
Error
&
err
)
{
handleResult
(
err
,
mChangeNKSPINBtn
);
}
void
NetKeyWidget
::
doChangePin
(
bool
sigG
)
void
NetKeyWidget
::
doChangePin
(
const
std
::
string
&
keyRef
)
{
const
auto
nksCard
=
ReaderStatus
::
instance
()
->
getCard
<
NetKeyCard
>
(
mSerialNumber
);
if
(
!
nksCard
)
{
KMessageBox
::
error
(
this
,
i18n
(
"Failed to find the NetKey card with the serial number: %1"
,
QString
::
fromStdString
(
mSerialNumber
)));
return
;
}
if
(
sigG
)
{
ReaderStatus
::
mutableInstance
()
->
startSimpleTransaction
(
nksCard
,
"SCD PASSWD PW1.CH.SIG"
,
this
,
"setSigGPinSettingResult"
);
}
else
{
ReaderStatus
::
mutableInstance
()
->
startSimpleTransaction
(
nksCard
,
"SCD PASSWD PW1.CH"
,
this
,
"setNksPinSettingResult"
);
}
auto
cmd
=
new
ChangePinCommand
(
mSerialNumber
,
NetKeyCard
::
AppName
,
this
);
this
->
setEnabled
(
false
);
connect
(
cmd
,
&
ChangePinCommand
::
finished
,
this
,
[
this
]()
{
this
->
setEnabled
(
true
);
});
cmd
->
setKeyRef
(
keyRef
);
cmd
->
start
();
}
void
NetKeyWidget
::
createKeyFromCardKeys
()
...
...
src/view/netkeywidget.h
View file @
66c0a62e
...
...
@@ -37,14 +37,9 @@ public:
void
setCard
(
const
SmartCard
::
NetKeyCard
*
card
);
private:
void
handleResult
(
const
GpgME
::
Error
&
err
,
QPushButton
*
btn
);
void
doChangePin
(
bool
sigG
);
void
doChangePin
(
const
std
::
string
&
keyRef
);
void
createKeyFromCardKeys
();
private
Q_SLOTS
:
void
setSigGPinSettingResult
(
const
GpgME
::
Error
&
err
);
void
setNksPinSettingResult
(
const
GpgME
::
Error
&
err
);
private:
std
::
string
mSerialNumber
;
QLabel
*
mSerialNumberLabel
=
nullptr
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment