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 | |
Nan Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame^] | 15 | namespace internal |
| 16 | { |
| 17 | using 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 Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 23 | |
| 24 | class 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 Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame^] | 31 | class Entry : public internal::EntryInterface |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 32 | { |
| 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 Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame^] | 51 | internal::EntryInterface(bus, objPath.c_str(), true), |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 52 | bus(bus), id(entryId), manager(manager) |
| 53 | |
| 54 | { |
Patrick Williams | e129be3 | 2021-04-30 20:35:19 -0500 | [diff] [blame] | 55 | this->csr(csr); |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 56 | 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 |