authmap.ipp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 _AUTHMAP_IPP__
  14. #define _AUTHMAP_IPP__
  15. #include "jliball.hpp"
  16. #include "seclib.hpp"
  17. unsigned str2perm(const char* permstr);
  18. class CSecResourceListHolder : public CInterface, implements IInterface
  19. {
  20. private:
  21. ISecResourceList* m_list;
  22. public:
  23. IMPLEMENT_IINTERFACE;
  24. CSecResourceListHolder(ISecResourceList* list) : m_list(list) {}
  25. ISecResourceList* list() {return m_list;}
  26. };
  27. // Here we're using 2 arrays instead of a hashmap due to the need
  28. // to find the best matching path prefix.
  29. class CAuthMap : public CInterface, implements IAuthMap
  30. {
  31. private:
  32. StringArray m_paths;
  33. IArrayOf<CSecResourceListHolder> m_resourcelists;
  34. ISecManager* m_secmgr;
  35. public:
  36. IMPLEMENT_IINTERFACE;
  37. CAuthMap(ISecManager* secmgr) {m_secmgr = secmgr;};
  38. int add(const char* path, ISecResourceList* resourceList);
  39. bool shouldAuth(const char* path);
  40. ISecResourceList* queryResourceList(const char* path);
  41. ISecResourceList* getResourceList(const char* path);
  42. bool addToBackend();
  43. };
  44. #endif