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 virtual void setSupervisorPropertyDefaults (
void);
38 virtual void forceSupervisorPropertyValues (
void){;}
44 static void extractPermissionsMapFromString (
const std::string& permissionsString, std::map<std::string, WebUsers::permissionLevel_t>& permissionsMap);
45 static bool doPermissionsGrantAccess (std::map<std::string, WebUsers::permissionLevel_t>& permissionLevelsMap, std::map<std::string, WebUsers::permissionLevel_t>& permissionThresholdsMap);
49 return theConfigurationManager_->getNode(
54 return getContextTreeNode().getNode(supervisorConfigurationPath_);
57 const std::string& getContextUID (
void)
const {
return supervisorContextUID_; }
58 const std::string& getSupervisorUID (
void)
const {
return supervisorApplicationUID_; }
59 const std::string& getSupervisorConfigurationPath (
void)
const
61 return supervisorConfigurationPath_;
65 const std::string supervisorClass_;
66 const std::string supervisorClassNoNamespace_;
71 std::string supervisorContextUID_;
72 std::string supervisorApplicationUID_;
73 std::string supervisorConfigurationPath_;
82 : allSetNames_({&CheckUserLockRequestTypes,
83 &RequireUserLockRequestTypes,
84 &AutomatedRequestTypes,
85 &AllowNoLoginRequestTypes,
86 &RequireSecurityRequestTypes,
87 &NoXmlWhiteSpaceRequestTypes,
92 const std::string UserPermissionsThreshold =
"UserPermissionsThreshold";
93 const std::string UserGroupsAllowed =
"UserGroupsAllowed";
94 const std::string UserGroupsDisallowed =
"UserGroupsDisallowed";
96 const std::string CheckUserLockRequestTypes =
"CheckUserLockRequestTypes";
97 const std::string RequireUserLockRequestTypes =
"RequireUserLockRequestTypes";
98 const std::string AutomatedRequestTypes =
"AutomatedRequestTypes";
99 const std::string AllowNoLoginRequestTypes =
"AllowNoLoginRequestTypes";
100 const std::string RequireSecurityRequestTypes =
"RequireSecurityRequestTypes";
102 const std::string NoXmlWhiteSpaceRequestTypes =
"NoXmlWhiteSpaceRequestTypes";
103 const std::string NonXMLRequestTypes =
"NonXMLRequestTypes";
105 const std::set<const std::string*> allSetNames_;
106 } SUPERVISOR_PROPERTIES;
110 void checkSupervisorPropertySetup (
void);
111 volatile bool propertiesAreSetup_;
116 std::map<std::string, std::string> propertyMap_;
117 struct CoreSupervisorPropertyStruct
119 CoreSupervisorPropertyStruct()
120 : allSets_({&CheckUserLockRequestTypes,
121 &RequireUserLockRequestTypes,
122 &AutomatedRequestTypes,
123 &AllowNoLoginRequestTypes,
124 &RequireSecurityRequestTypes,
125 &NoXmlWhiteSpaceRequestTypes,
126 &NonXMLRequestTypes})
130 std::map<std::string, WebUsers::permissionLevel_t> UserPermissionsThreshold;
131 std::map<std::string, std::string> UserGroupsAllowed;
132 std::map<std::string, std::string> UserGroupsDisallowed;
134 std::set<std::string> CheckUserLockRequestTypes;
135 std::set<std::string> RequireUserLockRequestTypes;
136 std::set<std::string> AutomatedRequestTypes;
137 std::set<std::string> AllowNoLoginRequestTypes;
138 std::set<std::string> RequireSecurityRequestTypes;
140 std::set<std::string> NoXmlWhiteSpaceRequestTypes;
141 std::set<std::string> NonXMLRequestTypes;
143 std::set<std::set<std::string>*> allSets_;
147 void resetPropertiesAreSetup (
void)
149 propertiesAreSetup_ =
false;
151 ConfigurationTree getSupervisorTreeNode(
void);
153 void loadUserSupervisorProperties (
void);
155 void setSupervisorProperty (
156 const std::string& propertyName,
const T& propertyValue)
158 std::stringstream ss;
160 setSupervisorProperty(propertyName, ss.str());
162 void setSupervisorProperty (
const std::string& propertyName,
163 const std::string& propertyValue);
165 void addSupervisorProperty (
166 const std::string& propertyName,
const T& propertyValue)
169 std::stringstream ss;
170 ss << propertyValue <<
" | " << getSupervisorProperty(propertyName);
171 setSupervisorProperty(propertyName, ss.str());
173 void addSupervisorProperty (
const std::string& propertyName,
const std::string& propertyValue);
175 T getSupervisorProperty (
176 const std::string& propertyName)
179 checkSupervisorPropertySetup();
181 auto it = propertyMap_.find(propertyName);
182 if(it == propertyMap_.end())
184 __SS__ <<
"Could not find property named " << propertyName << __E__;
187 return StringMacros::validateValueForDefaultStringDataType<T>(it->second);
190 T getSupervisorProperty (
191 const std::string& propertyName,
const T& defaultValue)
194 checkSupervisorPropertySetup();
196 auto it = propertyMap_.find(propertyName);
197 if(it == propertyMap_.end())
202 return StringMacros::validateValueForDefaultStringDataType<T>(it->second);
204 std::string getSupervisorProperty (
const std::string& propertyName);
205 std::string getSupervisorProperty (
const std::string& propertyName,
const std::string& defaultValue);
206 WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold (
const std::string& requestType);