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.

354 lines
11 KiB

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