summaryrefslogtreecommitdiffstats
path: root/phosphor-ldap-mapper/ldap_mapper_entry.hpp
blob: dea85c210b1eddbf74586c52c328c9fc950d3ee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once

#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <xyz/openbmc_project/User/PrivilegeMapperEntry/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>

namespace phosphor
{
namespace user
{

namespace Base = sdbusplus::xyz::openbmc_project;
using Entry =
    sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry;
using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
using Ifaces = sdbusplus::server::object::object<Entry, Delete>;

// Forward declaration for LDAPMapperMgr
class LDAPMapperMgr;

using Id = size_t;

/** @class LDAPMapperEntry
 *
 *  @brief This D-Bus object represents the privilege level for the LDAP group.
 */
class LDAPMapperEntry : public Ifaces
{
  public:
    LDAPMapperEntry() = delete;
    ~LDAPMapperEntry() = default;
    LDAPMapperEntry(const LDAPMapperEntry &) = delete;
    LDAPMapperEntry &operator=(const LDAPMapperEntry &) = delete;
    LDAPMapperEntry(LDAPMapperEntry &&) = default;
    LDAPMapperEntry &operator=(LDAPMapperEntry &&) = default;

    /** @brief Constructs LDAP privilege mapper entry object.
     *
     *  @param[in] bus  - sdbusplus handler
     *  @param[in] path - D-Bus path
     *  @param[in] filePath - serialization directory path
     *  @param[in] groupName - LDAP group name
     *  @param[in] privilege - the privilege for the group
     *  @param[in] parent - LDAP privilege mapper manager
     */
    LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
                    const char *filePath, const std::string &groupName,
                    const std::string &privilege, LDAPMapperMgr &parent);

    /** @brief Constructs LDAP privilege mapper entry object
     *
     *  @param[in] bus  - sdbusplus handler
     *  @param[in] path - D-Bus path
     *  @param[in] filePath - serialization directory path
     *  @param[in] parent - LDAP privilege mapper manager
     */
    LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
                    const char *filePath, LDAPMapperMgr &parent);

    /** @brief Delete privilege mapper entry object
     *
     *  This method deletes the privilege mapper entry.
     */
    void delete_(void) override;

    /** @brief Update the group name of the mapper object
     *
     *  @param[in] value - group name
     *
     *  @return On success the updated group name
     */
    std::string groupName(std::string value) override;

    /** @brief Update privilege associated with LDAP group
     *
     *  @param[in] value - privilege level
     *
     *  @return On success the updated privilege level
     */
    std::string privilege(std::string value) override;

    using sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry::
        privilege;

    using sdbusplus::xyz::openbmc_project::User::server::PrivilegeMapperEntry::
        groupName;

  private:
    Id id;
    LDAPMapperMgr &manager;

    /** @brief serialization directory path */
    std::string persistPath;
};

} // namespace user
} // namespace phosphor
OpenPOWER on IntegriCloud