xref: /openbmc/phosphor-certificate-manager/csr.hpp (revision 223e460421eebb1c598d9285b0cb01f1150fa50d)
1 #pragma once
2 #include <sdbusplus/server/object.hpp>
3 #include <xyz/openbmc_project/Certs/CSR/server.hpp>
4 
5 #include <string>
6 
7 namespace phosphor::certs
8 {
9 
10 enum class Status
11 {
12     success,
13     failure,
14 };
15 
16 namespace internal
17 {
18 using CSRInterface = sdbusplus::server::object_t<
19     sdbusplus::xyz::openbmc_project::Certs::server::CSR>;
20 }
21 
22 /** @class CSR
23  *  @brief To read CSR certificate
24  */
25 class CSR : public internal::CSRInterface
26 {
27   public:
28     CSR() = delete;
29     ~CSR() = default;
30     CSR(const CSR&) = delete;
31     CSR& operator=(const CSR&) = delete;
32     CSR(CSR&&) = delete;
33     CSR& operator=(CSR&&) = delete;
34 
35     /** @brief Constructor to put object onto bus at a D-Bus path.
36      *  @param[in] bus - Bus to attach to.
37      *  @param[in] path - The D-Bus object path to attach at.
38      *  @param[in] installPath - Certificate installation path.
39      *  @param[in] status - Status of Generate CSR request
40      */
41     CSR(sdbusplus::bus_t& bus, const char* path, std::string&& installPath,
42         const Status& status);
43     /** @brief Return CSR
44      */
45     std::string csr() override;
46 
47   private:
48     /** @brief object path */
49     std::string objectPath;
50 
51     /** @brief Certificate file installation path **/
52     std::string certInstallPath;
53 
54     /** @brief Status of GenerateCSR request */
55     Status csrStatus;
56 };
57 } // namespace phosphor::certs
58