defaultsecuritymanager.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 DEFAULTSECURITY_INCL
  14. #define DEFAULTSECURITY_INCL
  15. #include "basesecurity.hpp"
  16. class CDefaultSecurityManager : public CBaseSecurityManager
  17. {
  18. protected:
  19. public:
  20. CDefaultSecurityManager(const char *serviceName, const char *config);
  21. CDefaultSecurityManager(const char *serviceName, IPropertyTree *config);
  22. virtual ~CDefaultSecurityManager(){};
  23. virtual bool dbauthenticate(ISecUser& User, StringBuffer& SQLQuery){return true;}
  24. virtual bool dbValidateResource(ISecResource& res,int usernum,const char* realm)
  25. {
  26. CSecurityResource * tmpResource = (CSecurityResource*)(&res);
  27. if(tmpResource)
  28. tmpResource->setAccessFlags(SecAccess_Full);
  29. return true;
  30. }
  31. virtual int getAccessFlagsEx(SecResourceType rtype, ISecUser& sec_user, const char* resourcename)
  32. {
  33. return SecAccess_Full;
  34. }
  35. virtual int authorizeFileScope(ISecUser & user, const char * filescope)
  36. {
  37. return SecAccess_Full;
  38. }
  39. virtual bool authorizeFileScope(ISecUser & user, ISecResourceList * resources)
  40. {
  41. if(resources)
  42. {
  43. int cnt = resources->count();
  44. for(int i = 0; i < cnt; i++)
  45. {
  46. ISecResource* r = resources->queryResource(i);
  47. if(r)
  48. r->setAccessFlags(SecAccess_Full);
  49. }
  50. }
  51. return true;
  52. }
  53. virtual int authorizeWorkunitScope(ISecUser & user, const char * filescope)
  54. {
  55. return SecAccess_Full;
  56. }
  57. virtual bool authorizeWorkunitScope(ISecUser & user, ISecResourceList * resources)
  58. {
  59. if(resources)
  60. {
  61. int cnt = resources->count();
  62. for(int i = 0; i < cnt; i++)
  63. {
  64. ISecResource* r = resources->queryResource(i);
  65. if(r)
  66. r->setAccessFlags(SecAccess_Full);
  67. }
  68. }
  69. return true;
  70. }
  71. virtual bool createUserScopes() { return false; }
  72. };
  73. class CLocalSecurityManager : public CDefaultSecurityManager
  74. {
  75. public:
  76. CLocalSecurityManager(const char *serviceName, const char *config);
  77. CLocalSecurityManager(const char *serviceName, IPropertyTree *config);
  78. virtual ~CLocalSecurityManager();
  79. IAuthMap * createAuthMap(IPropertyTree * authconfig);
  80. protected:
  81. virtual bool IsPasswordValid(ISecUser& sec_user);
  82. };
  83. #endif // DEFAULTSECURITY_INCL
  84. //end