Session creation : Get and Set Oem ClientID

This commit implements handling the OemSession ClientID parameter
for the IBM management console.

Each session gets a random generated unique Id (Resource Id); but this Id
is not a parameter that the client can set to a well known identifier.
This Oem parameter ClientID is the string which the client can supply to
uniquely identify itself among other sessions in the BMC. This is a read-only
property which shall be passed in only during the session creation.

1. Create session by supplying the ClientID Oem parameter
2. Display the ClientID associated with the session
3. Persist the ClientID across BMC reboot

Tested by:
============
1. POST https://${bmc}/redfish/v1/SessionService/Sessions -d
   '{"UserName":"root", "Password":<>, "Oem":{"OpenBMC" : {"ClientID":"<client unique id>"}}}'

2. GET https://${bmc}/redfish/v1/SessionService/Sessions/<id>
{
  "@odata.id": "/redfish/v1/SessionService/Sessions/<id>",
  "@odata.type": "#Session.v1_0_2.Session",
  "Description": "Manager User Session",
  "Id": "<id>",
  "Name": "User Session",
  "Oem": {
    "OpenBMC": {
      "@odata.type": "#OemSession.v1_0_0.Session",
      "ClientID": "<client unique id>"
    }
  },
  "UserName": "root"
}

3. Verified the session creation works fine without the Oem parameters.
4. Redfish validator

Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com>
Change-Id: Ia740a610e3974dc3781bcee702c74ded9903944a
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 515f5be..4dbb64d 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -63,7 +63,11 @@
         res.jsonValue["@odata.type"] = "#Session.v1_0_2.Session";
         res.jsonValue["Name"] = "User Session";
         res.jsonValue["Description"] = "Manager User Session";
-
+#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
+        res.jsonValue["Oem"]["OpenBMC"]["@odata.type"] =
+            "#OemSession.v1_0_0.Session";
+        res.jsonValue["Oem"]["OpenBMC"]["ClientID"] = session->clientId;
+#endif
         res.end();
     }
 
@@ -168,8 +172,10 @@
     {
         std::string username;
         std::string password;
+        std::optional<nlohmann::json> oemObject;
+        std::string clientId;
         if (!json_util::readJson(req, res, "UserName", username, "Password",
-                                 password))
+                                 password, "Oem", oemObject))
         {
             res.end();
             return;
@@ -202,13 +208,29 @@
 
             return;
         }
-
+#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
+        if (oemObject)
+        {
+            std::optional<nlohmann::json> bmcOem;
+            if (!json_util::readJson(*oemObject, res, "OpenBMC", bmcOem))
+            {
+                res.end();
+                return;
+            }
+            if (!json_util::readJson(*bmcOem, res, "ClientID", clientId))
+            {
+                BMCWEB_LOG_ERROR << "Could not read ClientId";
+                res.end();
+                return;
+            }
+        }
+#endif
         // User is authenticated - create session
         std::shared_ptr<crow::persistent_data::UserSession> session =
             crow::persistent_data::SessionStore::getInstance()
                 .generateUserSession(
                     username, crow::persistent_data::PersistenceType::TIMEOUT,
-                    isConfigureSelfOnly);
+                    isConfigureSelfOnly, clientId);
         res.addHeader("X-Auth-Token", session->sessionToken);
         res.addHeader("Location", "/redfish/v1/SessionService/Sessions/" +
                                       session->uniqueId);