1 #ifndef _SERVICE_HANDLER_H 2 #define _SERVICE_HANDLER_H 12 #include <config_category.h> 14 #include <management_client.h> 23 virtual void shutdown() = 0;
24 virtual void restart() = 0;
25 virtual void configChange(
const std::string& category,
const std::string& config) = 0;
26 virtual void configChildCreate(
const std::string& parent_category,
const std::string& category,
const std::string& config) = 0;
27 virtual void configChildDelete(
const std::string& parent_category,
const std::string& category) = 0;
28 virtual bool isRunning() = 0;
29 virtual bool securityChange(
const std::string &payload) {
return payload.empty(); };
39 virtual ~
ServiceAuthHandler() {
if (m_refreshThread) { m_refreshRunning =
false; m_refreshThread->join();
delete m_refreshThread; } };
40 std::string& getName() {
return m_name; };
41 std::string& getType() {
return m_type; };
43 bool updateSecurityCategory(
const std::string& newCategory);
44 void setInitialAuthenticatedCaller();
45 void setAuthenticatedCaller(
bool enabled);
46 bool getAuthenticatedCaller();
48 bool AuthenticationMiddlewareACL(std::shared_ptr<HttpServer::Response> response,
49 std::shared_ptr<HttpServer::Request> request,
50 const std::string& serviceName,
51 const std::string& serviceType);
53 bool AuthenticationMiddlewareCommon(std::shared_ptr<HttpServer::Response> response,
54 std::shared_ptr<HttpServer::Request> request,
55 std::string& callerName,
56 std::string& callerType);
58 void AuthenticationMiddlewarePUT(std::shared_ptr<HttpServer::Response> response,
59 std::shared_ptr<HttpServer::Request> request,
61 std::shared_ptr<HttpServer::Response>,
62 std::shared_ptr<HttpServer::Request>)> funcPUT);
63 void refreshBearerToken();
65 void respond(std::shared_ptr<HttpServer::Response> response,
66 const std::string& payload)
68 *response <<
"HTTP/1.1 200 OK\r\n" 69 <<
"Content-Length: " << payload.length() <<
"\r\n" 70 <<
"Content-type: application/json\r\n\r\n" 74 void respond(std::shared_ptr<HttpServer::Response> response,
75 SimpleWeb::StatusCode code,
76 const std::string& payload)
78 *response <<
"HTTP/1.1 " << status_code(code) <<
"\r\n" 79 <<
"Content-Length: " << payload.length() <<
"\r\n" 80 <<
"Content-type: application/json\r\n\r\n" 84 getMgmtClient() {
return m_mgtClient; };
85 bool securityChange(
const std::string &payload);
88 bool verifyURL(
const std::string& path,
89 const std::string& sName,
90 const std::string& sType);
91 bool verifyService(
const std::string& sName,
92 const std::string &sType);
103 std::mutex m_mtx_config;
105 bool m_authentication_enabled;
110 std::thread *m_refreshThread;
111 bool m_refreshRunning;
Definition: config_category.h:56
The management client class used by services and tasks to communicate with the management API of the ...
Definition: management_client.h:43
This class represents the ACL (Access Control List) as JSON object fetched from Fledge Storage...
Definition: acl.h:23
ServiceHandler abstract class - the interface that services using the management API must provide...
Definition: service_handler.h:20
static ManagementClient * m_mgtClient
Initialise m_mgtClient object to NULL.
Definition: service_handler.h:99
ServiceAuthHandler adds security to the base class ServiceHandler.
Definition: service_handler.h:35