Fiókkezelő

Ebben a részben megtudhatja, hogyan kezelheti a Jami-fiókot: hogyan hozhat létre fiókot, hogyan módosíthatja annak alapbeállításait, és hogyan törölhet egy fiókot. Ez a rész nem tárgyalja az egyes beállítások jelentését, illetve a fiók használatát olyan műveletek végrehajtásához, mint például a kapcsolattartók hozzáadása.

Mi a fiók?

A Jamiban egy fiókot egy X.509 tanúsítványlánc képvisel, amely három tanúsítványból áll:

  1. CA: Önaláírt tanúsítvány, ha helyben hozták létre, vagy egy cég állította ki.

  2. Fiók: Tartalmazza a nyilvános kulcsot, amelynek ujjlenyomata a Jami ID.

  3. Eszköz: A fiókhoz társítva.

Megjegyzés

Ez a struktúra lehetővé teszi a vállalatok számára, hogy szükség esetén egy teljes fiókot vonjanak vissza, és a fiók tulajdonosa egyes eszközöket is visszavonhat (például, ha egy eszközt ellopnak).

Új fiók létrehozása

Új fiók—rendszerfolyamat-API

A ConfigurationManager-API (cx.ring.Ring.ConfigurationManager) biztosítja az addAccount metódust:

<method name="addAccount" tp:name-for-bindings="addAccount">
    <tp:docstring>
        Add a new account. When created, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure.
        <tp:rationale>If no details are specified, the default parameters are used.</tp:rationale>
        <tp:rationale>The core tries to register the account as soon it is created.</tp:rationale>
    </tp:docstring>
    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="MapStringString"/>
    <arg type="a{ss}" name="details" direction="in"  tp:type="String_String_Map">
        <tp:docstring>
             The new account settings
        </tp:docstring>
    </arg>
    <arg type="s" name="createdAccountId" direction="out">
        <tp:docstring>
             A new account ID
        </tp:docstring>
    </arg>
</method>

Új fiók—alapvető végrehajtás

A fióklétrehozás alapvető logikája a src/account_factory.cpp fájlban található, az AccountFactory::createAccount metóduson belül.

std::shared_ptr<Account>
AccountFactory::createAccount(std::string_view accountType, const std::string& id)
{
    if (hasAccount(id)) {
        JAMI_ERROR("Existing account {}", id);
        return nullptr;
    }

    const auto& it = generators_.find(accountType);
    if (it == generators_.cend())
        return {};

    std::shared_ptr<Account> account = it->second(id);
    {
        std::lock_guard lock(mutex_);
        auto m = accountMaps_.find(accountType);
        if (m == accountMaps_.end())
            m = accountMaps_.emplace(std::string(accountType), AccountMap<Account>{}).first;
        m->second.emplace(id, account);
    }
    return account;
}

Az addAccount (vagy a createAccount az AccountFactory-n keresztül) meghívása után az accountsChanged jel kerül kibocsátásra. Az ügyfeleknek kezelniük kell ezt a jelet, és meg kell hívniuk a „getAccountList” parancsot a helyi állapotuk frissítéséhez.

Belső archívumformátum

Fiók létrehozásakor az adatai egy gzip-archívumban tárolódnak. Jelszó megadása esetén az archívum AES titkosítással kerül mentésre: dht::crypto::aesEncrypt(archívum, jelszó) (a dht::crypto::aesEncrypt OpenDHT-ben van definiálva és nettle/{aes,gcm}-t használ). Az archívumban egy JSON-fájl található, amely a következőket tartalmazza:

  1. A ringAccountKey privát kulcs és a ringAccountCert tanúsítványlánc, base64 kódolásban.

  2. A létrehozott CA kulcs: ringCAKey.

  3. A ringAccountCRL eszközök tanúsítvány-visszavonási listája.

  4. A kapcsolattartók listája.

  5. A számla beállításai

Fiók törlése

