otsdaq  v2_04_01
RemoteWebUsers.h
1 #ifndef _ots_Utilities_RemoteWebUsers_h
2 #define _ots_Utilities_RemoteWebUsers_h
3 
4 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h" //for xdaq::ApplicationDescriptor
5 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
6 
7 #include <iostream>
8 #include <string>
9 
10 #include "otsdaq-core/TableCore/TableGroupKey.h" //for TableGroupKey
11 
12 namespace ots
13 {
14 class AllSupervisorInfo;
15 class HttpXmlDocument;
16 
17 // RemoteWebUsers
18 // This class provides the functionality for client supervisors to check with the Gateway
19 // Supervisor to verify user access. It also provides the functionality for client
20 // supervisors to retreive user info.
22 {
23  public:
24  RemoteWebUsers(xdaq::Application* application);
25 
26  // for external supervisors to check with Supervisor for login
27  // if false, user request handling code should just return.. out is handled on false;
28  // on true, out is untouched
29  bool xmlRequestToGateway(cgicc::Cgicc& cgi,
30  std::ostringstream* out,
31  HttpXmlDocument* xmldoc,
32  const AllSupervisorInfo& allSupervisorInfo,
33  WebUsers::RequestUserInfo& userInfo);
34 
35  // uint8_t* userPermissions = 0,
36  // const uint8_t permissionsThreshold = 1,
37  // const bool allowNoUser = false,
38  // const std::set<std::string>& groupsAllowed = {},
39  // const std::set<std::string>& groupsDisallowed = {},
40  // const bool refreshCookie = true,
41  // const bool checkLock = false,
42  // const bool lockRequired = false,
43  // std::string* userWithLock = 0,
44  // std::string* username = 0,
45  // std::string* displayName = 0,
46  // std::string* userGroups = 0,
47  // uint64_t* activeSessionIndex = 0);
48 
49  std::string getActiveUserList(
50  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor);
51  void sendSystemMessage(
52  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor,
53  const std::string& toUser,
54  const std::string& msg);
55  void makeSystemLogbookEntry(
56  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor,
57  const std::string& entryText);
58  std::pair<std::string /*group name*/, TableGroupKey> getLastConfigGroup(
59  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor,
60  const std::string& actionOfLastGroup,
61  std::string& actionTimeString); // actionOfLastGroup = "Configured" or "Started",
62  // for example
63 
64  private:
65  bool cookieCodeIsActiveForRequest(
66  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor,
67  std::string& cookieCode,
68  uint8_t* userPermissions = 0,
69  std::string ip = "0",
70  bool refreshCookie = true,
71  std::string* userWithLock = 0);
72 
73  bool getUserInfoForCookie(
74  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* supervisorDescriptor,
75  std::string& cookieCode,
76  std::string* userName,
77  std::string* displayName = 0,
78  uint64_t* activeSessionIndex = 0);
79 
80  //"Active User List" associations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81  std::string ActiveUserList_;
82  time_t ActiveUserLastUpdateTime_;
83  enum
84  {
85  ACTIVE_USERS_UPDATE_THRESHOLD =
86  10, // 10 seconds, min amount of time between Supervisor requests
87  };
88 
89  std::string tmpUserWithLock_, tmpUserGroups_, tmpUsername_;
90  // uint8_t tmpUserPermissions_;
91 };
92 
93 } // namespace ots
94 
95 #endif
bool xmlRequestToGateway(cgicc::Cgicc &cgi, std::ostringstream *out, HttpXmlDocument *xmldoc, const AllSupervisorInfo &allSupervisorInfo, WebUsers::RequestUserInfo &userInfo)