otsdaq  v2_05_02_indev
RemoteWebUsers.h
1 #ifndef _ots_Utilities_RemoteWebUsers_h
2 #define _ots_Utilities_RemoteWebUsers_h
3 
4 #include "otsdaq/SOAPUtilities/SOAPMessenger.h" //for xdaq::ApplicationDescriptor
5 #include "otsdaq/WebUsersUtilities/WebUsers.h"
6 
7 #include <iostream>
8 #include <string>
9 
10 #include "otsdaq/TableCore/TableGroupKey.h" //for TableGroupKey
11 
12 // clang-format off
13 namespace ots
14 {
15 class AllSupervisorInfo;
16 class HttpXmlDocument;
17 
18 // RemoteWebUsers
19 // This class provides the functionality for client supervisors to check with the Gateway
20 // Supervisor to verify user access. It also provides the functionality for client
21 // supervisors to retreive user info.
23 {
24  public:
25  RemoteWebUsers(xdaq::Application* application, XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisorDescriptor);
26 
27 
28 
29  // const_cast away the const
30  // so that this line is compatible with slf6 and slf7 versions of xdaq
31  // where they changed to XDAQ_CONST_CALL xdaq::ApplicationDescriptor* in slf7
32  //
33  // XDAQ_CONST_CALL is defined in "otsdaq/Macros/CoutMacros.h"
34  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* gatewaySupervisorDescriptor_;
35 
36  // for external supervisors to check with Supervisor for login
37  // if false, user request handling code should just return.. out is handled on false;
38  // on true, out is untouched
39  bool xmlRequestToGateway(cgicc::Cgicc& cgi, std::ostringstream* out, HttpXmlDocument* xmldoc, const AllSupervisorInfo& allSupervisorInfo, WebUsers::RequestUserInfo& userInfo);
40 
41  // uint8_t* userPermissions = 0,
42  // const uint8_t permissionsThreshold = 1,
43  // const bool allowNoUser = false,
44  // const std::set<std::string>& groupsAllowed = {},
45  // const std::set<std::string>& groupsDisallowed = {},
46  // const bool refreshCookie = true,
47  // const bool checkLock = false,
48  // const bool lockRequired = false,
49  // std::string* userWithLock = 0,
50  // std::string* username = 0,
51  // std::string* displayName = 0,
52  // std::string* userGroups = 0,
53  // uint64_t* activeSessionIndex = 0);
54 
55  std::string getActiveUserList (void);
56  void sendSystemMessage (const std::string& toUser, const std::string& message, bool doEmail = false);
57  void sendSystemMessage (const std::string& toUser, const std::string& subject, const std::string& message, bool doEmail = false);
58  void makeSystemLogbookEntry (const std::string& entryText);
59  std::pair<std::string /*group name*/, TableGroupKey>
60  getLastTableGroup (const std::string& actionOfLastGroup, std::string& returnedActionTimeString); // actionOfLastGroup = "Configured" or "Started", for example
61 
62  private:
63 
64  //"Active User List" associations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65  std::string ActiveUserList_;
66  time_t ActiveUserLastUpdateTime_;
67  enum
68  {
69  ACTIVE_USERS_UPDATE_THRESHOLD = 2, // seconds, min amount of time between Supervisor requests
70  };
71 
72  //std::string tmpUserWithLock_, tmpUserGroups_, tmpUsername_;
73 
74 };
75 // clang-format on
76 } // namespace ots
77 
78 #endif