1 #ifndef _ots_CorePropertySupervisorBase_h_
2 #define _ots_CorePropertySupervisorBase_h_
4 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
5 #include "otsdaq/ConfigurationInterface/ConfigurationTree.h"
6 #include "otsdaq/Macros/CoutMacros.h"
7 #include "otsdaq/MessageFacility/MessageFacility.h"
8 #include "otsdaq/SupervisorInfo/AllSupervisorInfo.h"
9 #include "otsdaq/TableCore/TableGroupKey.h"
10 #include "otsdaq/TablePlugins/XDAQContextTable.h"
12 #include "otsdaq/WebUsersUtilities/WebUsers.h"
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
16 #include <xdaq/Application.h>
17 #pragma GCC diagnostic pop
37 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* getGatewaySupervisorDescriptor (
void);
39 virtual void setSupervisorPropertyDefaults (
void);
40 virtual void forceSupervisorPropertyValues (
void){;}
46 static void extractPermissionsMapFromString (
const std::string& permissionsString, std::map<std::string, WebUsers::permissionLevel_t>& permissionsMap);
47 static bool doPermissionsGrantAccess (std::map<std::string, WebUsers::permissionLevel_t>& permissionLevelsMap, std::map<std::string, WebUsers::permissionLevel_t>& permissionThresholdsMap);
51 return theConfigurationManager_->getNode(
56 return getContextTreeNode().getNode(supervisorConfigurationPath_);
59 const std::string& getContextUID (
void)
const {
return supervisorContextUID_; }
60 const std::string& getSupervisorUID (
void)
const {
return supervisorApplicationUID_; }
61 const std::string& getSupervisorConfigurationPath (
void)
const
63 return supervisorConfigurationPath_;
67 const std::string supervisorClass_;
68 const std::string supervisorClassNoNamespace_;
73 std::string supervisorContextUID_;
74 std::string supervisorApplicationUID_;
75 std::string supervisorConfigurationPath_;
84 : allSetNames_({&CheckUserLockRequestTypes,
85 &RequireUserLockRequestTypes,
86 &AutomatedRequestTypes,
87 &AllowNoLoginRequestTypes,
88 &RequireSecurityRequestTypes,
89 &NoXmlWhiteSpaceRequestTypes,
94 const std::string UserPermissionsThreshold =
"UserPermissionsThreshold";
95 const std::string UserGroupsAllowed =
"UserGroupsAllowed";
96 const std::string UserGroupsDisallowed =
"UserGroupsDisallowed";
98 const std::string CheckUserLockRequestTypes =
"CheckUserLockRequestTypes";
99 const std::string RequireUserLockRequestTypes =
"RequireUserLockRequestTypes";
100 const std::string AutomatedRequestTypes =
"AutomatedRequestTypes";
101 const std::string AllowNoLoginRequestTypes =
"AllowNoLoginRequestTypes";
102 const std::string RequireSecurityRequestTypes =
"RequireSecurityRequestTypes";
104 const std::string NoXmlWhiteSpaceRequestTypes =
"NoXmlWhiteSpaceRequestTypes";
105 const std::string NonXMLRequestTypes =
"NonXMLRequestTypes";
107 const std::set<const std::string*> allSetNames_;
108 } SUPERVISOR_PROPERTIES;
112 void checkSupervisorPropertySetup (
void);
113 volatile bool propertiesAreSetup_;
118 std::map<std::string, std::string> propertyMap_;
119 struct CoreSupervisorPropertyStruct
121 CoreSupervisorPropertyStruct()
122 : allSets_({&CheckUserLockRequestTypes,
123 &RequireUserLockRequestTypes,
124 &AutomatedRequestTypes,
125 &AllowNoLoginRequestTypes,
126 &RequireSecurityRequestTypes,
127 &NoXmlWhiteSpaceRequestTypes,
128 &NonXMLRequestTypes})
132 std::map<std::string, WebUsers::permissionLevel_t> UserPermissionsThreshold;
133 std::map<std::string, std::string> UserGroupsAllowed;
134 std::map<std::string, std::string> UserGroupsDisallowed;
136 std::set<std::string> CheckUserLockRequestTypes;
137 std::set<std::string> RequireUserLockRequestTypes;
138 std::set<std::string> AutomatedRequestTypes;
139 std::set<std::string> AllowNoLoginRequestTypes;
140 std::set<std::string> RequireSecurityRequestTypes;
142 std::set<std::string> NoXmlWhiteSpaceRequestTypes;
143 std::set<std::string> NonXMLRequestTypes;
145 std::set<std::set<std::string>*> allSets_;
149 void resetPropertiesAreSetup (
void)
151 propertiesAreSetup_ =
false;
153 ConfigurationTree getSupervisorTreeNode(
void);
155 void loadUserSupervisorProperties (
void);
157 void setSupervisorProperty (
158 const std::string& propertyName,
const T& propertyValue)
160 std::stringstream ss;
162 setSupervisorProperty(propertyName, ss.str());
164 void setSupervisorProperty (
const std::string& propertyName,
165 const std::string& propertyValue);
167 void addSupervisorProperty (
168 const std::string& propertyName,
const T& propertyValue)
171 std::stringstream ss;
172 ss << propertyValue <<
" | " << getSupervisorProperty(propertyName);
173 setSupervisorProperty(propertyName, ss.str());
175 void addSupervisorProperty (
const std::string& propertyName,
const std::string& propertyValue);
177 T getSupervisorProperty (
178 const std::string& propertyName)
181 checkSupervisorPropertySetup();
183 auto it = propertyMap_.find(propertyName);
184 if(it == propertyMap_.end())
186 __SS__ <<
"Could not find property named " << propertyName << __E__;
189 return StringMacros::validateValueForDefaultStringDataType<T>(it->second);
192 T getSupervisorProperty (
193 const std::string& propertyName,
const T& defaultValue)
196 checkSupervisorPropertySetup();
198 auto it = propertyMap_.find(propertyName);
199 if(it == propertyMap_.end())
204 return StringMacros::validateValueForDefaultStringDataType<T>(it->second);
206 std::string getSupervisorProperty (
const std::string& propertyName);
207 std::string getSupervisorProperty (
const std::string& propertyName,
const std::string& defaultValue);
208 WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold (
const std::string& requestType);