entropic_identity.cpp

src/facade/entropic_identity.cpp

@file entropic_identity.cpp @brief C API implementation for identity management.

Owners: @tvanfossen

check_identity_mgr

static entropic_error_t check_identity_mgr(entropic_handle_t h)

Check handle prerequisites for identity manager APIs.

src/facade/entropic_identity.cpp:28

Source · 5 lines
static entropic_error_t check_identity_mgr(entropic_handle_t h) {
    if (!h) { return ENTROPIC_ERROR_INVALID_HANDLE; }
    if (!h->identity_manager) { return ENTROPIC_ERROR_INVALID_STATE; }
    return ENTROPIC_OK;
}
Activity · 5 steps
lines 29–29◇ if (!h)lines 29–29return ENTROPIC_ERROR_INVALID_HANDLE;lines 30–30◇ if (!h->identity_manager)lines 30–30return ENTROPIC_ERROR_INVALID_STATE;lines 31–31return ENTROPIC_OK;

Requirements

REQ-API-005

entropic_get_identity

ENTROPIC_EXPORT entropic_error_t entropic_get_identity(entropic_handle_t handle, char **identity_json)

Get an identity's config as JSON.

src/facade/entropic_identity.cpp:71

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE

Calls check_identity_mgr, obj

Source · 21 lines
entropic_get_identity(
    entropic_handle_t handle,
    char** identity_json) {

    auto rc = check_identity_mgr(handle);
    if (rc != ENTROPIC_OK || !identity_json) {
        return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
    }

    auto names = handle->identity_manager->list();
    auto* cfg = names.empty()
        ? nullptr : handle->identity_manager->get(names[0]);
    if (!cfg) { return ENTROPIC_ERROR_IDENTITY_NOT_FOUND; }

    auto j = facade_json::obj();
    j["name"] = cfg->name;
    j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
                   ? "static" : "dynamic";
    *identity_json = strdup(j.dump().c_str());
    return ENTROPIC_OK;
}
Activity · 12 steps
lines 75–75auto rc = check_identity_mgr(handle);lines 76–76◇ if (rc != ENTROPIC_OK || !identity_json)lines 77–77return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 80–80auto names = handle->identity_manager->list();lines 81–82auto* cfg = names.empty() ? nullptr : handle->identity_manager->get(names[0]);lines 83–83◇ if (!cfg)lines 83–83return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 85–85auto j = facade_json::obj();lines 86–86j["name"] = cfg->name;lines 87–88j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC) ? "static" : "dynamic";lines 89–89*identity_json = strdup(j.dump().c_str());lines 90–90return ENTROPIC_OK;
ENTROPIC_EXPORT entropic_error_t entropic_get_identity(entropic_handle_t handle, char **identity_json)

Get the current active identity as a JSON string.

src/facade/entropic_identity.cpp:71

Show on the map →

Called by SCENARIO, SCENARIO

Calls check_identity_mgr, get, list, obj

Source · 21 lines
entropic_get_identity(
    entropic_handle_t handle,
    char** identity_json) {

    auto rc = check_identity_mgr(handle);
    if (rc != ENTROPIC_OK || !identity_json) {
        return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
    }

    auto names = handle->identity_manager->list();
    auto* cfg = names.empty()
        ? nullptr : handle->identity_manager->get(names[0]);
    if (!cfg) { return ENTROPIC_ERROR_IDENTITY_NOT_FOUND; }

    auto j = facade_json::obj();
    j["name"] = cfg->name;
    j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
                   ? "static" : "dynamic";
    *identity_json = strdup(j.dump().c_str());
    return ENTROPIC_OK;
}
Activity · 12 steps
lines 75–75auto rc = check_identity_mgr(handle);lines 76–76◇ if (rc != ENTROPIC_OK || !identity_json)lines 77–77return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 80–80auto names = handle->identity_manager->list();lines 81–82auto* cfg = names.empty() ? nullptr : handle->identity_manager->get(names[0]);lines 83–83◇ if (!cfg)lines 83–83return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 85–85auto j = facade_json::obj();lines 86–86j["name"] = cfg->name;lines 87–88j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC) ? "static" : "dynamic";lines 89–89*identity_json = strdup(j.dump().c_str());lines 90–90return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-008 REQ-IDEN-002

entropic_load_identity

ENTROPIC_EXPORT entropic_error_t entropic_load_identity(entropic_handle_t handle, const char *identity_name)

Load an identity by name — verify it exists.

src/facade/entropic_identity.cpp:45

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE

Calls check_identity_mgr

Source · 13 lines
entropic_load_identity(
    entropic_handle_t handle,
    const char* identity_name) {

    auto rc = check_identity_mgr(handle);
    if (rc != ENTROPIC_OK || !identity_name) {
        return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
    }

    bool found = handle->identity_manager->has(identity_name);
    logger->info("load_identity: name='{}' found={}", identity_name, found);
    return found ? ENTROPIC_OK : ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
Activity · 6 steps
lines 49–49auto rc = check_identity_mgr(handle);lines 50–50◇ if (rc != ENTROPIC_OK || !identity_name)lines 51–51return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 54–54bool found = handle->identity_manager->has(identity_name);lines 55–55logger->info("load_identity: name='{}' found={}", identity_name, found);lines 56–56return found ? ENTROPIC_OK : ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
ENTROPIC_EXPORT entropic_error_t entropic_load_identity(entropic_handle_t handle, const char *identity_name)

Load an identity by name from the configuration.

src/facade/entropic_identity.cpp:45

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE

Calls check_identity_mgr, has

Source · 13 lines
entropic_load_identity(
    entropic_handle_t handle,
    const char* identity_name) {

    auto rc = check_identity_mgr(handle);
    if (rc != ENTROPIC_OK || !identity_name) {
        return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
    }

    bool found = handle->identity_manager->has(identity_name);
    logger->info("load_identity: name='{}' found={}", identity_name, found);
    return found ? ENTROPIC_OK : ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
Activity · 6 steps
lines 49–49auto rc = check_identity_mgr(handle);lines 50–50◇ if (rc != ENTROPIC_OK || !identity_name)lines 51–51return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 54–54bool found = handle->identity_manager->has(identity_name);lines 55–55logger->info("load_identity: name='{}' found={}", identity_name, found);lines 56–56return found ? ENTROPIC_OK : ENTROPIC_ERROR_IDENTITY_NOT_FOUND;

Requirements

REQ-API-005 REQ-IDEN-002