Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "ca_cert_entry.hpp" |
| 4 | #include "xyz/openbmc_project/Certs/Authority/server.hpp" |
| 5 | #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" |
| 6 | |
| 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/object.hpp> |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 9 | |
Nan Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 10 | namespace ca::cert |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 11 | { |
| 12 | |
Nan Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame] | 13 | namespace internal |
| 14 | { |
| 15 | using ManagerInterface = sdbusplus::server::object_t< |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 16 | sdbusplus::xyz::openbmc_project::Certs::server::Authority, |
| 17 | sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>; |
Nan Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | class CACertMgr; |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 21 | |
| 22 | /** @class Manager |
| 23 | * @brief Implementation for the |
| 24 | * xyz.openbmc_project.Certs.ca.authority.Manager DBus API. |
| 25 | */ |
Nan Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame] | 26 | class CACertMgr : public internal::ManagerInterface |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 27 | { |
| 28 | public: |
| 29 | CACertMgr() = delete; |
| 30 | CACertMgr(const CACertMgr&) = delete; |
| 31 | CACertMgr& operator=(const CACertMgr&) = delete; |
| 32 | CACertMgr(CACertMgr&&) = delete; |
| 33 | CACertMgr& operator=(CACertMgr&&) = delete; |
| 34 | virtual ~CACertMgr() = default; |
| 35 | |
| 36 | /** @brief Constructor to put object onto bus at a dbus path. |
| 37 | * @param[in] bus - Bus to attach to. |
| 38 | * @param[in] path - Path to attach at. |
| 39 | */ |
Patrick Williams | b3dbfb3 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 40 | CACertMgr(sdbusplus::bus_t& bus, const char* path) : |
Nan Zhou | cf06ccd | 2021-12-28 16:25:45 -0800 | [diff] [blame] | 41 | internal::ManagerInterface(bus, path), bus(bus), objectPath(path), |
Patrick Williams | a2f68d8 | 2024-08-16 15:21:36 -0400 | [diff] [blame^] | 42 | lastEntryId(0) {}; |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 43 | |
| 44 | /** @brief This method provides signing authority functionality. |
| 45 | It signs the certificate and creates the CSR request entry Dbus |
| 46 | Object. |
| 47 | * @param[in] csr - csr string |
| 48 | * @return Object path |
| 49 | */ |
| 50 | sdbusplus::message::object_path signCSR(std::string csr) override; |
| 51 | |
| 52 | /** @brief Erase specified entry d-bus object |
| 53 | * @param[in] entryId - unique identifier of the entry |
| 54 | */ |
| 55 | void erase(uint32_t entryId); |
| 56 | |
| 57 | /** @brief Erase all entries |
| 58 | */ |
| 59 | void deleteAll() override; |
| 60 | |
Ravi Teja | ea7c3f0 | 2020-09-15 03:03:51 -0500 | [diff] [blame] | 61 | protected: |
| 62 | std::map<uint32_t, std::unique_ptr<Entry>> entries; |
| 63 | |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 64 | private: |
| 65 | /** @brief sdbusplus DBus bus connection. */ |
Patrick Williams | b3dbfb3 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 66 | sdbusplus::bus_t& bus; |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 67 | /** @brief object path */ |
| 68 | std::string objectPath; |
| 69 | /** @brief Id of the last certificate entry */ |
| 70 | uint32_t lastEntryId; |
| 71 | }; |
| 72 | |
Nan Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 73 | } // namespace ca::cert |