blob: 9d6231eae06a3ec98bf2345b3c2babe0dd1c4f69 [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
63 private:
64 /** @brief sdbusplus DBus bus connection. */
65 sdbusplus::bus::bus& bus;
66 // sdevent Event handle
67 sdeventplus::Event& event;
68
69 std::map<uint32_t, std::unique_ptr<Entry>> entries;
70 /** @brief object path */
71 std::string objectPath;
72 /** @brief Id of the last certificate entry */
73 uint32_t lastEntryId;
74};
75
76} // namespace cert
77} // namespace ca