blob: 21088b6901658437b4736125e99439913d40bddb [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>
9#include <sdeventplus/source/event.hpp>
10
Nan Zhoue1289ad2021-12-28 11:02:56 -080011namespace ca::cert
Ravi Tejaa49895e2020-06-16 03:57:58 -050012{
13
14class CACertMgr;
15
16using CreateIface = sdbusplus::server::object::object<
17 sdbusplus::xyz::openbmc_project::Certs::server::Authority,
18 sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
19using Mgr = ca::cert::CACertMgr;
20
21/** @class Manager
22 * @brief Implementation for the
23 * xyz.openbmc_project.Certs.ca.authority.Manager DBus API.
24 */
25class 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 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. */
66 sdbusplus::bus::bus& bus;
67 // sdevent Event handle
68 sdeventplus::Event& event;
Ravi Tejaa49895e2020-06-16 03:57:58 -050069 /** @brief object path */
70 std::string objectPath;
71 /** @brief Id of the last certificate entry */
72 uint32_t lastEntryId;
73};
74
Nan Zhoue1289ad2021-12-28 11:02:56 -080075} // namespace ca::cert