Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::ArchiveAccountManager Class Reference

#include <archive_account_manager.h>

Inheritance diagram for jami::ArchiveAccountManager:
Inheritance graph
Collaboration diagram for jami::ArchiveAccountManager:
Collaboration graph

Classes

struct  AddDeviceContext
 
struct  ArchiveAccountCredentials
 
struct  AuthMsg
 
struct  DecodingContext
 
struct  DeviceAuthInfo
 
struct  DeviceContextBase
 
struct  DhtLoadContext
 
struct  LinkDeviceContext
 

Public Types

using OnExportConfig = std::function< std::map< std::string, std::string >()>
 
- Public Types inherited from jami::AccountManager
enum class  AddDeviceError { INVALID_URI = -1 , ALREADY_LINKING = -2 , GENERIC = -3 }
 
enum class  AuthError { UNKNOWN , INVALID_ARGUMENTS , SERVER_ERROR , NETWORK }
 
using AuthFailureCallback = std::function< void(AuthError error, const std::string &message)>
 
using AuthSuccessCallback = std::function< void(const AccountInfo &info, const std::map< std::string, std::string > &config, std::string &&receipt, std::vector< uint8_t > &&receipt_signature)>
 
using CertRequest = std::future< std::unique_ptr< dht::crypto::CertificateRequest > >
 
using clock = std::chrono::system_clock
 
using DeviceSyncCallback = std::function< void(DeviceSync &&syncData)>
 
using LookupCallback = NameDirectory::LookupCallback
 
using OnChangeCallback = ContactList::OnChangeCallback
 
using OnDeviceAnnouncedCb = std::function< void()>
 
using OnNewDeviceCb = std::function< void(const std::shared_ptr< dht::crypto::Certificate > &)>
 
using PeerCertificateCb = std::function< void(const std::shared_ptr< dht::crypto::Certificate > &crt, const dht::InfoHash &peer_account)>
 
using PrivateKey = std::shared_future< std::shared_ptr< dht::crypto::PrivateKey > >
 
using RegistrationCallback = NameDirectory::RegistrationCallback
 
using RevokeDeviceCallback = std::function< void(RevokeDeviceResult)>
 
enum class  RevokeDeviceResult { SUCCESS = 0 , ERROR_CREDENTIALS , ERROR_NETWORK }
 
using SearchCallback = NameDirectory::SearchCallback
 
using SearchResponse = NameDirectory::Response
 
using SearchResult = NameDirectory::SearchResult
 
using time_point = clock::time_point
 

Public Member Functions

int32_t addDevice (const std::string &uri, std::string_view auth_scheme, AuthChannelHandler *) override
 Initiates the process of adding a new device to the account.
 
 ArchiveAccountManager (const std::string &accountId, const std::filesystem::path &path, OnExportConfig &&onExportConfig, std::string archivePath, const std::string &nameServer)
 
bool cancelAddDevice (uint32_t token) override
 
bool changePassword (const std::string &password_old, const std::string &password_new) override
 
bool confirmAddDevice (uint32_t token) override
 
bool exportArchive (const std::string &destinationPath, std::string_view scheme, const std::string &password)
 
virtual std::vector< uint8_tgetPasswordKey (const std::string &) override
 
void initAuthentication (PrivateKey request, std::string deviceName, std::unique_ptr< AccountCredentials > credentials, AuthSuccessCallback onSuccess, AuthFailureCallback onFailure, const OnChangeCallback &onChange) override
 
bool isPasswordValid (const std::string &password) override
 
void onAuthReady (const std::string &deviceId, std::shared_ptr< dhtnet::ChannelSocket > channel)
 
bool provideAccountAuthentication (const std::string &credentialsFromUser, const std::string &scheme)
 
bool revokeDevice (const std::string &device, std::string_view scheme, const std::string &password, RevokeDeviceCallback) override
 
bool setValidity (std::string_view scheme, const std::string &password, dht::crypto::Identity &device, const dht::InfoHash &id, int64_t validity)
 Change the validity of a certificate.
 
void startSync (const OnNewDeviceCb &, const OnDeviceAnnouncedCb &dcb={}, bool publishPresence=true) override
 
void syncDevices () override
 
- Public Member Functions inherited from jami::AccountManager
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.
 
CertRequest buildRequest (PrivateKey fDeviceKey)
 
dhtnet::tls::CertificateStore & certStore () const
 
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< ContactgetContactInfo (const std::string &uri) const
 
std::vector< std::map< std::string, std::string > > getContacts (bool includeRemoved=false) const
 
const AccountInfogetInfo () const
 
const std::map< dht::PkId, KnownDevice > & getKnownDevices () const
 
std::vector< std::map< std::string, std::string > > getTrustRequests () const
 
bool isAllowed (const crypto::Certificate &crt, bool allowPublic=false)
 
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 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)
 
void updateContactConversation (const std::string &uri, const std::string &convId)
 
const AccountInfouseIdentity (const dht::crypto::Identity &id, const std::string &receipt, const std::vector< uint8_t > &receiptSignature, const std::string &username, const OnChangeCallback &onChange)
 
virtual ~AccountManager ()
 

Additional Inherited Members

- Static Public Member Functions inherited from jami::AccountManager
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 inherited from jami::AccountManager
static constexpr const char *const DHT_TYPE_NS = "cx.ring"
 
- Protected Attributes inherited from jami::AccountManager
const std::string accountId_
 
std::shared_ptr< dht::DhtRunner > dht_
 
std::unique_ptr< AccountInfoinfo_
 
