blob: bb45aa39b3b3b5fc3ca8be67ff9e381c52761b01 [file] [log] [blame]
Tom Joseph536ea322018-09-14 10:02:20 +05301#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
Tom Joseph536ea322018-09-14 10:02:20 +05305#include <xyz/openbmc_project/Object/Delete/server.hpp>
Patrick Williams9638afb2021-02-22 17:16:24 -06006#include <xyz/openbmc_project/User/PrivilegeMapperEntry/server.hpp>
Tom Joseph536ea322018-09-14 10:02:20 +05307
8namespace phosphor
9{
10namespace user
11{
12
13namespace Base = sdbusplus::xyz::openbmc_project;
14using Entry =
15 sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry;
16using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
17using Ifaces = sdbusplus::server::object::object<Entry, Delete>;
18
19// Forward declaration for LDAPMapperMgr
20class LDAPMapperMgr;
21
22using Id = size_t;
23
24/** @class LDAPMapperEntry
25 *
26 * @brief This D-Bus object represents the privilege level for the LDAP group.
27 */
28class LDAPMapperEntry : public Ifaces
29{
30 public:
31 LDAPMapperEntry() = delete;
32 ~LDAPMapperEntry() = default;
Patrick Williams9638afb2021-02-22 17:16:24 -060033 LDAPMapperEntry(const LDAPMapperEntry&) = delete;
34 LDAPMapperEntry& operator=(const LDAPMapperEntry&) = delete;
35 LDAPMapperEntry(LDAPMapperEntry&&) = default;
36 LDAPMapperEntry& operator=(LDAPMapperEntry&&) = default;
Tom Joseph536ea322018-09-14 10:02:20 +053037
38 /** @brief Constructs LDAP privilege mapper entry object.
39 *
40 * @param[in] bus - sdbusplus handler
41 * @param[in] path - D-Bus path
Tom Josephf5bd8912018-11-19 09:49:21 +053042 * @param[in] filePath - serialization directory path
43 * @param[in] groupName - LDAP group name
Tom Joseph536ea322018-09-14 10:02:20 +053044 * @param[in] privilege - the privilege for the group
45 * @param[in] parent - LDAP privilege mapper manager
46 */
Patrick Williams9638afb2021-02-22 17:16:24 -060047 LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
48 const char* filePath, const std::string& groupName,
49 const std::string& privilege, LDAPMapperMgr& parent);
Tom Joseph536ea322018-09-14 10:02:20 +053050
Tom Joseph0b14c472018-09-30 01:42:59 +053051 /** @brief Constructs LDAP privilege mapper entry object
52 *
53 * @param[in] bus - sdbusplus handler
54 * @param[in] path - D-Bus path
Tom Josephf5bd8912018-11-19 09:49:21 +053055 * @param[in] filePath - serialization directory path
Tom Joseph0b14c472018-09-30 01:42:59 +053056 * @param[in] parent - LDAP privilege mapper manager
57 */
Patrick Williams9638afb2021-02-22 17:16:24 -060058 LDAPMapperEntry(sdbusplus::bus::bus& bus, const char* path,
59 const char* filePath, LDAPMapperMgr& parent);
Tom Joseph0b14c472018-09-30 01:42:59 +053060
Tom Joseph536ea322018-09-14 10:02:20 +053061 /** @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 Williams9638afb2021-02-22 17:16:24 -060091 LDAPMapperMgr& manager;
Tom Josephf5bd8912018-11-19 09:49:21 +053092
93 /** @brief serialization directory path */
94 std::string persistPath;
Tom Joseph536ea322018-09-14 10:02:20 +053095};
96
97} // namespace user
98} // namespace phosphor