$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_CorePropertySupervisorBase_h_ 00002 #define _ots_CorePropertySupervisorBase_h_ 00003 00004 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h" 00005 #include "otsdaq-core/ConfigurationInterface/ConfigurationTree.h" 00006 #include "otsdaq-core/Macros/CoutMacros.h" 00007 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00008 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h" 00009 #include "otsdaq-core/TableCore/TableGroupKey.h" 00010 #include "otsdaq-core/TablePluginDataFormats/XDAQContextTable.h" 00011 00012 #include "otsdaq-core/WebUsersUtilities/WebUsers.h" //for WebUsers::RequestUserInfo 00013 00014 #pragma GCC diagnostic push 00015 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 00016 #include <xdaq/Application.h> 00017 #pragma GCC diagnostic pop 00018 00019 namespace ots 00020 { 00021 // CorePropertySupervisorBase 00022 // This class provides supervisor property get and set functionality. It has member 00023 // variables generally useful to the configuration of client supervisors. 00024 class CorePropertySupervisorBase 00025 { 00026 friend class GatewaySupervisor; // for access to indicateOtsAlive() 00027 00028 public: 00029 CorePropertySupervisorBase(xdaq::Application* application); 00030 virtual ~CorePropertySupervisorBase(void); 00031 00032 00033 AllSupervisorInfo allSupervisorInfo_; 00034 ConfigurationManager* theConfigurationManager_; 00035 00036 00037 virtual void setSupervisorPropertyDefaults( 00038 void); // override to control supervisor specific defaults 00039 virtual void forceSupervisorPropertyValues(void) 00040 { 00041 ; 00042 } // override to force supervisor property values (and ignore user settings) 00043 00044 void getRequestUserInfo(WebUsers::RequestUserInfo& requestUserInfo); 00045 00046 // supervisors should use these two static functions to standardize permissions 00047 // access: 00048 static void extractPermissionsMapFromString( 00049 const std::string& permissionsString, 00050 std::map<std::string, WebUsers::permissionLevel_t>& permissionsMap); 00051 static bool doPermissionsGrantAccess( 00052 std::map<std::string, WebUsers::permissionLevel_t>& permissionLevelsMap, 00053 std::map<std::string, WebUsers::permissionLevel_t>& permissionThresholdsMap); 00054 00055 ConfigurationTree getContextTreeNode(void) const 00056 { 00057 return theConfigurationManager_->getNode( 00058 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName()); 00059 } 00060 ConfigurationTree getSupervisorTableNode(void) const 00061 { 00062 return getContextTreeNode().getNode(supervisorConfigurationPath_); 00063 } 00064 00065 const std::string& getContextUID(void) const { return supervisorContextUID_; } 00066 const std::string& getSupervisorUID(void) const { return supervisorApplicationUID_; } 00067 const std::string& getSupervisorConfigurationPath(void) const 00068 { 00069 return supervisorConfigurationPath_; 00070 } 00071 00072 00073 00074 protected: 00075 const std::string supervisorClass_; 00076 const std::string supervisorClassNoNamespace_; 00077 00078 private: 00079 static void indicateOtsAlive(const CorePropertySupervisorBase* properties = 0); 00080 00081 std::string supervisorContextUID_; 00082 std::string supervisorApplicationUID_; 00083 std::string supervisorConfigurationPath_; 00084 00085 protected: 00086 // Supervisor Property names 00087 // to access, use CorePropertySupervisorBase::getSupervisorProperty and 00088 // CorePropertySupervisorBase::setSupervisorProperty 00089 static const struct SupervisorProperties 00090 { 00091 SupervisorProperties() 00092 : allSetNames_({&CheckUserLockRequestTypes, 00093 &RequireUserLockRequestTypes, 00094 &AutomatedRequestTypes, 00095 &AllowNoLoginRequestTypes, 00096 &NoXmlWhiteSpaceRequestTypes, 00097 &NonXMLRequestTypes}) 00098 { 00099 } 00100 00101 const std::string UserPermissionsThreshold = "UserPermissionsThreshold"; 00102 const std::string UserGroupsAllowed = "UserGroupsAllowed"; 00103 const std::string UserGroupsDisallowed = "UserGroupsDisallowed"; 00104 00105 const std::string CheckUserLockRequestTypes = "CheckUserLockRequestTypes"; 00106 const std::string RequireUserLockRequestTypes = "RequireUserLockRequestTypes"; 00107 const std::string AutomatedRequestTypes = "AutomatedRequestTypes"; 00108 const std::string AllowNoLoginRequestTypes = "AllowNoLoginRequestTypes"; 00109 00110 const std::string NoXmlWhiteSpaceRequestTypes = "NoXmlWhiteSpaceRequestTypes"; 00111 const std::string NonXMLRequestTypes = "NonXMLRequestTypes"; 00112 00113 const std::set<const std::string*> allSetNames_; 00114 } SUPERVISOR_PROPERTIES; 00115 00116 private: 00117 // property private members 00118 void checkSupervisorPropertySetup(void); 00119 volatile bool propertiesAreSetup_; 00120 00121 // for public access to property map,.. 00122 // use CorePropertySupervisorBase::getSupervisorProperty and 00123 // CorePropertySupervisorBase::setSupervisorProperty 00124 std::map<std::string, std::string> propertyMap_; 00125 struct CoreSupervisorPropertyStruct 00126 { 00127 CoreSupervisorPropertyStruct() 00128 : allSets_({&CheckUserLockRequestTypes, 00129 &RequireUserLockRequestTypes, 00130 &AutomatedRequestTypes, 00131 &AllowNoLoginRequestTypes, 00132 &NoXmlWhiteSpaceRequestTypes, 00133 &NonXMLRequestTypes}) 00134 { 00135 } 00136 00137 std::map<std::string, WebUsers::permissionLevel_t> UserPermissionsThreshold; 00138 std::map<std::string, std::string> UserGroupsAllowed; 00139 std::map<std::string, std::string> UserGroupsDisallowed; 00140 00141 std::set<std::string> CheckUserLockRequestTypes; 00142 std::set<std::string> RequireUserLockRequestTypes; 00143 std::set<std::string> AutomatedRequestTypes; 00144 std::set<std::string> AllowNoLoginRequestTypes; 00145 00146 std::set<std::string> NoXmlWhiteSpaceRequestTypes; 00147 std::set<std::string> NonXMLRequestTypes; 00148 00149 std::set<std::set<std::string>*> allSets_; 00150 } propertyStruct_; 00151 00152 public: 00153 void resetPropertiesAreSetup(void) 00154 { 00155 propertiesAreSetup_ = false; 00156 } // forces reload of properties from configuration 00157 ConfigurationTree getSupervisorTreeNode(void); 00158 00159 void loadUserSupervisorProperties(void); 00160 template<class T> 00161 void setSupervisorProperty(const std::string& propertyName, const T& propertyValue) 00162 { 00163 std::stringstream ss; 00164 ss << propertyValue; 00165 setSupervisorProperty(propertyName, ss.str()); 00166 } 00167 void setSupervisorProperty(const std::string& propertyName, 00168 const std::string& propertyValue); 00169 template<class T> 00170 void addSupervisorProperty(const std::string& propertyName, const T& propertyValue) 00171 { 00172 // prepend new values.. since map/set extraction takes the first value encountered 00173 std::stringstream ss; 00174 ss << propertyValue << " | " << getSupervisorProperty(propertyName); 00175 setSupervisorProperty(propertyName, ss.str()); 00176 } 00177 void addSupervisorProperty(const std::string& propertyName, 00178 const std::string& propertyValue); 00179 template<class T> 00180 T getSupervisorProperty(const std::string& propertyName) 00181 { 00182 // check if need to setup properties 00183 checkSupervisorPropertySetup(); 00184 00185 auto it = propertyMap_.find(propertyName); 00186 if(it == propertyMap_.end()) 00187 { 00188 __SS__ << "Could not find property named " << propertyName << __E__; 00189 __SS_THROW__; 00190 } 00191 return StringMacros::validateValueForDefaultStringDataType<T>(it->second); 00192 } 00193 std::string getSupervisorProperty(const std::string& propertyName); 00194 WebUsers::permissionLevel_t getSupervisorPropertyUserPermissionsThreshold( 00195 const std::string& requestType); 00196 }; 00197 00198 } // namespace ots 00199 00200 #endif