Ring Daemon 16.0.0
|
#include <account_manager.h>
Classes | |
struct | AccountCredentials |
Public Member Functions | |
bool | acceptTrustRequest (const std::string &from, bool includeConversation=true) |
AccountManager (const std::string &accountId, const std::filesystem::path &path, const std::string &nameServer) | |
bool | addContact (const dht::InfoHash &uri, bool confirmed=false, const std::string &conversationId="") |
Add contact to the account contact list. | |
virtual int32_t | addDevice (const std::string &, std::string_view, AuthChannelHandler *) |
Initiates the process of adding a new device to the account. | |
CertRequest | buildRequest (PrivateKey fDeviceKey) |
virtual bool | cancelAddDevice (uint32_t) |
dhtnet::tls::CertificateStore & | certStore () const |
virtual bool | changePassword (const std::string &password_old, const std::string &password_new)=0 |
virtual bool | confirmAddDevice (uint32_t) |
bool | discardTrustRequest (const std::string &from) |
virtual bool | findCertificate (const dht::InfoHash &h, std::function< void(const std::shared_ptr< dht::crypto::Certificate > &)> &&cb={}) |
virtual bool | findCertificate (const dht::PkId &h, std::function< void(const std::shared_ptr< dht::crypto::Certificate > &)> &&cb={}) |
void | forEachDevice (const dht::InfoHash &to, std::function< void(const std::shared_ptr< dht::crypto::PublicKey > &)> &&op, std::function< void(bool)> &&end={}) |
bool | foundAccountDevice (const std::shared_ptr< dht::crypto::Certificate > &crt, const std::string &name={}, const time_point &last_sync=time_point::min()) |
std::string | getAccountDeviceName () const |
std::vector< std::string > | getCertificatesByStatus (dhtnet::tls::TrustStore::PermissionStatus status) |
dhtnet::tls::TrustStore::PermissionStatus | getCertificateStatus (const std::string &cert_id) const |
std::map< std::string, std::string > | getContactDetails (const std::string &uri) const |
Obtain details about one account contact in serializable form. | |
std::optional< Contact > | getContactInfo (const std::string &uri) const |
std::vector< std::map< std::string, std::string > > | getContacts (bool includeRemoved=false) const |
const AccountInfo * | getInfo () const |
const std::map< dht::PkId, KnownDevice > & | getKnownDevices () const |
virtual std::vector< uint8_t > | getPasswordKey (const std::string &) |
std::vector< std::map< std::string, std::string > > | getTrustRequests () const |
virtual void | initAuthentication (PrivateKey request, std::string deviceName, std::unique_ptr< AccountCredentials > credentials, AuthSuccessCallback onSuccess, AuthFailureCallback onFailure, const OnChangeCallback &onChange)=0 |
bool | isAllowed (const crypto::Certificate &crt, bool allowPublic=false) |
virtual bool | isPasswordValid (const std::string &) |
dht::crypto::Identity | loadIdentity (const std::string &crt_path, const std::string &key_path, const std::string &key_pwd) const |
virtual void | lookupAddress (const std::string &address, LookupCallback cb) |
virtual void | lookupUri (const std::string &name, const std::string &defaultServer, LookupCallback cb) |
bool | onPeerCertificate (const std::shared_ptr< dht::crypto::Certificate > &crt, bool allowPublic, dht::InfoHash &account_id) |
void | onPeerMessage (const dht::crypto::PublicKey &peer_device, bool allowPublic, PeerCertificateCb &&cb) |
virtual void | onSyncData (DeviceSync &&device, bool checkDevice=true) |
virtual void | registerName (const std::string &name, std::string_view scheme, const std::string &password, RegistrationCallback cb)=0 |
void | reloadContacts () |
void | removeContact (const std::string &uri, bool banned=true) |
void | removeContactConversation (const std::string &uri) |
virtual bool | revokeDevice (const std::string &, std::string_view, const std::string &, RevokeDeviceCallback) |
virtual bool | searchUser (const std::string &, SearchCallback) |
void | sendTrustRequest (const std::string &to, const std::string &convId, const std::vector< uint8_t > &payload) |
void | sendTrustRequestConfirm (const dht::InfoHash &to, const std::string &conversationId) |
void | setAccountDeviceName (const std::string &name) |
bool | setCertificateStatus (const std::shared_ptr< crypto::Certificate > &cert, dhtnet::tls::TrustStore::PermissionStatus status, bool local=true) |
bool | setCertificateStatus (const std::string &cert_id, dhtnet::tls::TrustStore::PermissionStatus status) |
void | setDht (const std::shared_ptr< dht::DhtRunner > &dht) |
virtual void | startSync (const OnNewDeviceCb &cb, const OnDeviceAnnouncedCb &dcb, bool publishPresence=true) |
virtual void | syncDevices ()=0 |
void | updateContactConversation (const std::string &uri, const std::string &convId) |
const AccountInfo * | useIdentity (const dht::crypto::Identity &id, const std::string &receipt, const std::vector< uint8_t > &receiptSignature, const std::string &username, const OnChangeCallback &onChange) |
virtual | ~AccountManager () |
Static Public Member Functions | |
static bool | foundPeerDevice (const std::string &accoundId, const std::shared_ptr< dht::crypto::Certificate > &crt, dht::InfoHash &account_id) |
Inform that a potential peer device have been found. | |
static std::shared_ptr< dht::Value > | parseAnnounce (const std::string &announceBase64, const std::string &accountId, const std::string &deviceSha1, const std::string &deviceSha256) |
Static Public Attributes | |
static constexpr const char *const | DHT_TYPE_NS = "cx.ring" |
Protected Attributes | |
const std::string | accountId_ |
std::shared_ptr< dht::DhtRunner > | dht_ |
std::unique_ptr< AccountInfo > | info_ |
std::reference_wrapper< NameDirectory > | nameDir_ |
OnChangeCallback | onChange_ |
const std::filesystem::path | path_ |
Definition at line 73 of file account_manager.h.
using jami::AccountManager::AuthFailureCallback = std::function<void(AuthError error, const std::string& message)> |
Definition at line 102 of file account_manager.h.
using jami::AccountManager::AuthSuccessCallback = std::function<void(const AccountInfo& info, const std::map<std::string, std::string>& config, std::string&& receipt, std::vector<uint8_t>&& receipt_signature)> |
Definition at line 97 of file account_manager.h.
using jami::AccountManager::CertRequest = std::future<std::unique_ptr<dht::crypto::CertificateRequest> > |
Definition at line 104 of file account_manager.h.
using jami::AccountManager::clock = std::chrono::system_clock |
Definition at line 77 of file account_manager.h.
using jami::AccountManager::DeviceSyncCallback = std::function<void(DeviceSync&& syncData)> |
Definition at line 103 of file account_manager.h.
Definition at line 277 of file account_manager.h.
Definition at line 76 of file account_manager.h.
using jami::AccountManager::OnDeviceAnnouncedCb = std::function<void()> |
Definition at line 80 of file account_manager.h.
using jami::AccountManager::OnNewDeviceCb = std::function<void(const std::shared_ptr<dht::crypto::Certificate>&)> |
Definition at line 79 of file account_manager.h.
using jami::AccountManager::PeerCertificateCb = std::function<void(const std::shared_ptr<dht::crypto::Certificate>& crt, const dht::InfoHash& peer_account)> |
Definition at line 204 of file account_manager.h.
using jami::AccountManager::PrivateKey = std::shared_future<std::shared_ptr<dht::crypto::PrivateKey> > |
Definition at line 105 of file account_manager.h.
Definition at line 280 of file account_manager.h.
using jami::AccountManager::RevokeDeviceCallback = std::function<void(RevokeDeviceResult)> |
Definition at line 164 of file account_manager.h.
Definition at line 279 of file account_manager.h.
Definition at line 281 of file account_manager.h.
Definition at line 278 of file account_manager.h.
using jami::AccountManager::time_point = clock::time_point |
Definition at line 78 of file account_manager.h.
Enumerator | |
---|---|
INVALID_URI | |
ALREADY_LINKING | |
GENERIC |
Definition at line 156 of file account_manager.h.
Enumerator | |
---|---|
UNKNOWN | |
INVALID_ARGUMENTS | |
SERVER_ERROR | |
NETWORK |
Definition at line 95 of file account_manager.h.
Enumerator | |
---|---|
SUCCESS | |
ERROR_CREDENTIALS | |
ERROR_NETWORK |
Definition at line 158 of file account_manager.h.
|
inline |
Definition at line 82 of file account_manager.h.
|
virtual |
Definition at line 53 of file account_manager.cpp.
References dht_.
bool jami::AccountManager::acceptTrustRequest | ( | const std::string & | from, |
bool | includeConversation = true |
||
) |
Definition at line 692 of file account_manager.cpp.
References libjami::Account::TrustRequest::CONVERSATIONID.
bool jami::AccountManager::addContact | ( | const dht::InfoHash & | uri, |
bool | confirmed = false , |
||
const std::string & | conversationId = "" |
||
) |
Add contact to the account contact list.
Set confirmed if we know the contact also added us.
Definition at line 487 of file account_manager.cpp.
References JAMI_ERROR, and JAMI_WARNING.
|
inlinevirtual |
Initiates the process of adding a new device to the account.
uri | The URI provided by the new device to be added |
auth_scheme | The auth scheme (currently only "password" is expected) |
chanel |
Reimplemented in jami::ArchiveAccountManager.
Definition at line 176 of file account_manager.h.
AccountManager::CertRequest jami::AccountManager::buildRequest | ( | PrivateKey | fDeviceKey | ) |
Definition at line 40 of file account_manager.cpp.
References jami::emitSignal().
Referenced by jami::ArchiveAccountManager::initAuthentication(), and jami::ServerAccountManager::initAuthentication().
Reimplemented in jami::ArchiveAccountManager.
Definition at line 182 of file account_manager.h.
dhtnet::tls::CertificateStore & jami::AccountManager::certStore | ( | ) | const |
Definition at line 856 of file account_manager.cpp.
|
pure virtual |
Implemented in jami::ServerAccountManager, and jami::ArchiveAccountManager.
Reimplemented in jami::ArchiveAccountManager.
Definition at line 183 of file account_manager.h.
Definition at line 711 of file account_manager.cpp.
|
virtual |
Definition at line 610 of file account_manager.cpp.
Referenced by onSyncData().
|
virtual |
Definition at line 632 of file account_manager.cpp.
void jami::AccountManager::forEachDevice | ( | const dht::InfoHash & | to, |
std::function< void(const std::shared_ptr< dht::crypto::PublicKey > &)> && | op, | ||
std::function< void(bool)> && | end = {} |
||
) |
Definition at line 771 of file account_manager.cpp.
References JAMI_ERROR, and JAMI_LOG.
bool jami::AccountManager::foundAccountDevice | ( | const std::shared_ptr< dht::crypto::Certificate > & | crt, |
const std::string & | name = {} , |
||
const time_point & | last_sync = time_point::min() |
||
) |
Definition at line 379 of file account_manager.cpp.
|
static |
Inform that a potential peer device have been found.
Returns true only if the device certificate is a valid device certificate. In that case (true is returned) the account_id parameter is set to the peer account ID.
Definition at line 402 of file account_manager.cpp.
References JAMI_LOG, and JAMI_WARNING.
std::string jami::AccountManager::getAccountDeviceName | ( | ) | const |
Definition at line 394 of file account_manager.cpp.
std::vector< std::string > jami::AccountManager::getCertificatesByStatus | ( | dhtnet::tls::TrustStore::PermissionStatus | status | ) |
Definition at line 663 of file account_manager.cpp.
dhtnet::tls::TrustStore::PermissionStatus jami::AccountManager::getCertificateStatus | ( | const std::string & | cert_id | ) | const |
Definition at line 669 of file account_manager.cpp.
std::map< std::string, std::string > jami::AccountManager::getContactDetails | ( | const std::string & | uri | ) | const |
Obtain details about one account contact in serializable form.
Definition at line 580 of file account_manager.cpp.
References JAMI_ERROR.
Definition at line 595 of file account_manager.cpp.
References JAMI_ERROR.
std::vector< std::map< std::string, std::string > > jami::AccountManager::getContacts | ( | bool | includeRemoved = false | ) | const |
Definition at line 556 of file account_manager.cpp.
References JAMI_ERROR.
|
inline |
Definition at line 150 of file account_manager.h.
References info_.
const std::map< dht::PkId, KnownDevice > & jami::AccountManager::getKnownDevices | ( | ) | const |
Definition at line 373 of file account_manager.cpp.
|
inlinevirtual |
Reimplemented in jami::ArchiveAccountManager.
Definition at line 132 of file account_manager.h.
std::vector< std::map< std::string, std::string > > jami::AccountManager::getTrustRequests | ( | ) | const |
Definition at line 682 of file account_manager.cpp.
References JAMI_ERROR.
|
pure virtual |
Implemented in jami::ArchiveAccountManager, and jami::ServerAccountManager.
Definition at line 676 of file account_manager.cpp.
Reimplemented in jami::ArchiveAccountManager.
Definition at line 131 of file account_manager.h.
dht::crypto::Identity jami::AccountManager::loadIdentity | ( | const std::string & | crt_path, |
const std::string & | key_path, | ||
const std::string & | key_pwd | ||
) | const |
Definition at line 113 of file account_manager.cpp.
References JAMI_DEBUG, and JAMI_ERROR.
|
virtual |
Definition at line 850 of file account_manager.cpp.
|
virtual |
Definition at line 842 of file account_manager.cpp.
bool jami::AccountManager::onPeerCertificate | ( | const std::shared_ptr< dht::crypto::Certificate > & | crt, |
bool | allowPublic, | ||
dht::InfoHash & | account_id | ||
) |
Definition at line 466 of file account_manager.cpp.
References JAMI_WARNING.
void jami::AccountManager::onPeerMessage | ( | const dht::crypto::PublicKey & | peer_device, |
bool | allowPublic, | ||
PeerCertificateCb && | cb | ||
) |
Definition at line 443 of file account_manager.cpp.
References JAMI_WARNING.
|
virtual |
Definition at line 59 of file account_manager.cpp.
References accountId_, jami::emitSignal(), findCertificate(), info_, and JAMI_DEBUG.
|
static |
Definition at line 152 of file account_manager.cpp.
References jami::DeviceAnnouncement::dev, JAMI_ERROR, and jami::DeviceAnnouncement::pk.
Referenced by jami::ServerAccountManager::initAuthentication().
|
pure virtual |
Implemented in jami::ServerAccountManager.
void jami::AccountManager::reloadContacts | ( | ) |
Definition at line 269 of file account_manager.cpp.
Definition at line 502 of file account_manager.cpp.
References JAMI_ERROR.
Definition at line 518 of file account_manager.cpp.
References JAMI_ERROR.
|
inlinevirtual |
Reimplemented in jami::ServerAccountManager, and jami::ArchiveAccountManager.
Definition at line 184 of file account_manager.h.
|
inlinevirtual |
Reimplemented in jami::ServerAccountManager.
Definition at line 287 of file account_manager.h.
void jami::AccountManager::sendTrustRequest | ( | const std::string & | to, |
const std::string & | convId, | ||
const std::vector< uint8_t > & | payload | ||
) |
Definition at line 718 of file account_manager.cpp.
References JAMI_ERROR, and JAMI_WARNING.
void jami::AccountManager::sendTrustRequestConfirm | ( | const dht::InfoHash & | to, |
const std::string & | conversationId | ||
) |
Definition at line 754 of file account_manager.cpp.
References JAMI_WARNING.
Definition at line 387 of file account_manager.cpp.
bool jami::AccountManager::setCertificateStatus | ( | const std::shared_ptr< crypto::Certificate > & | cert, |
dhtnet::tls::TrustStore::PermissionStatus | status, | ||
bool | local = true |
||
) |
Definition at line 655 of file account_manager.cpp.
bool jami::AccountManager::setCertificateStatus | ( | const std::string & | cert_id, |
dhtnet::tls::TrustStore::PermissionStatus | status | ||
) |
Definition at line 648 of file account_manager.cpp.
Definition at line 144 of file account_manager.h.
References dht_.
|
virtual |
Reimplemented in jami::ArchiveAccountManager.
Definition at line 277 of file account_manager.cpp.
References JAMI_DEBUG.
Implemented in jami::ArchiveAccountManager, and jami::ServerAccountManager.
void jami::AccountManager::updateContactConversation | ( | const std::string & | uri, |
const std::string & | convId | ||
) |
Definition at line 534 of file account_manager.cpp.
References libjami::Account::TrustRequest::CONVERSATIONID, and JAMI_ERROR.
const AccountInfo * jami::AccountManager::useIdentity | ( | const dht::crypto::Identity & | id, |
const std::string & | receipt, | ||
const std::vector< uint8_t > & | receiptSignature, | ||
const std::string & | username, | ||
const OnChangeCallback & | onChange | ||
) |
Definition at line 185 of file account_manager.cpp.
References JAMI_ERROR, and JAMI_LOG.
|
protected |
Definition at line 297 of file account_manager.h.
Referenced by jami::ArchiveAccountManager::initAuthentication(), jami::ServerAccountManager::initAuthentication(), and onSyncData().
|
protected |
Definition at line 301 of file account_manager.h.
Referenced by setDht(), and ~AccountManager().
Definition at line 91 of file account_manager.h.
|
protected |
Definition at line 300 of file account_manager.h.
Referenced by getInfo(), and onSyncData().
|
protected |
Definition at line 302 of file account_manager.h.
|
protected |
Definition at line 299 of file account_manager.h.
Referenced by jami::ArchiveAccountManager::initAuthentication(), and jami::ServerAccountManager::initAuthentication().
|
protected |
Definition at line 298 of file account_manager.h.