mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
account manager: move findCertificate to base class
Change-Id: I6f37b16f1ba897b337a30b4cac0e02904efc0556
This commit is contained in:
@ -362,6 +362,23 @@ AccountManager::getContactDetails(const std::string& uri) const
|
||||
return info_->contacts->getContactDetails(h);
|
||||
}
|
||||
|
||||
bool
|
||||
AccountManager::findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb)
|
||||
{
|
||||
if (auto cert = tls::CertificateStore::instance().getCertificate(h.toString())) {
|
||||
if (cb)
|
||||
cb(cert);
|
||||
} else {
|
||||
dht_->findCertificate(h, [cb](const std::shared_ptr<dht::crypto::Certificate>& crt) {
|
||||
if (crt)
|
||||
tls::CertificateStore::instance().pinCertificate(crt);
|
||||
if (cb)
|
||||
cb(crt);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AccountManager::setCertificateStatus(const std::string& cert_id, tls::TrustStore::PermissionStatus status)
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ public:
|
||||
/** Obtain details about one account contact in serializable form. */
|
||||
std::map<std::string, std::string> getContactDetails(const std::string& uri) const;
|
||||
|
||||
virtual bool findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb = {}) = 0;
|
||||
virtual bool findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb = {});
|
||||
bool setCertificateStatus(const std::string& cert_id, tls::TrustStore::PermissionStatus status);
|
||||
std::vector<std::string> getCertificatesByStatus(tls::TrustStore::PermissionStatus status);
|
||||
tls::TrustStore::PermissionStatus getCertificateStatus(const std::string& cert_id) const;
|
||||
|
@ -667,23 +667,6 @@ ArchiveAccountManager::exportArchive(const std::string& destinationPath, const s
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ArchiveAccountManager::findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb)
|
||||
{
|
||||
if (auto cert = tls::CertificateStore::instance().getCertificate(h.toString())) {
|
||||
if (cb)
|
||||
cb(cert);
|
||||
} else {
|
||||
dht_->findCertificate(h, [cb](const std::shared_ptr<dht::crypto::Certificate>& crt) {
|
||||
if (crt)
|
||||
tls::CertificateStore::instance().pinCertificate(crt);
|
||||
if (cb)
|
||||
cb(crt);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_RINGNS
|
||||
void
|
||||
|
@ -56,8 +56,6 @@ public:
|
||||
void syncDevices() override;
|
||||
void onSyncData(DeviceSync&& device);
|
||||
|
||||
bool findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb = {}) override;
|
||||
|
||||
void addDevice(const std::string& password, AddDeviceCallback) override;
|
||||
bool revokeDevice(const std::string& password, const std::string& device, RevokeDeviceCallback) override;
|
||||
bool exportArchive(const std::string& destinationPath, const std::string& password);
|
||||
|
@ -41,32 +41,18 @@ public:
|
||||
AuthFailureCallback onFailure,
|
||||
OnChangeCallback onChange) override;
|
||||
|
||||
bool changePassword(const std::string& password_old, const std::string& password_new) {
|
||||
bool changePassword(const std::string& password_old, const std::string& password_new) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void syncDevices();
|
||||
void syncDevices() override;
|
||||
|
||||
bool findCertificate(const dht::InfoHash& h, std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)>&& cb = {}) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
void lookupName(const std::string& name, LookupCallback cb) {
|
||||
|
||||
}
|
||||
|
||||
void lookupAddress(const std::string& address, LookupCallback cb) {
|
||||
|
||||
}*/
|
||||
|
||||
void registerName(const std::string& password, const std::string& name, RegistrationCallback cb);
|
||||
void registerName(const std::string& password, const std::string& name, RegistrationCallback cb) override;
|
||||
|
||||
private:
|
||||
struct AuthContext {
|
||||
CertRequest request;
|
||||
//std::unique_ptr<dht::crypto::CertificateRequest> request;
|
||||
std::unique_ptr<ServerAccountCredentials> credentials;
|
||||
//std::unique_ptr<DhtLoadContext> dhtContext;
|
||||
AuthSuccessCallback onSuccess;
|
||||
AuthFailureCallback onFailure;
|
||||
};
|
||||
|
Reference in New Issue
Block a user