blob: ad7ffce2edf5a2b86f5709cf19b3823486db779b [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#ifdef SDBUSPP_NEW_CAMELCASE
54 this->csr(csr);
55#else
Ravi Tejaa49895e2020-06-16 03:57:58 -050056 cSR(csr);
Patrick Williamse129be32021-04-30 20:35:19 -050057#endif
Ravi Tejaa49895e2020-06-16 03:57:58 -050058 clientCertificate(cert);
59
60 // Emit deferred signal.
61 this->emit_object_added();
62 };
63
64 void delete_() override;
65
66 protected:
67 /** @brief sdbusplus handler */
68 sdbusplus::bus::bus& bus;
69 uint32_t id;
70 /** @brief object path */
71 std::string objectPath;
72 /** @brief Reference to Certificate Manager */
73 CACertMgr& manager;
74};
75} // namespace cert
76} // namespace ca