permissions.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 __PERMISSIONS_HPP_
  14. #define __PERMISSIONS_HPP_
  15. #ifndef _WIN32
  16. #undef DWORD
  17. typedef unsigned int DWORD;
  18. #endif
  19. #include "ldapconnection.hpp"
  20. #define DEFAULT_OWNER_PERMISSION SecAccess_Full
  21. #define DEFAULT_AUTHENTICATED_USERS_PERMISSION SecAccess_Full
  22. class CSecurityDescriptor : public CInterface, implements IInterface
  23. {
  24. private:
  25. StringAttr m_name;
  26. StringAttr m_relativeBasedn;
  27. MemoryBuffer m_descriptor;
  28. StringAttr m_dn;
  29. StringAttr m_objectClass;
  30. public:
  31. IMPLEMENT_IINTERFACE;
  32. CSecurityDescriptor(const char* name);
  33. const char* getName();
  34. const char* getRelativeBasedn();
  35. MemoryBuffer& getDescriptor();
  36. void setDescriptor(unsigned len, void* buf);
  37. void appendDescriptor(unsigned len, void* buf);
  38. void setDn(const char* dn)
  39. {
  40. m_dn.set(dn);
  41. }
  42. const char* getDn()
  43. {
  44. return m_dn.get();
  45. }
  46. void setObjectClass(const char* oc)
  47. {
  48. m_objectClass.set(oc);
  49. }
  50. const char* getObjectClass()
  51. {
  52. return m_objectClass.get();
  53. }
  54. };
  55. class CMemoryBufferWrapper : public CInterface, implements IInterface
  56. {
  57. private:
  58. MemoryBuffer m_membuf;
  59. public:
  60. IMPLEMENT_IINTERFACE;
  61. MemoryBuffer& getBuffer()
  62. {
  63. return m_membuf;
  64. }
  65. void setBuffer(unsigned len, void* buf)
  66. {
  67. m_membuf.append(len, buf);
  68. }
  69. };
  70. interface IPermissionProcessor : implements IInterface
  71. {
  72. virtual void setLdapClient(ILdapClient* client) = 0;
  73. virtual bool getPermissions(ISecUser& user, IArrayOf<CSecurityDescriptor>& sdlist, IArrayOf<ISecResource>& resources) = 0;
  74. virtual CSecurityDescriptor* createDefaultSD(ISecUser * const user, ISecResource* resource, SecPermissionType ptype) = 0;
  75. virtual CSecurityDescriptor* createDefaultSD(ISecUser * const user, const char* name, SecPermissionType ptype) = 0;
  76. virtual CSecurityDescriptor* createDefaultSD(ISecUser * const user, ISecResource* resource, MemoryBuffer& initial_sd) = 0;
  77. virtual bool retrieveUserInfo(ISecUser& user) = 0;
  78. virtual void getCachedSid(const char* name, MemoryBuffer& sid) = 0;
  79. virtual void cacheSid(const char* name, int len, const void* sidbuf) = 0;
  80. virtual void lookupSid(const char* act_name, MemoryBuffer& act_sid, ACT_TYPE acttype=USER_ACT) = 0;
  81. virtual int sdSegments(CSecurityDescriptor* sd) = 0;
  82. virtual bool getPermissionsArray(CSecurityDescriptor *sd, IArrayOf<CPermission>& permissions) = 0;
  83. virtual CSecurityDescriptor* changePermission(CSecurityDescriptor* initialsd, CPermissionAction& action) = 0;
  84. };
  85. bool toXpath(const char* from, StringBuffer& to);
  86. #endif