blob: 174dabae6928d296c6f613449b68d5db9ffe02b3 [file] [log] [blame]
Ravi Tejaa49895e2020-06-16 03:57:58 -05001#pragma once
2
3#include "xyz/openbmc_project/Certs/Entry/server.hpp"
4#include "xyz/openbmc_project/Object/Delete/server.hpp"
5#include "xyz/openbmc_project/PLDM/Provider/Certs/Authority/CSR/server.hpp"
6
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
10namespace ca
11{
12namespace cert
13{
14
15using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
16
17using CertEntry = sdbusplus::xyz::openbmc_project::Certs::server::Entry;
18using CSREntry = sdbusplus::xyz::openbmc_project::PLDM::Provider::Certs::
19 Authority::server::CSR;
20using Ifaces = sdbusplus::server::object::object<CSREntry, CertEntry, Delete>;
21
22class CACertMgr;
23
24/** @class Entry
25 * @brief CA authority certificate Entry implementation.
26 * @details A concrete implementation for the
27 * xyz.openbmc_project.Certs.Entry DBus API
28 */
29class Entry : public Ifaces
30{
31 public:
32 Entry() = delete;
33 Entry(const Entry&) = delete;
34 Entry& operator=(const Entry&) = delete;
35 Entry(Entry&&) = delete;
36 Entry& operator=(Entry&&) = delete;
37 ~Entry() = default;
38
39 /** @brief Constructor to put object onto bus at a D-Bus path.
40 * @param[in] bus - Bus to attach to.
41 * @param[in] objPath - The D-Bus object path to attach at.
42 * @param[in] entryId - Entry id
43 * @param[in] csr - csr string
44 * @param[in] cert - client certificate
45 */
46 Entry(sdbusplus::bus::bus& bus, const std::string& objPath,
47 uint32_t entryId, std::string& csr, std::string& cert,
48 CACertMgr& manager) :
49 Ifaces(bus, objPath.c_str(), true),
50 bus(bus), id(entryId), manager(manager)
51
52 {
Patrick Williamse129be32021-04-30 20:35:19 -050053 this->csr(csr);
Ravi Tejaa49895e2020-06-16 03:57:58 -050054 clientCertificate(cert);
55
56 // Emit deferred signal.
57 this->emit_object_added();
58 };
59
60 void delete_() override;
61
62 protected:
63 /** @brief sdbusplus handler */
64 sdbusplus::bus::bus& bus;
65 uint32_t id;
66 /** @brief object path */
67 std::string objectPath;
68 /** @brief Reference to Certificate Manager */
69 CACertMgr& manager;
70};
71} // namespace cert
72} // namespace ca