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> |
| 9 | #include <sdeventplus/source/event.hpp> |
| 10 | |
Nan Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 11 | namespace ca::cert |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 12 | { |
| 13 | |
| 14 | class CACertMgr; |
| 15 | |
| 16 | using CreateIface = sdbusplus::server::object::object< |
| 17 | sdbusplus::xyz::openbmc_project::Certs::server::Authority, |
| 18 | sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>; |
| 19 | using Mgr = ca::cert::CACertMgr; |
| 20 | |
| 21 | /** @class Manager |
| 22 | * @brief Implementation for the |
| 23 | * xyz.openbmc_project.Certs.ca.authority.Manager DBus API. |
| 24 | */ |
| 25 | class CACertMgr : public CreateIface |
| 26 | { |
| 27 | public: |
| 28 | CACertMgr() = delete; |
| 29 | CACertMgr(const CACertMgr&) = delete; |
| 30 | CACertMgr& operator=(const CACertMgr&) = delete; |
| 31 | CACertMgr(CACertMgr&&) = delete; |
| 32 | CACertMgr& operator=(CACertMgr&&) = delete; |
| 33 | virtual ~CACertMgr() = default; |
| 34 | |
| 35 | /** @brief Constructor to put object onto bus at a dbus path. |
| 36 | * @param[in] bus - Bus to attach to. |
| 37 | * @param[in] path - Path to attach at. |
| 38 | */ |
| 39 | CACertMgr(sdbusplus::bus::bus& bus, sdeventplus::Event& event, |
| 40 | const char* path) : |
| 41 | CreateIface(bus, path), |
| 42 | bus(bus), event(event), objectPath(path), lastEntryId(0){}; |
| 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. */ |
| 66 | sdbusplus::bus::bus& bus; |
| 67 | // sdevent Event handle |
| 68 | sdeventplus::Event& event; |
Ravi Teja | a49895e | 2020-06-16 03:57:58 -0500 | [diff] [blame] | 69 | /** @brief object path */ |
| 70 | std::string objectPath; |
| 71 | /** @brief Id of the last certificate entry */ |
| 72 | uint32_t lastEntryId; |
| 73 | }; |
| 74 | |
Nan Zhou | e1289ad | 2021-12-28 11:02:56 -0800 | [diff] [blame] | 75 | } // namespace ca::cert |