Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

430 lines
8.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. sitesecu.h
  5. Abstract:
  6. Site Security property page definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _SITESECU_H_
  14. #define _SITESECU_H_
  15. #define DEFAULT_GRANTED 0
  16. #define DEFAULT_DENIED 1
  17. class COMDLL CIPAccessDescriptor : public CObjectPlus
  18. /*++
  19. Class Description:
  20. Access description object
  21. Public Interface:
  22. CIPAccessDescriptor : Various overload constructors for the different types
  23. SetValues : Set values, overloaded on a per type basis
  24. DuplicateInList : Check to see if a duplicate entry exists in the list
  25. GrantAccess : Grant or deny access
  26. HasAccess : Query whether the object describes a 'grant' or 'deny'
  27. item
  28. IsSingle : Query whether the object describes a single IP address
  29. IsMultiple : Query whether the object describes a range of ip
  30. addresses
  31. IsDomainName : Query whether the object describes a domain name
  32. QueryIPAddress : Get the object's IP address
  33. QuerySubnetMask : Get the object's subnet mask value
  34. QueryDomainName : Get the object's domain name
  35. operator == : Comparison operator
  36. OrderByAddress : Sorting helper
  37. --*/
  38. {
  39. protected:
  40. //
  41. // Access descriptor types
  42. //
  43. enum AD_TYPE
  44. {
  45. ADT_SINGLE,
  46. ADT_MULTIPLE,
  47. ADT_DOMAIN,
  48. };
  49. //
  50. // Constructors
  51. //
  52. public:
  53. //
  54. // Construct NULL descriptor
  55. //
  56. CIPAccessDescriptor(
  57. IN BOOL fGranted = TRUE
  58. );
  59. //
  60. // Copy Constructor
  61. //
  62. CIPAccessDescriptor(
  63. IN const CIPAccessDescriptor & ac
  64. );
  65. //
  66. // Construct with ip address(ip address/subnet mask) descriptor
  67. // if subnet massk is ffffffff this describes a single ip address
  68. //
  69. CIPAccessDescriptor(
  70. IN BOOL fGranted,
  71. IN DWORD dwIpAddress,
  72. IN DWORD dwSubnetMask = NULL_IP_MASK,
  73. IN BOOL fNetworkByteOrder = FALSE
  74. );
  75. //
  76. // Construct domain name descriptor
  77. //
  78. CIPAccessDescriptor(
  79. IN BOOL fGranted,
  80. IN LPCTSTR lpstrDomain
  81. );
  82. //
  83. // Interface
  84. //
  85. public:
  86. //
  87. // Set ip address/ip range value
  88. //
  89. void SetValues(
  90. IN BOOL fGranted,
  91. IN DWORD dwIpAddress,
  92. IN DWORD dwSubnetMask = NULL_IP_MASK,
  93. BOOL fNetworkByteOrder = FALSE
  94. );
  95. //
  96. // Set domain name
  97. //
  98. void SetValues(
  99. IN BOOL fGranted,
  100. IN LPCTSTR lpstrDomain
  101. );
  102. //
  103. // Check to see if a duplicate exists in the
  104. // list.
  105. //
  106. BOOL DuplicateInList(
  107. IN CObListPlus & oblList
  108. );
  109. //
  110. // Access
  111. //
  112. public:
  113. //
  114. // Access Functions
  115. //
  116. BOOL HasAccess() const;
  117. //
  118. // Grant/deny access
  119. //
  120. void GrantAccess(
  121. IN BOOL fGranted = TRUE
  122. );
  123. //
  124. // TRUE if this item is single ip address
  125. //
  126. BOOL IsSingle() const;
  127. //
  128. // True if this item describes an ip range
  129. //
  130. BOOL IsMultiple() const;
  131. //
  132. // True if this item describes a domain name
  133. //
  134. BOOL IsDomainName() const;
  135. //
  136. // Get the ip address as a DWORD
  137. //
  138. DWORD QueryIPAddress(
  139. IN BOOL fNetworkByteOrder
  140. ) const;
  141. //
  142. // Get the ip address as ip address object
  143. //
  144. CIPAddress QueryIPAddress() const;
  145. //
  146. // Get the subnet mask as a DWORD
  147. //
  148. DWORD QuerySubnetMask(
  149. IN BOOL fNetworkByteOrder
  150. ) const;
  151. //
  152. // Get the subnet mask as an ip address object
  153. //
  154. CIPAddress QuerySubnetMask() const;
  155. //
  156. // Get the domain name
  157. //
  158. LPCTSTR QueryDomainName() const;
  159. public:
  160. //
  161. // Comparison Operator
  162. //
  163. BOOL operator ==(
  164. IN const CIPAccessDescriptor & ac
  165. ) const;
  166. //
  167. // Sorting Helper
  168. //
  169. int OrderByAddress(
  170. IN const CObjectPlus * pobAccess
  171. ) const;
  172. private:
  173. BOOL m_fGranted;
  174. AD_TYPE m_adtType;
  175. CString m_strDomain;
  176. CIPAddress m_iaIPAddress;
  177. CIPAddress m_iaSubnetMask;
  178. };
  179. //
  180. // Helper Functions
  181. //
  182. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  183. //
  184. // Convert an oblist of access descriptors to a blob
  185. //
  186. void COMDLL
  187. BuildIplBlob(
  188. IN CObListPlus & oblAccessList,
  189. IN BOOL fGrantByDefault,
  190. OUT CBlob & blob
  191. );
  192. //
  193. // Reverse the above, build an oblist of access descriptors
  194. // from a blob
  195. //
  196. DWORD COMDLL
  197. BuildIplOblistFromBlob(
  198. IN CBlob & blob,
  199. OUT CObListPlus & oblAccessList,
  200. OUT BOOL & fGrantByDefault
  201. );
  202. class COMDLL CIPAccessDescriptorListBox : public CHeaderListBox
  203. /*++
  204. Class Description:
  205. Listbox of CIPAccessDescriptor objects
  206. Public Interface:
  207. CIPAccessDescriptorListBox : Constructor
  208. GetItem : Get CIPAccessDescriptor item at specified position
  209. in the listbox
  210. AddItem : Add new CIPAccessDescriptor item to the listbox
  211. Initialize : Initialize the listbox
  212. --*/
  213. {
  214. DECLARE_DYNAMIC(CIPAccessDescriptorListBox);
  215. public:
  216. //
  217. // Number of bitmaps
  218. //
  219. static const nBitmaps;
  220. //
  221. // Constructor/Destructor
  222. //
  223. public:
  224. CIPAccessDescriptorListBox(
  225. IN BOOL fDomainsAllowed = FALSE
  226. );
  227. //
  228. // Interface
  229. //
  230. public:
  231. CIPAccessDescriptor * GetItem(
  232. IN UINT nIndex
  233. );
  234. int AddItem(
  235. IN const CIPAccessDescriptor * pItem
  236. );
  237. //
  238. // Return the singly selected item, or NULL
  239. // if 0, or more than one item is selected
  240. //
  241. CIPAccessDescriptor * GetSelectedItem(
  242. OUT int * pnSel = NULL
  243. );
  244. //
  245. // Return next selected listbox item (doesn't matter
  246. // if the listbox is single select or multi-select)
  247. //
  248. CIPAccessDescriptor * GetNextSelectedItem(
  249. IN OUT int * pnStartingIndex
  250. );
  251. virtual BOOL Initialize();
  252. protected:
  253. virtual void DrawItemEx(
  254. IN CRMCListBoxDrawStruct & ds
  255. );
  256. protected:
  257. BOOL m_fDomainsAllowed;
  258. CString m_strGranted;
  259. CString m_strDenied;
  260. CString m_strFormat;
  261. };
  262. //
  263. // Inline Expansion
  264. //
  265. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  266. inline BOOL CIPAccessDescriptor::HasAccess() const
  267. {
  268. return m_fGranted;
  269. }
  270. inline void CIPAccessDescriptor::GrantAccess(
  271. IN BOOL fGranted
  272. )
  273. {
  274. m_fGranted = fGranted;
  275. }
  276. inline BOOL CIPAccessDescriptor::IsSingle() const
  277. {
  278. return m_adtType == ADT_SINGLE;
  279. }
  280. inline BOOL CIPAccessDescriptor::IsMultiple() const
  281. {
  282. return m_adtType == ADT_MULTIPLE;
  283. }
  284. inline BOOL CIPAccessDescriptor::IsDomainName() const
  285. {
  286. return m_adtType == ADT_DOMAIN;
  287. }
  288. inline DWORD CIPAccessDescriptor::QueryIPAddress(
  289. IN BOOL fNetworkByteOrder
  290. ) const
  291. {
  292. ASSERT(!IsDomainName());
  293. return m_iaIPAddress.QueryIPAddress(fNetworkByteOrder);
  294. }
  295. inline CIPAddress CIPAccessDescriptor::QueryIPAddress() const
  296. {
  297. ASSERT(!IsDomainName());
  298. return m_iaIPAddress;
  299. }
  300. inline DWORD CIPAccessDescriptor::QuerySubnetMask(
  301. IN BOOL fNetworkByteOrder
  302. ) const
  303. {
  304. ASSERT(!IsDomainName());
  305. return m_iaSubnetMask.QueryIPAddress(fNetworkByteOrder);
  306. }
  307. inline CIPAddress CIPAccessDescriptor::QuerySubnetMask() const
  308. {
  309. ASSERT(!IsDomainName());
  310. return m_iaSubnetMask;
  311. }
  312. inline LPCTSTR CIPAccessDescriptor::QueryDomainName() const
  313. {
  314. ASSERT(IsDomainName());
  315. return (LPCTSTR)m_strDomain;
  316. }
  317. inline CIPAccessDescriptor * CIPAccessDescriptorListBox::GetItem(
  318. IN UINT nIndex
  319. )
  320. {
  321. return (CIPAccessDescriptor *)GetItemDataPtr(nIndex);
  322. }
  323. inline int CIPAccessDescriptorListBox::AddItem(
  324. IN const CIPAccessDescriptor * pItem
  325. )
  326. {
  327. return AddString((LPCTSTR)pItem);
  328. }
  329. inline CIPAccessDescriptor * CIPAccessDescriptorListBox::GetSelectedItem(
  330. OUT int * pnSel
  331. )
  332. {
  333. return (CIPAccessDescriptor *)CRMCListBox::GetSelectedListItem(pnSel);
  334. }
  335. inline CIPAccessDescriptor * CIPAccessDescriptorListBox::GetNextSelectedItem(
  336. IN OUT int * pnStartingIndex
  337. )
  338. {
  339. return (CIPAccessDescriptor *)CRMCListBox::GetNextSelectedItem(pnStartingIndex);
  340. }
  341. #endif // _SITESECU_H_