summaryrefslogtreecommitdiffstats
path: root/phosphor-ldap-mapper/ldap_mapper_entry.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2018-09-14 10:02:20 +0530
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-10-04 14:27:10 -0400
commit536ea32ddc61bc3f5ad34eada5788797e1771832 (patch)
tree184aa6f39ef50147245bed65254d614403998673 /phosphor-ldap-mapper/ldap_mapper_entry.cpp
parent3618f443ceae49bbcbfd7d35563c23f876ca5d79 (diff)
downloadphosphor-user-manager-536ea32ddc61bc3f5ad34eada5788797e1771832.tar.gz
phosphor-user-manager-536ea32ddc61bc3f5ad34eada5788797e1771832.zip
ldap: Add application to configure privilege for LDAP groups
The application implements the xyz.openbmc_project.User.PrivilegeMapper D-Bus interface to configure privilege levels for LDAP groups. The Create method is used to create privilege mapping for the LDAP group. D-Bus object is created for each LDAP group and implements the D-Bus interface xyz.openbmc_project.User.PrivilegeMapperEntry. : Change-Id: I20935229a8a79ce1e52a857672a6a0085cb5ace4 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'phosphor-ldap-mapper/ldap_mapper_entry.cpp')
-rw-r--r--phosphor-ldap-mapper/ldap_mapper_entry.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/phosphor-ldap-mapper/ldap_mapper_entry.cpp b/phosphor-ldap-mapper/ldap_mapper_entry.cpp
new file mode 100644
index 0000000..64d3578
--- /dev/null
+++ b/phosphor-ldap-mapper/ldap_mapper_entry.cpp
@@ -0,0 +1,62 @@
+#include <experimental/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_mapper_entry.hpp"
+#include "ldap_mapper_mgr.hpp"
+
+namespace phosphor
+{
+namespace user
+{
+
+using namespace phosphor::logging;
+using InvalidArgument =
+ sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
+using Argument = xyz::openbmc_project::Common::InvalidArgument;
+
+LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
+ 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)
+{
+ Ifaces::privilege(privilege, true);
+ Ifaces::groupName(groupName, true);
+ Ifaces::emit_object_added();
+}
+
+void LDAPMapperEntry::delete_(void)
+{
+ manager.deletePrivilegeMapper(id);
+}
+
+std::string LDAPMapperEntry::groupName(std::string value)
+{
+ if (value == Ifaces::groupName())
+ {
+ return value;
+ }
+
+ manager.checkPrivilegeMapper(value);
+ return Ifaces::groupName(value);
+}
+
+std::string LDAPMapperEntry::privilege(std::string value)
+{
+ if (value == Ifaces::privilege())
+ {
+ return value;
+ }
+
+ manager.checkPrivilegeLevel(value);
+ return Ifaces::privilege(value);
+}
+
+} // namespace user
+} // namespace phosphor
OpenPOWER on IntegriCloud