DRAFT:Add support of reading system privatekey (.ssh/id_rsa)

This commit is contained in:
calvin
2023-08-04 18:41:04 +08:00
parent 0260444ca0
commit 486b920d6b
3 changed files with 38 additions and 1 deletions

View File

@@ -1,7 +1,10 @@
import 'dart:async';
import 'package:toolbox/core/persistant_store.dart';
import 'package:toolbox/data/model/server/private_key_info.dart';
import 'package:toolbox/core/utils/platform.dart';
class PrivateKeyStore extends PersistentStore {
late SystemPrivateKeyInfo systemPrivateKeyInfo;
void put(PrivateKeyInfo info) {
box.put(info.id, info);
}
@@ -15,10 +18,19 @@ class PrivateKeyStore extends PersistentStore {
ps.add(s);
}
}
if (isLinux || isMacOS) {
SystemPrivateKeyInfo sysPk = SystemPrivateKeyInfo();
unawaited(sysPk.getKey());
systemPrivateKeyInfo = sysPk;
ps.add(sysPk);
}
return ps;
}
PrivateKeyInfo? get(String? id) {
if (id == "System private key") {
return this.systemPrivateKeyInfo;
}
if (id == null) return null;
return box.get(id);
}