1 #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 
10 namespace ca
11 {
12 namespace cert
13 {
14 
15 using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
16 
17 using CertEntry = sdbusplus::xyz::openbmc_project::Certs::server::Entry;
18 using CSREntry = sdbusplus::xyz::openbmc_project::PLDM::Provider::Certs::
19     Authority::server::CSR;
20 using Ifaces = sdbusplus::server::object::object<CSREntry, CertEntry, Delete>;
21 
22 class CACertMgr;
23 
24 /** @class Entry
25  *  @brief CA authority certificate Entry implementation.
26  *  @details A concrete implementation for the
27  *           xyz.openbmc_project.Certs.Entry DBus API
28  */
29 class Entry : public Ifaces
30 {
31   public:
32     Entry() = delete;
33     Entry(const Entry&) = delete;
34     Entry& operator=(const Entry&) = delete;
35     Entry(Entry&&) = delete;
36     Entry& operator=(Entry&&) = delete;
37     ~Entry() = default;
38 
39     /** @brief Constructor to put object onto bus at a D-Bus path.
40      *  @param[in] bus - Bus to attach to.
41      *  @param[in] objPath - The D-Bus object path to attach at.
42      *  @param[in] entryId - Entry id
43      *  @param[in] csr     - csr string
44      *  @param[in] cert    - client certificate
45      */
46     Entry(sdbusplus::bus::bus& bus, const std::string& objPath,
47           uint32_t entryId, std::string& csr, std::string& cert,
48           CACertMgr& manager) :
49         Ifaces(bus, objPath.c_str(), true),
50         bus(bus), id(entryId), manager(manager)
51 
52     {
53 #ifdef SDBUSPP_NEW_CAMELCASE
54         this->csr(csr);
55 #else
56         cSR(csr);
57 #endif
58         clientCertificate(cert);
59 
60         // Emit deferred signal.
61         this->emit_object_added();
62     };
63 
64     void delete_() override;
65 
66   protected:
67     /** @brief sdbusplus handler */
68     sdbusplus::bus::bus& bus;
69     uint32_t id;
70     /** @brief object path */
71     std::string objectPath;
72     /** @brief Reference to Certificate Manager */
73     CACertMgr& manager;
74 };
75 } // namespace cert
76 } // namespace ca
77