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.

395 lines
13 KiB

  1. // CertWizCtl.cpp : Implementation of the CCertWizCtrl ActiveX Control class.
  2. #include "stdafx.h"
  3. #include "CertWiz.h"
  4. #include "CertWizCtl.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. IMPLEMENT_DYNCREATE(CCertWizCtrl, COleControl)
  11. /////////////////////////////////////////////////////////////////////////////
  12. // Message map
  13. BEGIN_MESSAGE_MAP(CCertWizCtrl, COleControl)
  14. //{{AFX_MSG_MAP(CCertWizCtrl)
  15. // NOTE - ClassWizard will add and remove message map entries
  16. // DO NOT EDIT what you see in these blocks of generated code !
  17. //}}AFX_MSG_MAP
  18. ON_MESSAGE(OCM_COMMAND, OnOcmCommand)
  19. ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
  20. END_MESSAGE_MAP()
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Dispatch map
  23. BEGIN_DISPATCH_MAP(CCertWizCtrl, COleControl)
  24. //{{AFX_DISPATCH_MAP(CCertWizCtrl)
  25. DISP_FUNCTION(CCertWizCtrl, "SetMachineName", SetMachineName, VT_EMPTY, VTS_BSTR)
  26. DISP_FUNCTION(CCertWizCtrl, "SetServerInstance", SetServerInstance, VT_EMPTY, VTS_BSTR)
  27. DISP_STOCKFUNC_DOCLICK()
  28. //}}AFX_DISPATCH_MAP
  29. END_DISPATCH_MAP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Event map
  32. BEGIN_EVENT_MAP(CCertWizCtrl, COleControl)
  33. //{{AFX_EVENT_MAP(CCertWizCtrl)
  34. //}}AFX_EVENT_MAP
  35. END_EVENT_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Property pages
  38. // TODO: Add more property pages as needed. Remember to increase the count!
  39. //BEGIN_PROPPAGEIDS(CCertWizCtrl, 1)
  40. // PROPPAGEID(CCertWizPropPage::guid)
  41. //END_PROPPAGEIDS(CCertWizCtrl)
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Initialize class factory and guid
  44. IMPLEMENT_OLECREATE_EX(CCertWizCtrl, "CERTWIZ.CertWizCtrl.1",
  45. 0xd4be8632, 0xc85, 0x11d2, 0x91, 0xb1, 0, 0xc0, 0x4f, 0x8c, 0x87, 0x61)
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Type library ID and version
  48. IMPLEMENT_OLETYPELIB(CCertWizCtrl, _tlid, _wVerMajor, _wVerMinor)
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Interface IDs
  51. const IID BASED_CODE IID_DCertWiz =
  52. { 0xd4be8630, 0xc85, 0x11d2, { 0x91, 0xb1, 0, 0xc0, 0x4f, 0x8c, 0x87, 0x61 } };
  53. const IID BASED_CODE IID_DCertWizEvents =
  54. { 0xd4be8631, 0xc85, 0x11d2, { 0x91, 0xb1, 0, 0xc0, 0x4f, 0x8c, 0x87, 0x61 } };
  55. /////////////////////////////////////////////////////////////////////////////
  56. // Control type information
  57. static const DWORD BASED_CODE _dwCertWizOleMisc =
  58. OLEMISC_INVISIBLEATRUNTIME |
  59. OLEMISC_SETCLIENTSITEFIRST |
  60. OLEMISC_INSIDEOUT |
  61. OLEMISC_CANTLINKINSIDE |
  62. OLEMISC_RECOMPOSEONRESIZE;
  63. IMPLEMENT_OLECTLTYPE(CCertWizCtrl, IDS_CERTWIZ, _dwCertWizOleMisc)
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CCertWizCtrl::CCertWizCtrlFactory::UpdateRegistry -
  66. // Adds or removes system registry entries for CCertWizCtrl
  67. BOOL CCertWizCtrl::CCertWizCtrlFactory::UpdateRegistry(BOOL bRegister)
  68. {
  69. // TODO: Verify that your control follows apartment-model threading rules.
  70. // Refer to MFC TechNote 64 for more information.
  71. // If your control does not conform to the apartment-model rules, then
  72. // you must modify the code below, changing the 6th parameter from
  73. // afxRegApartmentThreading to 0.
  74. if (bRegister)
  75. return AfxOleRegisterControlClass(
  76. AfxGetInstanceHandle(),
  77. m_clsid,
  78. m_lpszProgID,
  79. IDS_CERTWIZ,
  80. IDB_CERTWIZ,
  81. afxRegApartmentThreading,
  82. _dwCertWizOleMisc,
  83. _tlid,
  84. _wVerMajor,
  85. _wVerMinor);
  86. else
  87. return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CCertWizCtrl::CCertWizCtrl - Constructor
  91. CCertWizCtrl::CCertWizCtrl()
  92. {
  93. InitializeIIDs(&IID_DCertWiz, &IID_DCertWizEvents);
  94. // TODO: Initialize your control's instance data here.
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CCertWizCtrl::~CCertWizCtrl - Destructor
  98. CCertWizCtrl::~CCertWizCtrl()
  99. {
  100. // TODO: Cleanup your control's instance data here.
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CCertWizCtrl::OnDraw - Drawing function
  104. void CCertWizCtrl::OnDraw(
  105. CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
  106. {
  107. DoSuperclassPaint(pdc, rcBounds);
  108. }
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CCertWizCtrl::DoPropExchange - Persistence support
  111. void CCertWizCtrl::DoPropExchange(CPropExchange* pPX)
  112. {
  113. ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
  114. COleControl::DoPropExchange(pPX);
  115. // TODO: Call PX_ functions for each persistent custom property.
  116. }
  117. /////////////////////////////////////////////////////////////////////////////
  118. // CCertWizCtrl::GetControlFlags -
  119. // Flags to customize MFC's implementation of ActiveX controls.
  120. //
  121. // For information on using these flags, please see MFC technical note
  122. // #nnn, "Optimizing an ActiveX Control".
  123. DWORD CCertWizCtrl::GetControlFlags()
  124. {
  125. DWORD dwFlags = COleControl::GetControlFlags();
  126. // The control can activate without creating a window.
  127. // TODO: when writing the control's message handlers, avoid using
  128. // the m_hWnd member variable without first checking that its
  129. // value is non-NULL.
  130. dwFlags |= windowlessActivate;
  131. return dwFlags;
  132. }
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CCertWizCtrl::OnResetState - Reset control to default state
  135. void CCertWizCtrl::OnResetState()
  136. {
  137. COleControl::OnResetState(); // Resets defaults found in DoPropExchange
  138. // TODO: Reset any other control state here.
  139. }
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CCertWizCtrl::PreCreateWindow - Modify parameters for CreateWindowEx
  142. BOOL CCertWizCtrl::PreCreateWindow(CREATESTRUCT& cs)
  143. {
  144. cs.lpszClass = _T("BUTTON");
  145. return COleControl::PreCreateWindow(cs);
  146. }
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CCertWizCtrl::IsSubclassedControl - This is a subclassed control
  149. BOOL CCertWizCtrl::IsSubclassedControl()
  150. {
  151. return TRUE;
  152. }
  153. /////////////////////////////////////////////////////////////////////////////
  154. // CCertWizCtrl::OnOcmCommand - Handle command messages
  155. LRESULT CCertWizCtrl::OnOcmCommand(WPARAM wParam, LPARAM lParam)
  156. {
  157. #ifdef _WIN32
  158. WORD wNotifyCode = HIWORD(wParam);
  159. #else
  160. WORD wNotifyCode = HIWORD(lParam);
  161. #endif
  162. // TODO: Switch on wNotifyCode here.
  163. return 0;
  164. }
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CCertWizCtrl message handlers
  167. #include "WelcomePage.h"
  168. #include "FinalPages.h"
  169. #include "CertContentsPages.h"
  170. #include "GetWhatPage.h"
  171. #include "ChooseCAType.h"
  172. #include "SecuritySettingsPage.h"
  173. #include "ChooseCspPage.h"
  174. #include "OrgInfoPage.h"
  175. #include "SiteNamePage.h"
  176. #include "GeoInfoPage.h"
  177. #include "ChooseFileName.h"
  178. #include "ChooseOnlinePage.h"
  179. #include "WhatToDoPendingPage.h"
  180. #include "ManageCertPage.h"
  181. #include "ChooseCertPage.h"
  182. #include "KeyPasswordPage.h"
  183. #include "Certificat.h"
  184. #include "CopyMoveCertRemotePage.h"
  185. #include "ChooseServerPages.h"
  186. #include "ChooseServerSitePages.h"
  187. void CCertWizCtrl::OnClick(USHORT iButton)
  188. {
  189. CIISWizardSheet propsheet(IDB_WIZ_LEFT, IDB_WIZ_TOP);
  190. CCertificate * cert = new CCertificate;
  191. ASSERT(!m_InstanceName.IsEmpty());
  192. cert->m_WebSiteInstanceName = m_InstanceName;
  193. cert->m_MachineName = m_MachineName;
  194. VERIFY(cert->Init());
  195. CWelcomePage welcome_page(cert);
  196. CGetWhatPage get_what_page(cert);
  197. CChooseCAType choose_ca_page(cert);
  198. CSecuritySettingsPage security_settings_page(cert);
  199. CChooseCspPage csp_page(cert);
  200. COrgInfoPage org_info_page(cert);
  201. CSiteNamePage site_name_page(cert);
  202. CGeoInfoPage geo_info_page(cert);
  203. CChooseReqFile choose_reqfile_name(cert);
  204. CChooseReqFileRenew choose_reqfile_name_renew(cert);
  205. CChooseRespFile choose_respfile_name(cert);
  206. CChooseKeyFile choose_keyfile_name(cert);
  207. CRequestToFilePage check_request(cert);
  208. CRequestToFilePageRenew check_request_renew(cert);
  209. CFinalToFilePage final_tofile_page(&cert->m_hResult, cert);
  210. CChooseOnlinePage choose_online(cert);
  211. COnlineRequestSubmit online_request_dump(cert);
  212. CWhatToDoPendingPage what_pending(cert);
  213. CInstallRespPage install_resp(cert);
  214. CManageCertPage manage_cert(cert);
  215. CFinalInstalledPage final_install(&cert->m_hResult, cert);
  216. CRemoveCertPage remove_cert(cert);
  217. CFinalRemovePage final_remove(&cert->m_hResult, cert);
  218. CReplaceCertPage replace_cert(cert);
  219. CFinalReplacedPage final_replace(&cert->m_hResult, cert);
  220. CChooseCertPage choose_cert(cert);
  221. CInstallCertPage install_cert(cert);
  222. CRequestCancelPage cancel_request(cert);
  223. CFinalCancelPage final_cancel(&cert->m_hResult, cert);
  224. CKeyPasswordPage key_password_page(cert);
  225. CInstallKeyPage install_key(cert);
  226. // new stuff for iis6
  227. CCopyMoveCertFromRemotePage copy_move_from_cert_remote_page(cert);
  228. CCopyMoveCertToRemotePage copy_move_to_cert_remote_page(cert);
  229. CChooseImportPFXFile choose_import_pfx_file_name(cert);
  230. CChooseExportPFXFile choose_export_pfx_file_name(cert);
  231. CImportPFXPasswordPage import_pfx_password_name(cert);
  232. CExportPFXPasswordPage export_pfx_password_name(cert);
  233. CInstallImportPFXPage install_import_pfx_key(cert);
  234. CInstallExportPFXPage install_export_pfx_key(cert);
  235. CFinalInstalledImportPFXPage final_import_pfx(&cert->m_hResult, cert);
  236. CFinalInstalledExportPFXPage final_export_pfx(&cert->m_hResult, cert);
  237. CChooseServerPages choose_server_name(cert);
  238. CChooseServerSitePages choose_server_site_name(cert);
  239. CChooseServerPagesTo choose_server_name_to(cert);
  240. CChooseServerSitePagesTo choose_server_site_name_to(cert);
  241. CInstallCopyFromRemotePage install_copy_from_remote(cert);
  242. CInstallMoveFromRemotePage install_move_from_remote(cert);
  243. CInstallCopyToRemotePage install_copy_to_remote(cert);
  244. CInstallMoveToRemotePage install_move_to_remote(cert);
  245. CFinalInstalledCopyFromRemotePage final_copy_from_remote(&cert->m_hResult, cert);
  246. CFinalInstalledMoveFromRemotePage final_move_from_remote(&cert->m_hResult, cert);
  247. CFinalInstalledCopyToRemotePage final_copy_to_remote(&cert->m_hResult, cert);
  248. CFinalInstalledMoveToRemotePage final_move_to_remote(&cert->m_hResult, cert);
  249. propsheet.AddPage(&welcome_page);
  250. propsheet.AddPage(&get_what_page);
  251. propsheet.AddPage(&choose_ca_page);
  252. propsheet.AddPage(&security_settings_page);
  253. propsheet.AddPage(&csp_page);
  254. propsheet.AddPage(&org_info_page);
  255. propsheet.AddPage(&site_name_page);
  256. propsheet.AddPage(&geo_info_page);
  257. propsheet.AddPage(&choose_reqfile_name);
  258. propsheet.AddPage(&choose_reqfile_name_renew);
  259. propsheet.AddPage(&choose_respfile_name);
  260. propsheet.AddPage(&choose_keyfile_name);
  261. propsheet.AddPage(&check_request);
  262. propsheet.AddPage(&check_request_renew);
  263. propsheet.AddPage(&final_tofile_page);
  264. propsheet.AddPage(&choose_online);
  265. propsheet.AddPage(&online_request_dump);
  266. propsheet.AddPage(&what_pending);
  267. propsheet.AddPage(&install_resp);
  268. propsheet.AddPage(&manage_cert);
  269. propsheet.AddPage(&final_install);
  270. propsheet.AddPage(&remove_cert);
  271. propsheet.AddPage(&final_remove);
  272. propsheet.AddPage(&choose_cert);
  273. propsheet.AddPage(&replace_cert);
  274. propsheet.AddPage(&final_replace);
  275. propsheet.AddPage(&install_cert);
  276. propsheet.AddPage(&cancel_request);
  277. propsheet.AddPage(&final_cancel);
  278. propsheet.AddPage(&key_password_page);
  279. propsheet.AddPage(&install_key);
  280. // new stuff for iis6
  281. propsheet.AddPage(&copy_move_from_cert_remote_page);
  282. propsheet.AddPage(&copy_move_to_cert_remote_page);
  283. propsheet.AddPage(&choose_import_pfx_file_name);
  284. propsheet.AddPage(&choose_export_pfx_file_name);
  285. propsheet.AddPage(&import_pfx_password_name);
  286. propsheet.AddPage(&export_pfx_password_name);
  287. propsheet.AddPage(&install_import_pfx_key);
  288. propsheet.AddPage(&install_export_pfx_key);
  289. propsheet.AddPage(&final_import_pfx);
  290. propsheet.AddPage(&final_export_pfx);
  291. propsheet.AddPage(&choose_server_name);
  292. propsheet.AddPage(&choose_server_site_name);
  293. propsheet.AddPage(&choose_server_name_to);
  294. propsheet.AddPage(&choose_server_site_name_to);
  295. propsheet.AddPage(&install_copy_from_remote);
  296. propsheet.AddPage(&install_move_from_remote);
  297. propsheet.AddPage(&install_copy_to_remote);
  298. propsheet.AddPage(&install_move_to_remote);
  299. propsheet.AddPage(&final_copy_from_remote);
  300. propsheet.AddPage(&final_move_from_remote);
  301. propsheet.AddPage(&final_copy_to_remote);
  302. propsheet.AddPage(&final_move_to_remote);
  303. if (IDCANCEL != propsheet.DoModal())
  304. {
  305. // save our settings to the Registry
  306. VERIFY(cert->SaveSettings());
  307. }
  308. delete cert;
  309. }
  310. void CCertWizCtrl::SetMachineName(LPCTSTR MachineName)
  311. {
  312. m_MachineName = MachineName;
  313. }
  314. void CCertWizCtrl::SetServerInstance(LPCTSTR InstanceName)
  315. {
  316. m_InstanceName = InstanceName;
  317. }