Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 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 | { |
Patrick Williams | e129be3 | 2021-04-30 20:35:19 -0500 | [diff] [blame] | 53 | this->csr(csr); |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 54 | clientCertificate(cert); |
| 55 | |
| 56 | // Emit deferred signal. |
| 57 | this->emit_object_added(); |
| 58 | }; |
| 59 | |
| 60 | void delete_() override; |
| 61 | |
| 62 | protected: |
| 63 | /** @brief sdbusplus handler */ |
| 64 | sdbusplus::bus::bus& bus; |
| 65 | uint32_t id; |
| 66 | /** @brief object path */ |
| 67 | std::string objectPath; |
| 68 | /** @brief Reference to Certificate Manager */ |
| 69 | CACertMgr& manager; |
| 70 | }; |
| 71 | } // namespace cert |
| 72 | } // namespace ca |