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
Requirements
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
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
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
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
Requirements
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
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
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
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;
}