ws_accessService.hpp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 _ESPWIZ_ws_access_HPP__
  14. #define _ESPWIZ_ws_access_HPP__
  15. #pragma warning( disable : 4786)
  16. #include "ldapsecurity.ipp"
  17. #include "ws_access.hpp"
  18. #include "ws_access_esp.ipp"
  19. class Cws_accessSoapBindingEx : public Cws_accessSoapBinding
  20. {
  21. StringBuffer m_authType;
  22. public:
  23. Cws_accessSoapBindingEx(IPropertyTree *cfg, const char *name, const char *process, http_soap_log_level llevel=hsl_none) : Cws_accessSoapBinding(cfg, name, process, llevel)
  24. {
  25. StringBuffer xpath;
  26. xpath.appendf("Software/EspProcess[@name='%s']/Authentication/@method", process);
  27. const char* method = cfg->queryProp(xpath);
  28. if (method && *method)
  29. m_authType.append(method);
  30. }
  31. virtual void getNavigationData(IEspContext &context, IPropertyTree & data)
  32. {
  33. IPropertyTree *folder = ensureNavFolder(data, "Users/Permissions", "Permissions");
  34. if (!stricmp(m_authType.str(), "none") || !stricmp(m_authType.str(), "local"))
  35. {
  36. ensureNavLink(*folder, "Users", "/ws_access/SecurityNotEnabled?form_", "Users");
  37. ensureNavLink(*folder, "Groups", "/ws_access/SecurityNotEnabled?form_", "Groups");
  38. ensureNavLink(*folder, "Permissions", "/ws_access/SecurityNotEnabled?form_", "Permissions");
  39. }
  40. else
  41. {
  42. ensureNavLink(*folder, "Users", "/ws_access/Users", "Users");
  43. ensureNavLink(*folder, "Groups", "/ws_access/Groups", "Groups");
  44. ensureNavLink(*folder, "Permissions", "/ws_access/Permissions", "Permissions");
  45. }
  46. }
  47. virtual int onGetForm(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method);
  48. };
  49. class Cws_accessEx : public Cws_access
  50. {
  51. Owned<IPropertyTree> m_servicecfg;
  52. IArrayOf<IEspDnStruct> m_basedns;
  53. IArrayOf<IEspDnStruct> m_rawbasedns;
  54. SecResourceType str2type(const char* rtstr);
  55. void setBasedns(IEspContext &context);
  56. bool permissionAddInputOnResource(IEspContext &context, IEspPermissionAddRequest &req, IEspPermissionAddResponse &resp);
  57. bool permissionAddInputOnAccount(IEspContext &context, const char* accountName, IEspPermissionAddRequest &req, IEspPermissionAddResponse &resp);
  58. bool getNewFileScopePermissions(ISecManager* secmgr, IEspResourceAddRequest &req, StringBuffer& existingResource, StringArray& newResources);
  59. bool setNewFileScopePermissions(ISecManager* secmgr, IEspResourceAddRequest &req, StringBuffer& existingResource, StringArray& newResources);
  60. bool permissionsReset(CLdapSecManager* ldapsecmgr, const char* basedn, const char* rtype, const char* prefix,
  61. const char* resourceName, ACT_TYPE accountType, const char* accountName,
  62. bool allow_access, bool allow_read, bool allow_write, bool allow_full,
  63. bool deny_access, bool deny_read, bool deny_write, bool deny_full);
  64. void getBaseDNsForAddingPermssionToAccount(CLdapSecManager* secmgr, const char* prefix, const char* accountName,
  65. int accountType, StringArray& basednNames);
  66. int enableDisableScopeScans(IEspContext &context, bool doEnable, StringBuffer &retMsg);
  67. CLdapSecManager* queryLDAPSecurityManager(IEspContext &context);
  68. public:
  69. IMPLEMENT_IINTERFACE;
  70. virtual void init(IPropertyTree *cfg, const char *process, const char *service);
  71. virtual bool onUsers(IEspContext &context, IEspUserRequest &req, IEspUserResponse &resp);
  72. virtual bool onUserEdit(IEspContext &context, IEspUserEditRequest &req, IEspUserEditResponse &resp);
  73. virtual bool onGroups(IEspContext &context, IEspGroupRequest &req, IEspGroupResponse &resp);
  74. virtual bool onAddUser(IEspContext &context, IEspAddUserRequest &req, IEspAddUserResponse &resp);
  75. virtual bool onUserAction(IEspContext &context, IEspUserActionRequest &req, IEspUserActionResponse &resp);
  76. virtual bool onPermissions(IEspContext &context, IEspBasednsRequest &req, IEspBasednsResponse &resp);
  77. virtual bool onResources(IEspContext &context, IEspResourcesRequest &req, IEspResourcesResponse &resp);
  78. virtual bool onResourceAdd(IEspContext &context, IEspResourceAddRequest &req, IEspResourceAddResponse &resp);
  79. virtual bool onResourceAddInput(IEspContext &context, IEspResourceAddInputRequest &req, IEspResourceAddInputResponse &resp);
  80. virtual bool onResourcePermissions(IEspContext &context, IEspResourcePermissionsRequest &req, IEspResourcePermissionsResponse &resp);
  81. virtual bool onPermissionAddInput(IEspContext &context, IEspPermissionAddRequest &req, IEspPermissionAddResponse &resp);
  82. virtual bool onPermissionAction(IEspContext &context, IEspPermissionActionRequest &req, IEspPermissionActionResponse &resp);
  83. virtual bool onUserGroupEditInput(IEspContext &context, IEspUserGroupEditInputRequest &req, IEspUserGroupEditInputResponse &resp);
  84. virtual bool onUserGroupEdit(IEspContext &context, IEspUserGroupEditRequest &req, IEspUserGroupEditResponse &resp);
  85. virtual bool onGroupAdd(IEspContext &context, IEspGroupAddRequest &req, IEspGroupAddResponse &resp);
  86. virtual bool onGroupAction(IEspContext &context, IEspGroupActionRequest &req, IEspGroupActionResponse &resp);
  87. virtual bool onGroupEdit(IEspContext &context, IEspGroupEditRequest &req, IEspGroupEditResponse &resp);
  88. virtual bool onGroupMemberEditInput(IEspContext &context, IEspGroupMemberEditInputRequest &req, IEspGroupMemberEditInputResponse &resp);
  89. virtual bool onGroupMemberEdit(IEspContext &context, IEspGroupMemberEditRequest &req, IEspGroupMemberEditResponse &resp);
  90. virtual bool onResourceDelete(IEspContext &context, IEspResourceDeleteRequest &req, IEspResourceDeleteResponse &resp);
  91. virtual bool onUserResetPass(IEspContext &context, IEspUserResetPassRequest &req, IEspUserResetPassResponse &resp);
  92. virtual bool onUserResetPassInput(IEspContext &context, IEspUserResetPassInputRequest &req, IEspUserResetPassInputResponse &resp);
  93. virtual bool onUserPosix(IEspContext &context, IEspUserPosixRequest &req, IEspUserPosixResponse &resp);
  94. virtual bool onUserPosixInput(IEspContext &context, IEspUserPosixInputRequest &req, IEspUserPosixInputResponse &resp);
  95. virtual bool onUserInfoEdit(IEspContext &context, IEspUserInfoEditRequest &req, IEspUserInfoEditResponse &resp);
  96. virtual bool onUserInfoEditInput(IEspContext &context, IEspUserInfoEditInputRequest &req, IEspUserInfoEditInputResponse &resp);
  97. virtual bool onUserSudoersInput(IEspContext &context, IEspUserSudoersInputRequest &req, IEspUserSudoersInputResponse &resp);
  98. virtual bool onUserSudoers(IEspContext &context, IEspUserSudoersRequest &req, IEspUserSudoersResponse &resp);
  99. virtual bool onAccountPermissions(IEspContext &context, IEspAccountPermissionsRequest &req, IEspAccountPermissionsResponse &resp);
  100. virtual bool onFilePermission(IEspContext &context, IEspFilePermissionRequest &req, IEspFilePermissionResponse &resp);
  101. virtual bool onPermissionsResetInput(IEspContext &context, IEspPermissionsResetInputRequest &req, IEspPermissionsResetInputResponse &resp);
  102. virtual bool onPermissionsReset(IEspContext &context, IEspPermissionsResetRequest &req, IEspPermissionsResetResponse &resp);
  103. virtual bool onUserAccountExport(IEspContext &context, IEspUserAccountExportRequest &req, IEspUserAccountExportResponse &resp);
  104. virtual bool onClearPermissionsCache(IEspContext &context, IEspClearPermissionsCacheRequest &req, IEspClearPermissionsCacheResponse &resp);
  105. virtual bool onQueryScopeScansEnabled(IEspContext &context, IEspQueryScopeScansEnabledRequest &req, IEspQueryScopeScansEnabledResponse &resp);
  106. virtual bool onEnableScopeScans(IEspContext &context, IEspEnableScopeScansRequest &req, IEspEnableScopeScansResponse &resp);
  107. virtual bool onDisableScopeScans(IEspContext &context, IEspDisableScopeScansRequest &req, IEspDisableScopeScansResponse &resp);
  108. };
  109. #endif //_ESPWIZ_ws_access_HPP__