Tom Joseph | 536ea32 | 2018-09-14 10:02:20 +0530 | [diff] [blame^] | 1 | #include <experimental/filesystem> |
| 2 | #include <xyz/openbmc_project/Common/error.hpp> |
| 3 | #include <xyz/openbmc_project/User/Common/error.hpp> |
| 4 | #include <phosphor-logging/log.hpp> |
| 5 | #include <phosphor-logging/elog.hpp> |
| 6 | #include <phosphor-logging/elog-errors.hpp> |
| 7 | #include "config.h" |
| 8 | #include "ldap_mapper_entry.hpp" |
| 9 | #include "ldap_mapper_mgr.hpp" |
| 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace user |
| 14 | { |
| 15 | |
| 16 | using namespace phosphor::logging; |
| 17 | using InvalidArgument = |
| 18 | sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument; |
| 19 | using Argument = xyz::openbmc_project::Common::InvalidArgument; |
| 20 | |
| 21 | LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path, |
| 22 | const std::string &groupName, |
| 23 | const std::string &privilege, |
| 24 | LDAPMapperMgr &parent) : |
| 25 | Ifaces(bus, path, true), |
| 26 | id(std::stol(std::experimental::filesystem::path(path).filename())), |
| 27 | manager(parent) |
| 28 | { |
| 29 | Ifaces::privilege(privilege, true); |
| 30 | Ifaces::groupName(groupName, true); |
| 31 | Ifaces::emit_object_added(); |
| 32 | } |
| 33 | |
| 34 | void LDAPMapperEntry::delete_(void) |
| 35 | { |
| 36 | manager.deletePrivilegeMapper(id); |
| 37 | } |
| 38 | |
| 39 | std::string LDAPMapperEntry::groupName(std::string value) |
| 40 | { |
| 41 | if (value == Ifaces::groupName()) |
| 42 | { |
| 43 | return value; |
| 44 | } |
| 45 | |
| 46 | manager.checkPrivilegeMapper(value); |
| 47 | return Ifaces::groupName(value); |
| 48 | } |
| 49 | |
| 50 | std::string LDAPMapperEntry::privilege(std::string value) |
| 51 | { |
| 52 | if (value == Ifaces::privilege()) |
| 53 | { |
| 54 | return value; |
| 55 | } |
| 56 | |
| 57 | manager.checkPrivilegeLevel(value); |
| 58 | return Ifaces::privilege(value); |
| 59 | } |
| 60 | |
| 61 | } // namespace user |
| 62 | } // namespace phosphor |