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