1a49895eeSRavi Teja #pragma once
2a49895eeSRavi Teja 
3a49895eeSRavi Teja #include "xyz/openbmc_project/Certs/Entry/server.hpp"
4a49895eeSRavi Teja #include "xyz/openbmc_project/Object/Delete/server.hpp"
5a49895eeSRavi Teja #include "xyz/openbmc_project/PLDM/Provider/Certs/Authority/CSR/server.hpp"
6a49895eeSRavi Teja 
7a49895eeSRavi Teja #include <sdbusplus/bus.hpp>
8a49895eeSRavi Teja #include <sdbusplus/server/object.hpp>
9a49895eeSRavi Teja 
10a49895eeSRavi Teja namespace ca
11a49895eeSRavi Teja {
12a49895eeSRavi Teja namespace cert
13a49895eeSRavi Teja {
14a49895eeSRavi Teja 
15cf06ccdcSNan Zhou namespace internal
16cf06ccdcSNan Zhou {
17cf06ccdcSNan Zhou using EntryInterface = sdbusplus::server::object_t<
18cf06ccdcSNan Zhou     sdbusplus::xyz::openbmc_project::PLDM::Provider::Certs::Authority::server::
19cf06ccdcSNan Zhou         CSR,
20cf06ccdcSNan Zhou     sdbusplus::xyz::openbmc_project::Certs::server::Entry,
21cf06ccdcSNan Zhou     sdbusplus::xyz::openbmc_project::Object::server::Delete>;
22cf06ccdcSNan Zhou }
23a49895eeSRavi Teja 
24a49895eeSRavi Teja class CACertMgr;
25a49895eeSRavi Teja 
26a49895eeSRavi Teja /** @class Entry
27a49895eeSRavi Teja  *  @brief CA authority certificate Entry implementation.
28a49895eeSRavi Teja  *  @details A concrete implementation for the
29a49895eeSRavi Teja  *           xyz.openbmc_project.Certs.Entry DBus API
30a49895eeSRavi Teja  */
31cf06ccdcSNan Zhou class Entry : public internal::EntryInterface
32a49895eeSRavi Teja {
33a49895eeSRavi Teja   public:
34a49895eeSRavi Teja     Entry() = delete;
35a49895eeSRavi Teja     Entry(const Entry&) = delete;
36a49895eeSRavi Teja     Entry& operator=(const Entry&) = delete;
37a49895eeSRavi Teja     Entry(Entry&&) = delete;
38a49895eeSRavi Teja     Entry& operator=(Entry&&) = delete;
39a49895eeSRavi Teja     ~Entry() = default;
40a49895eeSRavi Teja 
41a49895eeSRavi Teja     /** @brief Constructor to put object onto bus at a D-Bus path.
42a49895eeSRavi Teja      *  @param[in] bus - Bus to attach to.
43a49895eeSRavi Teja      *  @param[in] objPath - The D-Bus object path to attach at.
44a49895eeSRavi Teja      *  @param[in] entryId - Entry id
45a49895eeSRavi Teja      *  @param[in] csr     - csr string
46a49895eeSRavi Teja      *  @param[in] cert    - client certificate
47a49895eeSRavi Teja      */
Entry(sdbusplus::bus_t & bus,const std::string & objPath,uint32_t entryId,std::string & csr,std::string & cert,CACertMgr & manager)48*b3dbfb37SPatrick Williams     Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t entryId,
49*b3dbfb37SPatrick Williams           std::string& csr, std::string& cert, CACertMgr& manager) :
50ebd21ba4SPatrick Williams         internal::EntryInterface(bus, objPath.c_str(),
51ebd21ba4SPatrick Williams                                  internal::EntryInterface::action::defer_emit),
52a49895eeSRavi Teja         bus(bus), id(entryId), manager(manager)
53a49895eeSRavi Teja 
54a49895eeSRavi Teja     {
55e129be3bSPatrick Williams         this->csr(csr);
56a49895eeSRavi Teja         clientCertificate(cert);
57a49895eeSRavi Teja 
58a49895eeSRavi Teja         // Emit deferred signal.
59a49895eeSRavi Teja         this->emit_object_added();
60a49895eeSRavi Teja     };
61a49895eeSRavi Teja 
62a49895eeSRavi Teja     void delete_() override;
63a49895eeSRavi Teja 
64a49895eeSRavi Teja   protected:
65a49895eeSRavi Teja     /** @brief sdbusplus handler */
66*b3dbfb37SPatrick Williams     sdbusplus::bus_t& bus;
67a49895eeSRavi Teja     uint32_t id;
68a49895eeSRavi Teja     /** @brief object path */
69a49895eeSRavi Teja     std::string objectPath;
70a49895eeSRavi Teja     /** @brief Reference to Certificate Manager */
71a49895eeSRavi Teja     CACertMgr& manager;
72a49895eeSRavi Teja };
73a49895eeSRavi Teja } // namespace cert
74a49895eeSRavi Teja } // namespace ca
75