dasess.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef DASESS_HPP
  14. #define DASESS_HPP
  15. #ifndef da_decl
  16. #define da_decl DECL_IMPORT
  17. #endif
  18. #ifdef _WIN32
  19. #pragma warning(disable : 4786)
  20. #endif
  21. #include "dacoven.hpp"
  22. typedef DALI_UID SessionId;
  23. typedef DALI_UID SubscriptionId;
  24. typedef DALI_UID SecurityToken; // currently use 0
  25. #define SESSID_DALI_SERVER ((SessionId)-1) // used with subscribeSession
  26. #define FIXED_HT_SIZE 4096 // elements
  27. #define FIXED_KEY_SIZE 24
  28. // NB: careful not to reorder existing enumerated roles, for backward compatibility reasons
  29. enum DaliClientRole // if changed must update queryRoleName()
  30. {
  31. DCR_Unknown,
  32. DCR_Private,
  33. DCR_Diagnostic,
  34. DCR_ThorSlave,
  35. DCR_ThorMaster,
  36. DCR_Deprecated1, // legacy role
  37. DCR_Deprecated2, // legacy role
  38. DCR_Deprecated3, // legacy role
  39. DCR_EclServer,
  40. DCR_EclAgent,
  41. DCR_DaliServer, // special (self)
  42. DCR_SashaServer,
  43. DCR_Util,
  44. DCR_Dfu,
  45. DCR_DfuServer,
  46. DCR_EspServer,
  47. DCR_WuClient, // GAB etc
  48. DCR_Config,
  49. DCR_Scheduler,
  50. DCR_RoxyMaster,
  51. DCR_RoxySlave,
  52. DCR_Other,
  53. DCR_BackupGen,
  54. DCR_AgentExec,
  55. DCR_EclScheduler,
  56. DCR_Max
  57. };
  58. interface IUserDescriptor: extends serializable
  59. {
  60. virtual StringBuffer &getUserName(StringBuffer &buf)=0;
  61. virtual StringBuffer &getPassword(StringBuffer &buf)=0;
  62. virtual void set(const char *name,const char *password)=0;
  63. virtual void clear()=0;
  64. };
  65. extern da_decl IUserDescriptor *createUserDescriptor();
  66. extern da_decl IUserDescriptor *createUserDescriptor(MemoryBuffer &mb);
  67. const static IUserDescriptor * unknownUser = NULL;//use of this should be avoided
  68. #define UNKNOWN_USER (IUserDescriptor*)unknownUser
  69. interface ISessionNotify: extends IInterface
  70. {
  71. virtual void closed(SessionId id) = 0;
  72. virtual void aborted(SessionId id) = 0;
  73. };
  74. enum SecAccessFlags : int;
  75. interface ISessionManager: extends IInterface
  76. {
  77. virtual SessionId startSession(SecurityToken tok, SessionId parentid =-1) = 0;
  78. virtual void stopSession(SessionId, bool failed) = 0; // session no longer valid after call
  79. virtual bool sessionStopped(SessionId, unsigned timeout) = 0;
  80. virtual SubscriptionId subscribeSession(SessionId id, ISessionNotify *inotify) = 0;
  81. virtual void unsubscribeSession(SubscriptionId id) = 0; // called from separate thread
  82. virtual SessionId lookupProcessSession(INode *node=NULL) = 0; // no parameters - get my session ID
  83. virtual INode *getProcessSessionNode(SessionId id) =0; // if session not running returns null
  84. virtual StringBuffer &getClientProcessList(StringBuffer &buf)=0; // for diagnostics
  85. virtual StringBuffer &getClientProcessEndpoint(SessionId id,StringBuffer &buf)=0; // for diagnostics
  86. virtual unsigned queryClientCount() = 0; // for SNMP
  87. virtual SecAccessFlags getPermissionsLDAP(const char *key,const char *obj,IUserDescriptor *udesc,unsigned auditflags, int *err=NULL)=0;
  88. virtual bool checkScopeScansLDAP()=0;
  89. virtual unsigned getLDAPflags()=0;
  90. virtual void setLDAPflags(unsigned flags)=0;
  91. virtual bool clearPermissionsCache(IUserDescriptor *udesc)=0;
  92. virtual bool queryScopeScansEnabled(IUserDescriptor *udesc, int * err, StringBuffer &retMsg)=0;
  93. virtual bool enableScopeScans(IUserDescriptor *udesc, bool enable, int * err, StringBuffer &retMsg)=0;
  94. };
  95. // the following are getPermissionsLDAP input flags for audit reporting
  96. #define DALI_LDAP_AUDIT_REPORT (1) // required to check
  97. #define DALI_LDAP_READ_WANTED (2)
  98. #define DALI_LDAP_WRITE_WANTED (4)
  99. #define HASREADPERMISSION(p) (((p) & (NewSecAccess_Access | NewSecAccess_Read)) == (NewSecAccess_Access | NewSecAccess_Read))
  100. #define HASWRITEPERMISSION(p) (((p) & (NewSecAccess_Access | NewSecAccess_Write)) == (NewSecAccess_Access | NewSecAccess_Write))
  101. extern da_decl ISessionManager &querySessionManager();
  102. #define myProcessSession() (querySessionManager().lookupProcessSession())
  103. interface IMessageWrapper
  104. {
  105. public:
  106. virtual void serializeReq(CMessageBuffer &mb) = 0;
  107. virtual void deserializeReq(CMessageBuffer &mb) = 0;
  108. };
  109. // for server use
  110. interface IDaliServer;
  111. interface IPropertyTree;
  112. interface IFile;
  113. interface IDaliLdapConnection;
  114. interface IDaliClientAuthConnection;
  115. extern da_decl IDaliServer *createDaliSessionServer(); // called for coven members
  116. extern da_decl void setLDAPconnection(IDaliLdapConnection *ldapconn); // called for coven members
  117. extern da_decl void setClientAuth(IDaliClientAuthConnection *authconn); // called for coven members
  118. #endif