mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 02:01:36 +03:00
Use one command for delete cert/key
This commit is contained in:
parent
ff6f72ae16
commit
d70644e599
@ -389,13 +389,6 @@ class SlotNode(RpcNode):
|
||||
self.certificate = certificate
|
||||
self._refresh = refresh
|
||||
|
||||
def _require_version(self, major, minor, micro):
|
||||
try:
|
||||
require_version(self.session.version, (major, minor, micro))
|
||||
return True
|
||||
except NotSupportedError:
|
||||
return False
|
||||
|
||||
def get_data(self):
|
||||
return dict(
|
||||
id=f"{int(self.slot):02x}",
|
||||
@ -406,17 +399,20 @@ class SlotNode(RpcNode):
|
||||
else None,
|
||||
)
|
||||
|
||||
@action(condition=lambda self: self.certificate)
|
||||
def delete_certificate(self, params, event, signal):
|
||||
self.session.delete_certificate(self.slot)
|
||||
self.session.put_object(OBJECT_ID.CHUID, generate_chuid())
|
||||
self._refresh()
|
||||
self.certificate = None
|
||||
return dict()
|
||||
@action(condition=lambda self: self.certificate or self.metadata)
|
||||
def delete(self, params, event, signal):
|
||||
delete_cert = params.pop("delete_cert", False)
|
||||
delete_key = params.pop("delete_key", False)
|
||||
|
||||
@action(condition=lambda self: self.metadata and self._require_version(5, 7, 0))
|
||||
def delete_key(self, params, event, signal):
|
||||
self.session.delete_key(self.slot)
|
||||
if not delete_cert and not delete_key:
|
||||
raise ValueError("Missing delete option")
|
||||
|
||||
if delete_cert:
|
||||
self.session.delete_certificate(self.slot)
|
||||
self.session.put_object(OBJECT_ID.CHUID, generate_chuid())
|
||||
self.certificate = None
|
||||
if delete_key:
|
||||
self.session.delete_key(self.slot)
|
||||
self._refresh()
|
||||
return dict()
|
||||
|
||||
|
@ -317,14 +317,10 @@ class _DesktopPivSlotsNotifier extends PivSlotsNotifier {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteCertificate(SlotId slot) async {
|
||||
await _session.command('delete_certificate', target: ['slots', slot.hexId]);
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteKey(SlotId slot) async {
|
||||
await _session.command('delete_key', target: ['slots', slot.hexId]);
|
||||
Future<void> delete(SlotId slot, bool deleteCert, bool deleteKey) async {
|
||||
await _session.command('delete',
|
||||
target: ['slots', slot.hexId],
|
||||
params: {'delete_cert': deleteCert, 'delete_key': deleteKey});
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@
|
||||
},
|
||||
"l_generating_private_key": "Generating private key\u2026",
|
||||
"s_private_key_generated": "Private key generated",
|
||||
"p_select_what_to_delete": "Please select what to delete from the slot.",
|
||||
"p_select_what_to_delete": "Select what to delete from the slot.",
|
||||
"p_warning_delete_certificate": "Warning! This action will delete the certificate from your YubiKey.",
|
||||
"p_warning_delete_key": "Warning! This action will delete the key from your YubiKey.",
|
||||
"p_warning_delete_certificate_and_key": "Warning! This action will delete the certificate and key from your YubiKey.",
|
||||
|
@ -66,6 +66,5 @@ abstract class PivSlotsNotifier
|
||||
PinPolicy pinPolicy = PinPolicy.dfault,
|
||||
TouchPolicy touchPolicy = TouchPolicy.dfault,
|
||||
});
|
||||
Future<void> deleteCertificate(SlotId slot);
|
||||
Future<void> deleteKey(SlotId slot);
|
||||
Future<void> delete(SlotId slot, bool deleteCert, bool deleteKey);
|
||||
}
|
||||
|
@ -71,16 +71,10 @@ class _DeleteCertificateDialogState
|
||||
onPressed: _deleteKey || _deleteCertificate
|
||||
? () async {
|
||||
try {
|
||||
if (_deleteCertificate) {
|
||||
await ref
|
||||
.read(pivSlotsProvider(widget.devicePath).notifier)
|
||||
.deleteCertificate(widget.pivSlot.slot);
|
||||
}
|
||||
if (_deleteKey) {
|
||||
await ref
|
||||
.read(pivSlotsProvider(widget.devicePath).notifier)
|
||||
.deleteKey(widget.pivSlot.slot);
|
||||
}
|
||||
await ref
|
||||
.read(pivSlotsProvider(widget.devicePath).notifier)
|
||||
.delete(widget.pivSlot.slot, _deleteCertificate,
|
||||
_deleteKey);
|
||||
|
||||
await ref.read(withContextProvider)(
|
||||
(context) async {
|
||||
|
Loading…
Reference in New Issue
Block a user