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