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