blob: 64d357871967b5f9040250e42bb33aaca7b03c70 [file] [log] [blame]
Tom Joseph536ea322018-09-14 10:02:20 +05301#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
11namespace phosphor
12{
13namespace user
14{
15
16using namespace phosphor::logging;
17using InvalidArgument =
18 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
19using Argument = xyz::openbmc_project::Common::InvalidArgument;
20
21LDAPMapperEntry::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
34void LDAPMapperEntry::delete_(void)
35{
36 manager.deletePrivilegeMapper(id);
37}
38
39std::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
50std::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