Leaked source code of windows server 2003
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.

371 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2002.
  5. //
  6. // File: cmponent.h
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. // cmponent.h : Declaration of CCertMgrComponent
  12. #ifndef __CMPONENT_H_INCLUDED__
  13. #define __CMPONENT_H_INCLUDED__
  14. #include <cryptui.h>
  15. #include <winsafer.h>
  16. #include "cookie.h" // CCertMgrCookie
  17. #include "certifct.h"
  18. #include "ctl.h"
  19. #include "crl.h"
  20. #include "SaferUtil.h"
  21. #include "SaferEntry.h"
  22. enum {
  23. MIN_MENU_ID = 99,
  24. IDM_USAGE_VIEW = 100,
  25. IDM_STORE_VIEW = 101,
  26. IDM_TASK_RENEW_NEW_KEY,
  27. IDM_TASK_RENEW_SAME_KEY,
  28. IDM_TASK_IMPORT,
  29. IDM_TASK_EXPORT,
  30. IDM_TASK_CTL_EXPORT,
  31. IDM_TASK_EXPORT_STORE,
  32. IDM_OPEN,
  33. IDM_TASK_OPEN,
  34. IDM_TASK_FIND,
  35. IDM_TOP_FIND,
  36. IDM_ENROLL_NEW_CERT,
  37. IDM_ENROLL_NEW_CERT_SAME_KEY,
  38. IDM_ENROLL_NEW_CERT_NEW_KEY,
  39. IDM_CTL_EDIT,
  40. IDM_NEW_CTL,
  41. IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT,
  42. IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT1,
  43. IDM_ADD_DOMAIN_ENCRYPTED_RECOVERY_AGENT2,
  44. IDM_CREATE_DOMAIN_ENCRYPTED_RECOVERY_AGENT,
  45. IDM_EDIT_ACRS,
  46. IDM_TASK_CRL_EXPORT,
  47. IDM_OPTIONS,
  48. IDM_INIT_POLICY,
  49. IDM_DEL_POLICY,
  50. IDM_TOP_CHANGE_COMPUTER,
  51. IDM_TASK_CHANGE_COMPUTER,
  52. IDM_NEW_ACRS,
  53. IDM_SAFER_LEVEL_SET_DEFAULT,
  54. IDM_SAFER_NEW_ENTRY_PATH,
  55. IDM_SAFER_NEW_ENTRY_HASH,
  56. IDM_SAFER_NEW_ENTRY_CERTIFICATE,
  57. IDM_SAFER_NEW_ENTRY_INTERNET_ZONE,
  58. IDM_TASK_PULSEAUTOENROLL,
  59. IDM_TOP_CREATE_NEW_SAFER_POLICY,
  60. IDM_TASK_CREATE_NEW_SAFER_POLICY,
  61. IDM_TOP_DELETE_NEW_SAFER_POLICY,
  62. IDM_TASK_DELETE_NEW_SAFER_POLICY,
  63. MAX_MENU_ID
  64. };
  65. // forward declarations
  66. class CCertMgrDataObject;
  67. class CCertMgrComponentData;
  68. class CCertMgrComponent :
  69. public CComponent,
  70. public IExtendContextMenu,
  71. public ICertificateManager,
  72. public IExtendPropertySheet,
  73. public IResultDataCompareEx,
  74. public PersistStream
  75. {
  76. public:
  77. CCertMgrComponent();
  78. virtual ~CCertMgrComponent();
  79. BEGIN_COM_MAP(CCertMgrComponent)
  80. COM_INTERFACE_ENTRY(ICertificateManager)
  81. COM_INTERFACE_ENTRY(IExtendContextMenu)
  82. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  83. COM_INTERFACE_ENTRY(IResultDataCompareEx)
  84. // security review 2/26/2002 BryanWal ok
  85. COM_INTERFACE_ENTRY(IPersistStream)
  86. COM_INTERFACE_ENTRY_CHAIN(CComponent)
  87. END_COM_MAP()
  88. #if DBG==1
  89. ULONG InternalAddRef()
  90. {
  91. return CComObjectRoot::InternalAddRef();
  92. }
  93. ULONG InternalRelease()
  94. {
  95. return CComObjectRoot::InternalRelease();
  96. }
  97. int dbg_InstID;
  98. #endif // DBG==1
  99. // IExtendContextMenu
  100. public:
  101. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  102. LPCONTEXTMENUCALLBACK pCallbackUnknown,
  103. long *pInsertionAllowed);
  104. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  105. // IResultDataCompareEx
  106. STDMETHOD(Compare)(RDCOMPARE* prdc, int* pnResult);
  107. // STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  108. // IComponent implemented in CComponent
  109. // support methods for IComponent
  110. virtual HRESULT ReleaseAll();
  111. virtual HRESULT OnPropertyChange( LPARAM param );
  112. virtual HRESULT OnViewChange (LPDATAOBJECT pDataObject, LPARAM data, LPARAM hint);
  113. virtual HRESULT Show(CCookie* pcookie, LPARAM arg, HSCOPEITEM hScopeItem, LPDATAOBJECT pDataObject);
  114. virtual HRESULT Show(CCookie* pcookie, LPARAM arg, HSCOPEITEM hScopeItem);
  115. virtual HRESULT OnNotifyAddImages( LPDATAOBJECT pDataObject,
  116. LPIMAGELIST lpImageList,
  117. HSCOPEITEM hSelectedItem );
  118. HRESULT PopulateListbox(CCertMgrCookie* pcookie);
  119. HRESULT RefreshResultPane();
  120. static HRESULT LoadStrings();
  121. HRESULT LoadColumns( CCertMgrCookie* pcookie );
  122. CCertMgrComponentData& QueryComponentDataRef()
  123. {
  124. return (CCertMgrComponentData&)QueryBaseComponentDataRef();
  125. }
  126. public:
  127. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pResultDataItem);
  128. CCertMgrCookie* m_pViewedCookie; // CODEWORK I hate to have to do this...
  129. static const GUID m_ObjectTypeGUIDs[CERTMGR_NUMTYPES];
  130. static const BSTR m_ObjectTypeStrings[CERTMGR_NUMTYPES];
  131. inline CCertMgrCookie* ActiveCookie( CCookie* pBaseCookie )
  132. {
  133. return (CCertMgrCookie*)ActiveBaseCookie( pBaseCookie );
  134. }
  135. // IExtendPropertySheet
  136. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK pCall, LONG_PTR handle, LPDATAOBJECT pDataObject);
  137. STDMETHOD(QueryPagesFor)(LPDATAOBJECT pDataObject);
  138. CTypedPtrList<CPtrList, CCertStore*> m_usageStoreList;
  139. // PersistStream
  140. HRESULT STDMETHODCALLTYPE Load(IStream __RPC_FAR *pStg);
  141. HRESULT STDMETHODCALLTYPE Save(IStream __RPC_FAR *pStgSave, BOOL fSameAsLoad);
  142. private:
  143. bool DoChainDeletion (
  144. CCertMgrCookie* pCookie,
  145. CCertStore** ppEFSStore);
  146. void DeleteCertFromContextList (
  147. CCertMgrCookie *pCookie,
  148. CERT_CONTEXT_LIST& EFSCertContextList);
  149. void GetNotToBeDeletedCertChains (
  150. CERT_CONTEXT_LIST& EFSCertContextList);
  151. void CreateCertChainsFromMultiSelect (
  152. CCertMgrDataObject* pDO,
  153. CCertMgrCookie* pCookie);
  154. void CreateCertChainsFromSingleSelect (
  155. CCertMgrCookie* pCookie);
  156. HRESULT AddLevel (
  157. const CString& szLevel,
  158. DWORD dwLevel,
  159. bool fIsMachine,
  160. PCWSTR pszServerName);
  161. HRESULT AddSaferLevels (
  162. bool bIsComputer,
  163. PCWSTR pszServerName,
  164. HKEY hGroupPolicyKey);
  165. bool m_bShowArchivedCertsStateWhenLogStoresEnumerated;
  166. LPDATAOBJECT m_pPastedDO;
  167. CertificateManagerObjectType m_currResultNodeType;
  168. bool m_bUsageStoresEnumerated;
  169. CString m_szDisplayInfoResult;
  170. UINT* m_ColumnWidths[CERTMGR_NUMTYPES];
  171. int m_nSelectedCertColumn;
  172. int m_nSelectedCRLColumn;
  173. int m_nSelectedCTLColumn;
  174. int m_nSelectedSaferEntryColumn;
  175. CUsageCookie* m_pLastUsageCookie;
  176. LPTOOLBAR m_pToolbar;
  177. CERT_CONTEXT_LIST m_certChainsThatCantBeDeleted;
  178. void SetTextNotAvailable ();
  179. protected:
  180. HRESULT SaferFinishEntryAndAdd (SAFER_ENTRY_TYPE previousType,
  181. PSAFER_IDENTIFICATION_HEADER pCaiCommon,
  182. bool bIsComputer,
  183. long dwLevel,
  184. CSaferEntries* pSaferEntries,
  185. const CString& szPreviousKey);
  186. HRESULT InsertNewSaferEntry (
  187. SAFER_ENTRY_TYPE type,
  188. bool bIsMachine,
  189. PCWSTR pwcszObjectName,
  190. PSAFER_IDENTIFICATION_HEADER pCaiCommon,
  191. DWORD dwLevel,
  192. CSaferEntries* pSaferEntries,
  193. IGPEInformation* pGPEInformation,
  194. CCertificate* pCert,
  195. PCWSTR pszRSOPRegistryKey = 0);
  196. HRESULT EnumSaferCertificates (
  197. bool bIsMachine,
  198. CCertStore& rCertStore,
  199. CSaferEntries* pSaferEntries);
  200. HRESULT SaferEnumerateNonCertEntries (HKEY hGroupPolicyKey, bool bIsComputer);
  201. HRESULT SaferEnumerateRSOPNonCertEntries (
  202. bool bIsComputer,
  203. CSaferEntries* pSaferEntries);
  204. HRESULT SaferEnumerateCertEntries (
  205. bool bIsComputer,
  206. CSaferEntries* pSaferEntries);
  207. HRESULT SaferGetSingleEntry (
  208. bool bIsMachine,
  209. SAFER_LEVEL_HANDLE hLevel,
  210. GUID& rEntryGuid,
  211. DWORD dwLevelID);
  212. HRESULT SaferEnumerateEntriesAtLevel (bool bIsMachine, HKEY hGroupPolicyKey, DWORD dwLevel);
  213. HRESULT SaferEnumerateEntries (bool bIsComputer,
  214. CSaferEntries* pSaferEntries);
  215. HRESULT DisplayCertificateCountByUsage (const CString& usageName, int nCertCnt) const;
  216. bool DeletePrivateKey (CCertStore& rCertStoreDest, CCertStore& rCertStoreSrc);
  217. void CloseAndReleaseUsageStores ();
  218. HRESULT PasteCookie (
  219. CCertMgrCookie* pPastedCookie,
  220. CCertMgrCookie* pTargetCookie,
  221. CCertStore& rCertStore,
  222. SPECIAL_STORE_TYPE storeType,
  223. bool bContainsCerts,
  224. bool bContainsCRLs,
  225. bool bContainsCTLs,
  226. HSCOPEITEM hScopeItem,
  227. bool bRequestConfirmation,
  228. bool bIsMultipleSelect,
  229. LPDATAOBJECT pDataObject);
  230. HRESULT DeleteCookie (
  231. CCertMgrCookie* pCookie,
  232. LPDATAOBJECT pDataObject,
  233. bool bRequestConfirmation,
  234. bool bIsMultipleSelect,
  235. bool bDoCommit);
  236. HRESULT RefreshResultItem (CCertMgrCookie* pCookie);
  237. HRESULT LaunchCommonCertDialog (CCertificate* pCert);
  238. HRESULT LaunchCommonCTLDialog (CCTL* pCTL);
  239. HRESULT LaunchCommonCRLDialog (CCRL* pCRL);
  240. virtual HRESULT OnOpen (LPDATAOBJECT pDataObject);
  241. CCertMgrCookie* ConvertCookie (LPDATAOBJECT pDataObject);
  242. HRESULT OnNotifyCutOrMove (LPARAM arg);
  243. HRESULT SaveWidths (CCertMgrCookie* pCookie);
  244. HRESULT LoadColumnsFromArrays (INT objecttype);
  245. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  246. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, BSTR* ppViewType, long* pViewOptions);
  247. HRESULT CopyPastedCRL (CCRL* pCRL, CCertStore& rCertStore);
  248. HRESULT CopyPastedCTL (CCTL* pCTL, CCertStore& rCertStore);
  249. HRESULT CopyPastedCert (
  250. CCertificate* pCert,
  251. CCertStore& rCertStore,
  252. const SPECIAL_STORE_TYPE storeType,
  253. bool bDeletePrivateKey,
  254. CCertMgrCookie* pTargetCookie,
  255. LPDATAOBJECT pDataObject);
  256. HRESULT OnNotifyQueryPaste (LPDATAOBJECT pDataObject, LPARAM arg, LPARAM param);
  257. HRESULT OnNotifyPaste (LPDATAOBJECT pDataObject, LPARAM arg, LPARAM param);
  258. void DisplayAccessDenied();
  259. STDMETHOD(Notify)(LPDATAOBJECT pDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  260. HRESULT EnumCTLs (CCertStore& rCertStore);
  261. HRESULT EnumerateLogicalStores (CCertMgrCookie& parentCookie);
  262. HRESULT EnumCertsByUsage (CUsageCookie* pUsageCookie);
  263. HRESULT EnumCertificates (CCertStore& rCertStore);
  264. HRESULT DeleteCRLFromResultPane (CCRL * pCRL, LPDATAOBJECT pDataObject);
  265. HRESULT DeleteCertFromResultPane (
  266. CCertificate* pCert,
  267. LPDATAOBJECT pDataObject,
  268. bool bDoCommit);
  269. HRESULT DeleteSaferEntryFromResultPane (
  270. CSaferEntry * pSaferEntry,
  271. LPDATAOBJECT pDataObject,
  272. bool bDoCommit);
  273. virtual HRESULT OnNotifyDelete (LPDATAOBJECT pDataObject);
  274. virtual HRESULT OnNotifyRefresh (LPDATAOBJECT pDataObject);
  275. virtual HRESULT OnNotifySelect( LPDATAOBJECT pDataObject, BOOL fSelected);
  276. virtual HRESULT OnNotifySnapinHelp (LPDATAOBJECT pDataObject);
  277. virtual HRESULT OnNotifyDblClick( LPDATAOBJECT pDataObject );
  278. virtual HRESULT OnNotifyCanPasteOutOfProc (LPBOOL pbCanHandle);
  279. void SetComponentDataConsolePointer (LPCONSOLE m_pConsole);
  280. }; // class CCertMgrComponent
  281. // Enumeration for the icons used
  282. enum
  283. {
  284. iIconDefault = 0,
  285. iIconCertificate,
  286. iIconCTL,
  287. iIconCRL,
  288. iIconAutoCertRequest,
  289. iIconAutoEnroll,
  290. iIconSaferLevel,
  291. iIconDefaultSaferLevel,
  292. iIconSaferHashEntry,
  293. iIconSaferURLEntry,
  294. iIconSaferNameEntry,
  295. iIconSettings,
  296. iIconSaferCertEntry,
  297. iIconLast // Must be last
  298. };
  299. typedef enum _COLNUM_CERTIFICATE {
  300. COLNUM_CERT_SUBJECT = 0,
  301. COLNUM_CERT_ISSUER,
  302. COLNUM_CERT_EXPIRATION_DATE,
  303. COLNUM_CERT_PURPOSE,
  304. COLNUM_CERT_CERT_NAME,
  305. COLNUM_CERT_STATUS,
  306. COLNUM_CERT_TEMPLATE,
  307. CERT_NUM_COLS
  308. } COLNUM_ROOT;
  309. typedef enum _COLNUM_CRL {
  310. COLNUM_CRL_ISSUER = 0,
  311. COLNUM_CRL_EFFECTIVE_DATE,
  312. COLNUM_CRL_NEXT_UPDATE,
  313. CRL_NUM_COLS
  314. } COLNUM_CRL;
  315. typedef enum _COLNUM_CTL {
  316. COLNUM_CTL_ISSUER = 0,
  317. COLNUM_CTL_EFFECTIVE_DATE,
  318. COLNUM_CTL_PURPOSE,
  319. COLNUM_CTL_FRIENDLY_NAME,
  320. CTL_NUM_COLS
  321. } COLNUM_CTL;
  322. typedef enum _COLNUM_SAFER_LEVELS {
  323. COLNUM_SAFER_LEVEL_NAME = 0,
  324. COLNUM_SAFER_LEVEL_DESCRIPTION,
  325. SAFER_LEVELS_NUM_COLS
  326. } COLNUM_SAFER_LEVELS;
  327. typedef enum _COLNUM_SAFER_ENTRIES {
  328. COLNUM_SAFER_ENTRIES_NAME = 0,
  329. COLNUM_SAFER_ENTRIES_TYPE,
  330. COLNUM_SAFER_ENTRIES_LEVEL,
  331. COLNUM_SAFER_ENTRIES_DESCRIPTION,
  332. COLNUM_SAFER_ENTRIES_LAST_MODIFIED_DATE,
  333. SAFER_ENTRIES_NUM_COLS
  334. } COLNUM_SAFER_ENTRIES;
  335. #endif // ~__CMPONENT_H_INCLUDED__