Egy Jami-fiók törlése egyszerű: mivel az összes kulcsfontosságú anyag a helyi eszközön található, a kulcsfájlok eltávolítása gyakorlatilag törli a fiókot. Az egyetlen külső bejegyzés a fiók felhasználóneve a névkiszolgálón, amely a kiszolgáló szabályzatától függően megmaradhat (például a https://ns.jami.net jelenleg nem támogatja a távoli névtörlést).

Fiók törlése—rendszerfolyamat-API

A ConfigurationManager-API biztosítja a removeAccount metódust:

<method name="removeAccount" tp:name-for-bindings="removeAccount">
    <tp:docstring>
        Remove an existing account. When removed, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure.
    </tp:docstring>
    <arg type="s" name="accoundID" direction="in">
        <tp:docstring>
             The account to remove, identified by its ID
        </tp:docstring>
    </arg>
</method>

A felhasználó a rendszerben a következő funkciókat alkalmazza:

Fiók törlése—alapvető végrehajtás

Az eltávolítási logika a src/accout_factory.cpp (AccountFactory::removeAccount) fájlban található, amely törli a fiókfájlokat és frissíti a dring.yml beállítást.

void
AccountFactory::removeAccount(Account& account)
{
    std::string_view account_type = account.getAccountType();
    std::lock_guard lock(mutex_);
    const auto& id = account.getAccountID();
    JAMI_DEBUG("Removing account {:s}", id);
    auto m = accountMaps_.find(account_type);
    if (m != accountMaps_.end()) {
        m->second.erase(id);
        JAMI_DEBUG("Remaining {:d} {:s} account(s)", m->second.size(), account_type);
    }
}

Fiókadatok frissítése

Fiók frissítése—rendszerfolyamat-API

A ConfigurationManager-API biztosítja a setAccountDetails metódust:

<method name="setAccountDetails" tp:name-for-bindings="setAccountDetails">
    <tp:docstring>
        Send new account parameters, or account parameters changes, to the core. The hash table is not required to be complete, only the updated parameters may be specified.
        <tp:rationale>Account settings are written to the configuration file when the app properly quits.</tp:rationale>
        <tp:rationale>After calling this method, the core will emit the signal <tp:member-ref>accountDetailsChanged</tp:member-ref> with the updated data. The client must subscribe to this signal and use it to update its internal data structure.</tp:rationale>
    </tp:docstring>
    <arg type="s" name="accountID" direction="in">
    </arg>
    <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="MapStringString"/>
    <arg type="a{ss}" name="details" direction="in" tp:type="String_String_Map">
    </arg>
</method>

A térkép tartalmazhat részleges frissítést, és siker esetén az accountDetailsChanged üzenet jelenik meg. getAccountDetails

Eszközök kezelése

Eszköz hozzáadása

Kétféleképpen adhat hozzá eszközt egy meglévő fiókhoz.

1. Restore from Backup Archive

Az exportToFile paranccsal csomagold ki a fiók archívumát egy helyi elérési útra:

<method name="exportToFile" tp:name-for-bindings="exportToFile">
    <tp:added version="5.1.0"/>
    <tp:docstring>
        Copy the account archive to the path provided in argument.
    </tp:docstring>
    <arg type="s" name="accountID" direction="in">
    </arg>
    <arg type="s" name="destinationPath" direction="in">
    </arg>
    <arg type="s" name="password" direction="in">
    </arg>
    <arg type="b" name="success" direction="out">
        <tp:docstring>
            True if the operation was initialized successfully.
        </tp:docstring>
    </arg>
</method>

2. Export on the DHT network

Az exportOnRing paranccsal publikálhatod a titkosított archívumot a DHT-hálózaton, és PIN-kódot kaphatsz:

<method name="exportOnRing" tp:name-for-bindings="exportOnRing">
    <tp:docstring>
        Export account on the DHT using the given password and generated PIN (returned through exportOnRingEnded signal).
    </tp:docstring>
    <arg type="s" name="accountID" direction="in">
    </arg>
    <arg type="s" name="password" direction="in">
    </arg>
    <arg type="b" name="success" direction="out">
        <tp:docstring>
            True if the operation was initialized successfully. exportOnRingEnded will be trigered on completion.
        </tp:docstring>
    </arg>
</method>

Ezután az exportOnRingEnded utasítás kerül kibocsátásra. A ügyfeleknek figyelniük kell a jelre a PIN-kód lekéréséhez.

Revoke a device

To revoke a device, call revokeDevice:

<method name="revokeDevice" tp:name-for-bindings="revokeDevice">
    <tp:docstring>
        Revoke device attached to the given Jami account, and publish the new revocation list.
    </tp:docstring>
    <arg type="s" name="accountID" direction="in">
    </arg>
    <arg type="s" name="password" direction="in">
    </arg>
    <arg type="s" name="deviceId" direction="in">
    </arg>
    <arg type="b" name="success" direction="out">
        <tp:docstring>
            True if the operation was performed successfully.
        </tp:docstring>
    </arg>
</method>
<signal name="deviceRevocationEnded" tp:name-for-bindings="deviceRevocationEnded">
    <tp:docstring>
        Notify clients when the revokeDevice operation ended.
    </tp:docstring>
    <arg type="s" name="accountID">
    </arg>
    <arg type="s" name="deviceId">
    </arg>
    <arg type="i" name="status">
        <tp:docstring>
            Status code: 0 for success
            <ul>
                <li>SUCCESS = 0         everything went fine. Device is now revoked.</li>
                <li>WRONG_PASSWORD = 1  revocation failed: wrong password.</li>
                <li>UNKNOWN_DEVICE = 2  revocation failed: unknown device.</li>
            </ul>
        </tp:docstring>
    </arg>
</signal>

Upon completion, the deviceRevocationEnded signal is emitted with a status code:

  • 0 (SUCCESS)

  • 1 (WRONG_PASSWORD)

  • 2 (UNKNOWN_DEVICE)

Clients should handle this signal to confirm the revocation status.