Redfish SessionService

- added node version of the SessionService implementation
- added a default timeout member and a get timeout method
  to the SessionStore class

Change-Id: I532080789b3d687208510f8b748402735ed888d8
Signed-off-by: Borawski.Lukasz <lukasz.borawski@intel.com>
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index e14845f..7714ab7 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -42,6 +42,7 @@
     nodes.emplace_back(std::make_unique<RoleCollection>(app));
     nodes.emplace_back(std::make_unique<ServiceRoot>(app));
     nodes.emplace_back(std::make_unique<NetworkProtocol>(app));
+    nodes.emplace_back(std::make_unique<SessionService>(app));
 
     for (auto& node : nodes) {
       node->getSubRoutes(nodes);
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 75857a1..4225cc1 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -36,6 +36,14 @@
     {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
     {crow::HTTPMethod::POST, {{}}}};
 
+static OperationMap sessionServiceOpMap = {
+    {crow::HTTPMethod::GET, {{"Login"}}},
+    {crow::HTTPMethod::HEAD, {{"Login"}}},
+    {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
+    {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
+    {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
+    {crow::HTTPMethod::POST, {{"ConfigureManager"}}}};
+
 class SessionCollection;
 
 class Sessions : public Node {
@@ -233,4 +241,31 @@
   Sessions memberSession;
 };
 
+class SessionService : public Node {
+ public:
+  SessionService(CrowApp& app)
+      : Node(app, EntityPrivileges(std::move(sessionServiceOpMap)),
+             "/redfish/v1/SessionService/") {
+    Node::json["@odata.type"] = "#SessionService.v1_0_2.SessionService";
+    Node::json["@odata.id"] = "/redfish/v1/SessionService/";
+    Node::json["@odata.context"] =
+        "/redfish/v1/$metadata#SessionService.SessionService";
+    Node::json["Name"] = "Session Service";
+    Node::json["Description"] = "Session Service";
+    Node::json["SessionTimeout"] =
+        crow::PersistentData::session_store->get_timeout_in_seconds();
+    Node::json["Status"]["State"] = "Enabled";
+    Node::json["Status"]["Health"] = "OK";
+    Node::json["Status"]["HealthRollup"] = "OK";
+    Node::json["ServiceEnabled"] = true;
+  }
+
+ private:
+  void doGet(crow::response& res, const crow::request& req,
+             const std::vector<std::string>& params) override {
+    res.json_value = Node::json;
+    res.end();
+  }
+};
+
 }  // namespace redfish