blob: 1b75fa43f9446d13f965a977c668a3cdff7acd67 [file] [log] [blame]
Ravi Tejaa49895e2020-06-16 03:57:58 -05001#pragma once
2
3#include "xyz/openbmc_project/Certs/Entry/server.hpp"
4#include "xyz/openbmc_project/Object/Delete/server.hpp"
5#include "xyz/openbmc_project/PLDM/Provider/Certs/Authority/CSR/server.hpp"
6
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
10namespace ca
11{
12namespace cert
13{
14
Nan Zhoucf06ccd2021-12-28 16:25:45 -080015namespace internal
16{
17using EntryInterface = sdbusplus::server::object_t<
18 sdbusplus::xyz::openbmc_project::PLDM::Provider::Certs::Authority::server::
19 CSR,
20 sdbusplus::xyz::openbmc_project::Certs::server::Entry,
21 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
22}
Ravi Tejaa49895e2020-06-16 03:57:58 -050023
24class CACertMgr;
25
26/** @class Entry
27 * @brief CA authority certificate Entry implementation.
28 * @details A concrete implementation for the
29 * xyz.openbmc_project.Certs.Entry DBus API
30 */
Nan Zhoucf06ccd2021-12-28 16:25:45 -080031class Entry : public internal::EntryInterface
Ravi Tejaa49895e2020-06-16 03:57:58 -050032{
33 public:
34 Entry() = delete;
35 Entry(const Entry&) = delete;
36 Entry& operator=(const Entry&) = delete;
37 Entry(Entry&&) = delete;
38 Entry& operator=(Entry&&) = delete;
39 ~Entry() = default;
40
41 /** @brief Constructor to put object onto bus at a D-Bus path.
42 * @param[in] bus - Bus to attach to.
43 * @param[in] objPath - The D-Bus object path to attach at.
44 * @param[in] entryId - Entry id
45 * @param[in] csr - csr string
46 * @param[in] cert - client certificate
47 */
48 Entry(sdbusplus::bus::bus& bus, const std::string& objPath,
49 uint32_t entryId, std::string& csr, std::string& cert,
50 CACertMgr& manager) :
Nan Zhoucf06ccd2021-12-28 16:25:45 -080051 internal::EntryInterface(bus, objPath.c_str(), true),
Ravi Tejaa49895e2020-06-16 03:57:58 -050052 bus(bus), id(entryId), manager(manager)
53
54 {
Patrick Williamse129be32021-04-30 20:35:19 -050055 this->csr(csr);
Ravi Tejaa49895e2020-06-16 03:57:58 -050056 clientCertificate(cert);
57
58 // Emit deferred signal.
59 this->emit_object_added();
60 };
61
62 void delete_() override;
63
64 protected:
65 /** @brief sdbusplus handler */
66 sdbusplus::bus::bus& bus;
67 uint32_t id;
68 /** @brief object path */
69 std::string objectPath;
70 /** @brief Reference to Certificate Manager */
71 CACertMgr& manager;
72};
73} // namespace cert
74} // namespace ca