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