std::reference_wrapper< NameDirectorynameDir_
 
OnChangeCallback onChange_
 
const std::filesystem::path path_
 

Detailed Description

Definition at line 37 of file archive_account_manager.h.

Member Typedef Documentation

◆ OnExportConfig

using jami::ArchiveAccountManager::OnExportConfig = std::function<std::map<std::string, std::string>()>

Definition at line 40 of file archive_account_manager.h.

Constructor & Destructor Documentation

◆ ArchiveAccountManager()

jami::ArchiveAccountManager::ArchiveAccountManager ( const std::string &  accountId,
const std::filesystem::path &  path,
OnExportConfig &&  onExportConfig,
std::string  archivePath,
const std::string &  nameServer 
)
inline

Definition at line 42 of file archive_account_manager.h.

Member Function Documentation

◆ addDevice()

int32_t jami::ArchiveAccountManager::addDevice ( const std::string &  ,
std::string_view  ,
AuthChannelHandler  
)
overridevirtual

Initiates the process of adding a new device to the account.

Parameters
uriThe URI provided by the new device to be added
auth_schemeThe auth scheme (currently only "password" is expected)
chanel
Returns
A positive operation ID if successful, or a negative value indicating an AddDeviceError:
  • INVALID_URI (-1): The provided URI is invalid
  • ALREADY_LINKING (-2): A device linking operation is already in progress
  • GENERIC (-3): A generic error occurred during the process

Reimplemented from jami::AccountManager.

Definition at line 896 of file archive_account_manager.cpp.

References jami::AUTH_URI_SCHEME, jami::CHANNEL_SCHEME, jami::AuthChannelHandler::connect(), JAMI_ERROR, JAMI_LOG, and JAMI_WARNING.

Here is the call graph for this function:

◆ cancelAddDevice()

bool jami::ArchiveAccountManager::cancelAddDevice ( uint32_t  token)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1189 of file archive_account_manager.cpp.

◆ changePassword()

bool jami::ArchiveAccountManager::changePassword ( const std::string &  password_old,
const std::string &  password_new 
)
overridevirtual

Implements jami::AccountManager.

Definition at line 1655 of file archive_account_manager.cpp.

References jami::AccountArchive::save().

Here is the call graph for this function:

◆ confirmAddDevice()

bool jami::ArchiveAccountManager::confirmAddDevice ( uint32_t  token)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1219 of file archive_account_manager.cpp.

References JAMI_DEBUG, and jami::ArchiveAccountManager::AuthMsg::set().

Here is the call graph for this function:

◆ exportArchive()

bool jami::ArchiveAccountManager::exportArchive ( const std::string &  destinationPath,
std::string_view  scheme,
const std::string &  password 
)

Definition at line 1737 of file archive_account_manager.cpp.

References JAMI_ERR, and jami::AccountArchive::save().

Here is the call graph for this function:

◆ getPasswordKey()

std::vector< uint8_t > jami::ArchiveAccountManager::getPasswordKey ( const std::string &  password)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1669 of file archive_account_manager.cpp.

References JAMI_ERROR.

◆ initAuthentication()

void jami::ArchiveAccountManager::initAuthentication ( PrivateKey  request,
std::string  deviceName,
std::unique_ptr< AccountCredentials credentials,
AuthSuccessCallback  onSuccess,
AuthFailureCallback  onFailure,
const OnChangeCallback onChange 
)
overridevirtual

◆ isPasswordValid()

bool jami::ArchiveAccountManager::isPasswordValid ( const std::string &  password)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1766 of file archive_account_manager.cpp.

◆ onAuthReady()

void jami::ArchiveAccountManager::onAuthReady ( const std::string &  deviceId,
std::shared_ptr< dhtnet::ChannelSocket >  channel 
)

◆ provideAccountAuthentication()

bool jami::ArchiveAccountManager::provideAccountAuthentication ( const std::string &  credentialsFromUser,
const std::string &  scheme 
)

Definition at line 523 of file archive_account_manager.cpp.

References JAMI_ERROR, JAMI_WARNING, jami::ArchiveAccountManager::AuthMsg::logMsg(), and jami::ArchiveAccountManager::AuthMsg::set().

Here is the call graph for this function:

◆ revokeDevice()

bool jami::ArchiveAccountManager::revokeDevice ( const std::string &  device,
std::string_view  scheme,
const std::string &  password,
RevokeDeviceCallback  cb 
)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1684 of file archive_account_manager.cpp.

References jami::AccountArchive::id, and jami::AccountArchive::revoked.

◆ setValidity()

bool jami::ArchiveAccountManager::setValidity ( std::string_view  scheme,
const std::string &  password,
dht::crypto::Identity &  device,
const dht::InfoHash &  id,
int64_t  validity 
)

Change the validity of a certificate.

If hash is empty, update all certificates

Definition at line 176 of file archive_account_manager.cpp.

References JAMI_LOG, and JAMI_WARNING.

◆ startSync()

void jami::ArchiveAccountManager::startSync ( const OnNewDeviceCb cb,
const OnDeviceAnnouncedCb dcb = {},
bool  publishPresence = true 
)
overridevirtual

Reimplemented from jami::AccountManager.

Definition at line 1552 of file archive_account_manager.cpp.

◆ syncDevices()

void jami::ArchiveAccountManager::syncDevices ( )
overridevirtual

Implements jami::AccountManager.

Definition at line 1523 of file archive_account_manager.cpp.

References JAMI_LOG, and JAMI_WARNING.


The documentation for this class was generated from the following files: