Create role mapping under ldap config object
Each ldap config object should be have its own
mapping object.
This is to align with the redfish.
https://redfish.dmtf.org/schemas/AccountService.v1_4_0.json
As per redfish, Each config will have it's own
"RemoteRoleMapping".
Mapping object should be persisted and restores
when the phosphor-ldap-conf restarts.
TestedBy:
Unit Tested.
Creation of privilege mapping.
Persist the priv-mapping.
Restores the priv-mapping.
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: I5ab4aeffae61f9cc57c1338f94784d0fe5607cd3
diff --git a/phosphor-ldap-config/ldap_mapper_entry.cpp b/phosphor-ldap-config/ldap_mapper_entry.cpp
index 8410942..09b0e0f 100644
--- a/phosphor-ldap-config/ldap_mapper_entry.cpp
+++ b/phosphor-ldap-config/ldap_mapper_entry.cpp
@@ -1,17 +1,17 @@
-#include <experimental/filesystem>
+#include <filesystem>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/Common/error.hpp>
#include <phosphor-logging/log.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include "config.h"
+#include "ldap_config.hpp"
#include "ldap_mapper_entry.hpp"
-#include "ldap_mapper_mgr.hpp"
#include "ldap_mapper_serialize.hpp"
namespace phosphor
{
-namespace user
+namespace ldap
{
using namespace phosphor::logging;
@@ -22,22 +22,21 @@
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
const char *filePath,
const std::string &groupName,
- const std::string &privilege,
- LDAPMapperMgr &parent) :
- Ifaces(bus, path, true),
- id(std::stol(std::experimental::filesystem::path(path).filename())),
- manager(parent), persistPath(filePath)
+ const std::string &privilege, Config &parent) :
+ Interfaces(bus, path, true),
+ id(std::stol(std::filesystem::path(path).filename())), manager(parent),
+ persistPath(filePath)
{
- Ifaces::privilege(privilege, true);
- Ifaces::groupName(groupName, true);
- Ifaces::emit_object_added();
+ Interfaces::privilege(privilege, true);
+ Interfaces::groupName(groupName, true);
+ Interfaces::emit_object_added();
}
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
- const char *filePath, LDAPMapperMgr &parent) :
- Ifaces(bus, path, true),
- id(std::stol(std::experimental::filesystem::path(path).filename())),
- manager(parent), persistPath(filePath)
+ const char *filePath, Config &parent) :
+ Interfaces(bus, path, true),
+ id(std::stol(std::filesystem::path(path).filename())), manager(parent),
+ persistPath(filePath)
{
}
@@ -48,29 +47,29 @@
std::string LDAPMapperEntry::groupName(std::string value)
{
- if (value == Ifaces::groupName())
+ if (value == Interfaces::groupName())
{
return value;
}
manager.checkPrivilegeMapper(value);
- auto val = Ifaces::groupName(value);
- serialize(*this, id, persistPath);
+ auto val = Interfaces::groupName(value);
+ serialize(*this, persistPath);
return val;
}
std::string LDAPMapperEntry::privilege(std::string value)
{
- if (value == Ifaces::privilege())
+ if (value == Interfaces::privilege())
{
return value;
}
manager.checkPrivilegeLevel(value);
- auto val = Ifaces::privilege(value);
- serialize(*this, id, persistPath);
+ auto val = Interfaces::privilege(value);
+ serialize(*this, persistPath);
return val;
}
-} // namespace user
+} // namespace ldap
} // namespace phosphor