Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef AccessRightsManagerH
00033 #define AccessRightsManagerH
00034
00035 #include <zeusbase/System/SingleLinkedList.hpp>
00036 #include <zeusbase/System/String.h>
00037
00038 #if defined(ENABLE_WIN32_BINDING)
00039 #include <Accctrl.h>
00040 #include <Windows.h>
00041
00042 #elif defined(ENABLE_LINUX_BINDING)
00043 #define ACCESS_MODE Int
00044
00045 #endif
00046
00047
00048 BEGIN_NAMESPACE_Zeus
00049
00050
00051
00053
00054 zeusbase_class TAccessRightsManager
00055 {
00056 public:
00058 enum ERightType
00059 {
00060 etRightTypeAllowed,
00061 etRightTypeDenied,
00062 etAllRightTypes
00063 };
00064
00066 static Retval setRightsOnFileSystemItem(const TString& strFileSystemItem,
00067 bool bItemIsFolderNotFile,
00068 const TSingleLinkedList<TString>& rlstUserGroups,
00069 bool bReadAccess, bool bWriteAccess,
00070 bool bExecuteAccess, bool bAllAccess,
00071 bool bAccessNotDenied);
00072
00073 #ifdef ENABLE_WIN32_BINDING
00074
00075 static Retval readDACLFromFileSystemItem(const TString& strFileSystemItem,
00076 bool bItemIsFolderNotFile, ACL*& rpDACL);
00077
00079 static Retval setRightsInDACL(ACL*& rpDACL,
00080 const TSingleLinkedList<TString>& rlstUserGroups,
00081 bool bReadAccess, bool bWriteAccess,
00082 bool bExecuteAccess, bool bAllAccess,
00083 bool bAccessNotDenied);
00084 #endif
00085
00087 static Retval removeUserGroupsFromFileSystemItem(const TString& strFileSystemItem,
00088 bool bItemIsFolderNotFile,
00089 const TSingleLinkedList<TString>& rlstUserGroups,
00090 ERightType eRightType);
00091
00093 static Retval removeUserGroupsFromFolderRecursively(const TString& strFolder,
00094 const TSingleLinkedList<TString>& rlstUserGroups,
00095 ERightType eRightType);
00096
00097 #ifdef ENABLE_WIN32_BINDING
00098
00099 static Retval removeUserGroupsFromDACL(ACL& rDACL,
00100 const TSingleLinkedList<TString>& rlstUserGroups,
00101 ERightType eRightType);
00102
00104 static Retval clearDACLOnFileSystemItem(const TString& strFileSystemItem,
00105 bool bItemIsFolderNotFile);
00106
00108 static Retval clearDACLOnFolderRecursively(const TString& strFolder);
00109
00111 static Retval applyDACLOnFileSystemItem(const ACL& rDACL,
00112 const TString& strFileSystemItem,
00113 bool bItemIsFolderNotFile);
00114 #endif
00115
00116 private:
00118 inline TAccessRightsManager() { }
00119
00121 static bool createFileSystemItemIfNotExisting(const TString& strFileSystemItem,
00122 bool bItemIsFolderNotFile);
00123
00124 #ifdef ENABLE_WIN32_BINDING
00125
00126 static Retval readDACLOnExistingFileSystemItem(const TString& strFileSystemItem, ACL*& rpDACL);
00127
00129 static Retval clearDACLOnExistingFileSystemItem(const TString& strFileSystemItem);
00130
00132 static Retval applyDACLOnExistingFileSystemItem(const ACL& rDACL,
00133 const TString& strFileSystemItem);
00134
00136 static ACCESS_MASK createAccessMask(bool bReadAccess, bool bWriteAccess,
00137 bool bExecuteAccess, bool bAllAccess);
00138
00140 static bool getUserGroupFromSID(SID* pSID, TString& rstrUserGroup);
00141 #endif
00142 };
00143
00144
00145 END_NAMESPACE_Zeus
00146
00147 #endif
00148