summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-06 23:17:43 +0300
committerEd Tanous <ed@tanous.net>2024-03-21 02:28:50 +0300
commit7a31e336bd151aebd6175663021acd8608e3a97e (patch)
treeadc494811e46af9f4108bdb59f1ec6864e54d0ac /redfish-core
parent7cb59f655a3e68b23ec720d286c71805c5c9a895 (diff)
downloadbmcweb-7a31e336bd151aebd6175663021acd8608e3a97e.tar.xz
Clean up Certificate Service to use readJson
Use multiple level direct read to simplify code. Tested: Visual only. Need help if anyone wants to test. Change-Id: Ib7c34daefbe2bb835cbe420b40861f27442d05b1 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/certificate_service.hpp39
1 files changed, 12 insertions, 27 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index a176dd5f93..5dc4413821 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -471,13 +471,12 @@ inline void handleReplaceCertificateAction(
return;
}
std::string certificate;
- nlohmann::json certificateUri;
+ std::string certURI;
std::optional<std::string> certificateType = "PEM";
if (!json_util::readJsonAction(req, asyncResp->res, "CertificateString",
- certificate, "CertificateUri",
- certificateUri, "CertificateType",
- certificateType))
+ certificate, "CertificateUri/@odata.id",
+ certURI, "CertificateType", certificateType))
{
BMCWEB_LOG_ERROR("Required parameters are missing");
return;
@@ -495,14 +494,6 @@ inline void handleReplaceCertificateAction(
return;
}
- std::string certURI;
- if (!redfish::json_util::readJson(certificateUri, asyncResp->res,
- "@odata.id", certURI))
- {
- messages::actionParameterMissing(asyncResp->res, "ReplaceCertificate",
- "CertificateUri");
- return;
- }
BMCWEB_LOG_INFO("Certificate URI to replace: {}", certURI);
boost::system::result<boost::urls::url> parsedUrl =
@@ -635,7 +626,7 @@ inline void
std::string organization;
std::string organizationalUnit;
std::string state;
- nlohmann::json certificateCollection;
+ std::string certURI;
// Optional parameters
std::optional<std::vector<std::string>> optAlternativeNames =
@@ -656,13 +647,14 @@ inline void
req, asyncResp->res, "City", city, "CommonName", commonName,
"ContactPerson", optContactPerson, "Country", country,
"Organization", organization, "OrganizationalUnit",
- organizationalUnit, "State", state, "CertificateCollection",
- certificateCollection, "AlternativeNames", optAlternativeNames,
- "ChallengePassword", optChallengePassword, "Email", optEmail,
- "GivenName", optGivenName, "Initials", optInitials, "KeyBitLength",
- optKeyBitLength, "KeyCurveId", optKeyCurveId, "KeyPairAlgorithm",
- optKeyPairAlgorithm, "KeyUsage", optKeyUsage, "Surname", optSurname,
- "UnstructuredName", optUnstructuredName))
+ organizationalUnit, "State", state,
+ "CertificateCollection/@odata.id", certURI, "AlternativeNames",
+ optAlternativeNames, "ChallengePassword", optChallengePassword,
+ "Email", optEmail, "GivenName", optGivenName, "Initials",
+ optInitials, "KeyBitLength", optKeyBitLength, "KeyCurveId",
+ optKeyCurveId, "KeyPairAlgorithm", optKeyPairAlgorithm, "KeyUsage",
+ optKeyUsage, "Surname", optSurname, "UnstructuredName",
+ optUnstructuredName))
{
return;
}
@@ -678,13 +670,6 @@ inline void
return;
}
- std::string certURI;
- if (!redfish::json_util::readJson(certificateCollection, asyncResp->res,
- "@odata.id", certURI))
- {
- return;
- }
-
std::string objectPath;
std::string service;
if (certURI.starts_with(