1 #ifndef _ots_CorePropertySupervisorBase_h_
2 #define _ots_CorePropertySupervisorBase_h_
5 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
6 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
7 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
8 #include "otsdaq-core/ConfigurationInterface/ConfigurationTree.h"
9 #include "otsdaq-core/ConfigurationPluginDataFormats/XDAQContextConfiguration.h"
10 #include "otsdaq-core/MessageFacility/MessageFacility.h"
11 #include "otsdaq-core/Macros/CoutMacros.h"
13 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
17 #include <xdaq/Application.h>
18 #pragma GCC diagnostic pop
37 virtual void setSupervisorPropertyDefaults (
void);
38 virtual void forceSupervisorPropertyValues (
void) {;}
43 static void extractPermissionsMapFromString (
const std::string& permissionsString, std::map<std::string,WebUsers::permissionLevel_t>& permissionsMap);
44 static bool doPermissionsGrantAccess (std::map<std::string,WebUsers::permissionLevel_t>& permissionLevelsMap, std::map<std::string,WebUsers::permissionLevel_t>& permissionThresholdsMap);
52 std::string supervisorClass_;
53 std::string supervisorClassNoNamespace_;
55 std::string supervisorContextUID_;
56 std::string supervisorApplicationUID_;
57 std::string supervisorConfigurationPath_;
66 : allSetNames_({&CheckUserLockRequestTypes,&RequireUserLockRequestTypes,
67 &AutomatedRequestTypes,&AllowNoLoginRequestTypes,
68 &NoXmlWhiteSpaceRequestTypes,&NonXMLRequestTypes})
71 const std::string UserPermissionsThreshold =
"UserPermissionsThreshold";
72 const std::string UserGroupsAllowed =
"UserGroupsAllowed";
73 const std::string UserGroupsDisallowed =
"UserGroupsDisallowed";
75 const std::string CheckUserLockRequestTypes =
"CheckUserLockRequestTypes";
76 const std::string RequireUserLockRequestTypes =
"RequireUserLockRequestTypes";
77 const std::string AutomatedRequestTypes =
"AutomatedRequestTypes";
78 const std::string AllowNoLoginRequestTypes =
"AllowNoLoginRequestTypes";
80 const std::string NoXmlWhiteSpaceRequestTypes =
"NoXmlWhiteSpaceRequestTypes";
81 const std::string NonXMLRequestTypes =
"NonXMLRequestTypes";
83 const std::set<const std::string*> allSetNames_;
84 } SUPERVISOR_PROPERTIES;
88 void checkSupervisorPropertySetup (
void);
89 volatile bool propertiesAreSetup_;
93 std::map<std::string, std::string> propertyMap_;
94 struct CoreSupervisorPropertyStruct
96 CoreSupervisorPropertyStruct()
97 : allSets_ ({&CheckUserLockRequestTypes,&RequireUserLockRequestTypes,
98 &AutomatedRequestTypes,&AllowNoLoginRequestTypes,
99 &NoXmlWhiteSpaceRequestTypes,&NonXMLRequestTypes})
102 std::map<std::string,WebUsers::permissionLevel_t> UserPermissionsThreshold;
103 std::map<std::string,std::string> UserGroupsAllowed;
104 std::map<std::string,std::string> UserGroupsDisallowed;
106 std::set<std::string> CheckUserLockRequestTypes;
107 std::set<std::string> RequireUserLockRequestTypes;
108 std::set<std::string> AutomatedRequestTypes;
109 std::set<std::string> AllowNoLoginRequestTypes;
111 std::set<std::string> NoXmlWhiteSpaceRequestTypes;
112 std::set<std::string> NonXMLRequestTypes;
114 std::set< std::set<std::string>* > allSets_;
118 void resetPropertiesAreSetup (
void) { propertiesAreSetup_ =
false; }
119 ConfigurationTree getSupervisorTreeNode (
void);
121 void loadUserSupervisorProperties (
void);
123 void setSupervisorProperty (
const std::string& propertyName,
const T& propertyValue)
125 std::stringstream ss;
127 setSupervisorProperty(propertyName,ss.str());
129 void setSupervisorProperty (
const std::string& propertyName,
const std::string& propertyValue);
131 void addSupervisorProperty (
const std::string& propertyName,
const T& propertyValue)
134 std::stringstream ss;
135 ss << propertyValue <<
" | " << getSupervisorProperty(propertyName);
136 setSupervisorProperty(propertyName,ss.str());
138 void addSupervisorProperty (
const std::string& propertyName,
const std::string& propertyValue);
140 T getSupervisorProperty (
const std::string& propertyName)
143 checkSupervisorPropertySetup();
145 auto it = propertyMap_.find(propertyName);
146 if(it == propertyMap_.end())
148 __SS__ <<
"Could not find property named " << propertyName << __E__;
151 return StringMacros::validateValueForDefaultStringDataType<T>(it->second);
153 std::string getSupervisorProperty(
const std::string& propertyName);
154 WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold(
const std::string& requestType);