Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/server/object.hpp> |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 6 | #include <xyz/openbmc_project/User/PrivilegeMapperEntry/server.hpp> |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
Ratan Gupta | 7b04c35 | 2019-04-12 21:46:29 +0530 | [diff] [blame] | 10 | namespace ldap |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 11 | { |
| 12 | |
| 13 | namespace Base = sdbusplus::xyz::openbmc_project; |
| 14 | using Entry = |
| 15 | sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry; |
| 16 | using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete; |
Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 17 | using Interfaces = sdbusplus::server::object_t<Entry, Delete>; |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 18 | |
Ratan Gupta | 7b04c35 | 2019-04-12 21:46:29 +0530 | [diff] [blame] | 19 | // Forward declaration for Config |
| 20 | class Config; |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 21 | |
| 22 | using Id = size_t; |
| 23 | |
| 24 | /** @class LDAPMapperEntry |
| 25 | * |
| 26 | * @brief This D-Bus object represents the privilege level for the LDAP group. |
| 27 | */ |
Ratan Gupta | 7b04c35 | 2019-04-12 21:46:29 +0530 | [diff] [blame] | 28 | class LDAPMapperEntry : public Interfaces |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 29 | { |
| 30 | public: |
| 31 | LDAPMapperEntry() = delete; |
| 32 | ~LDAPMapperEntry() = default; |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 33 | LDAPMapperEntry(const LDAPMapperEntry&) = delete; |
| 34 | LDAPMapperEntry& operator=(const LDAPMapperEntry&) = delete; |
Nan Zhou | f3fb77c | 2022-08-29 17:51:59 +0000 | [diff] [blame] | 35 | LDAPMapperEntry(LDAPMapperEntry&&) = delete; |
| 36 | LDAPMapperEntry& operator=(LDAPMapperEntry&&) = delete; |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 37 | |
| 38 | /** @brief Constructs LDAP privilege mapper entry object. |
| 39 | * |
| 40 | * @param[in] bus - sdbusplus handler |
| 41 | * @param[in] path - D-Bus path |
| 42 | * @param[in] filePath - serialization directory path |
| 43 | * @param[in] groupName - LDAP group name |
| 44 | * @param[in] privilege - the privilege for the group |
| 45 | * @param[in] parent - LDAP privilege mapper manager |
| 46 | */ |
Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 47 | LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path, |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 48 | const char* filePath, const std::string& groupName, |
| 49 | const std::string& privilege, Config& parent); |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 50 | |
| 51 | /** @brief Constructs LDAP privilege mapper entry object |
| 52 | * |
| 53 | * @param[in] bus - sdbusplus handler |
| 54 | * @param[in] path - D-Bus path |
| 55 | * @param[in] filePath - serialization directory path |
| 56 | * @param[in] parent - LDAP privilege mapper manager |
| 57 | */ |
Patrick Williams | b3ef4e1 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 58 | LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path, |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 59 | const char* filePath, Config& parent); |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 60 | |
| 61 | /** @brief Delete privilege mapper entry object |
| 62 | * |
| 63 | * This method deletes the privilege mapper entry. |
| 64 | */ |
| 65 | void delete_(void) override; |
| 66 | |
| 67 | /** @brief Update the group name of the mapper object |
| 68 | * |
| 69 | * @param[in] value - group name |
| 70 | * |
| 71 | * @return On success the updated group name |
| 72 | */ |
| 73 | std::string groupName(std::string value) override; |
| 74 | |
| 75 | /** @brief Update privilege associated with LDAP group |
| 76 | * |
| 77 | * @param[in] value - privilege level |
| 78 | * |
| 79 | * @return On success the updated privilege level |
| 80 | */ |
| 81 | std::string privilege(std::string value) override; |
| 82 | |
| 83 | using sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry:: |
| 84 | privilege; |
| 85 | |
| 86 | using sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry:: |
| 87 | groupName; |
| 88 | |
| 89 | private: |
| 90 | Id id; |
Patrick Williams | 9638afb | 2021-02-22 17:16:24 -0600 | [diff] [blame] | 91 | Config& manager; |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 92 | |
| 93 | /** @brief serialization directory path */ |
| 94 | std::string persistPath; |
| 95 | }; |
| 96 | |
Ratan Gupta | 7b04c35 | 2019-04-12 21:46:29 +0530 | [diff] [blame] | 97 | } // namespace ldap |
Ratan Gupta | fd761da | 2019-04-12 21:48:57 +0530 | [diff] [blame] | 98 | } // namespace phosphor |