blob: c49cab3f97d1a22e23a70a0485d569cfa6ac5842 [file] [log] [blame]
Ravi Tejaa49895e2020-06-16 03:57:58 -05001#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 Tejaa49895e2020-06-16 03:57:58 -05009
Nan Zhoue1289ad2021-12-28 11:02:56 -080010namespace ca::cert
Ravi Tejaa49895e2020-06-16 03:57:58 -050011{
12
Nan Zhoucf06ccd2021-12-28 16:25:45 -080013namespace internal
14{
15using ManagerInterface = sdbusplus::server::object_t<
Ravi Tejaa49895e2020-06-16 03:57:58 -050016 sdbusplus::xyz::openbmc_project::Certs::server::Authority,
17 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
Nan Zhoucf06ccd2021-12-28 16:25:45 -080018}
19
20class CACertMgr;
Ravi Tejaa49895e2020-06-16 03:57:58 -050021
22/** @class Manager
23 * @brief Implementation for the
24 * xyz.openbmc_project.Certs.ca.authority.Manager DBus API.
25 */
Nan Zhoucf06ccd2021-12-28 16:25:45 -080026class CACertMgr : public internal::ManagerInterface
Ravi Tejaa49895e2020-06-16 03:57:58 -050027{
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 Williamsb3dbfb32022-07-22 19:26:57 -050040 CACertMgr(sdbusplus::bus_t& bus, const char* path) :
Nan Zhoucf06ccd2021-12-28 16:25:45 -080041 internal::ManagerInterface(bus, path), bus(bus), objectPath(path),
Patrick Williamsa2f68d82024-08-16 15:21:36 -040042 lastEntryId(0) {};
Ravi Tejaa49895e2020-06-16 03:57:58 -050043
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 Tejaea7c3f02020-09-15 03:03:51 -050061 protected:
62 std::map<uint32_t, std::unique_ptr<Entry>> entries;
63
Ravi Tejaa49895e2020-06-16 03:57:58 -050064 private:
65 /** @brief sdbusplus DBus bus connection. */
Patrick Williamsb3dbfb32022-07-22 19:26:57 -050066 sdbusplus::bus_t& bus;
Ravi Tejaa49895e2020-06-16 03:57:58 -050067 /** @brief object path */
68 std::string objectPath;
69 /** @brief Id of the last certificate entry */
70 uint32_t lastEntryId;
71};
72
Nan Zhoue1289ad2021-12-28 11:02:56 -080073} // namespace ca::cert