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.

215 lines
5.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: iih.h
  7. //
  8. // Contents: ACUI Invoke Info Helper class definition
  9. //
  10. // History: 10-May-97 kirtd Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #if !defined(__IIH_H__)
  14. #define __IIH_H__
  15. #include <acui.h>
  16. #include <acuictl.h>
  17. extern HINSTANCE g_hModule;
  18. //
  19. // CInvokeInfoHelper is used to pull various pieces of information out
  20. // of the ACUI_INVOKE_INFO data structure
  21. //
  22. class CInvokeInfoHelper
  23. {
  24. public:
  25. //
  26. // Initialization
  27. //
  28. CInvokeInfoHelper (
  29. PACUI_INVOKE_INFO pInvokeInfo,
  30. HRESULT& rhr
  31. );
  32. ~CInvokeInfoHelper ();
  33. //
  34. // Information Retrieval Methods
  35. //
  36. LPCWSTR Subject() { return(m_pszSubject); }
  37. LPCWSTR Publisher() { return(m_pszPublisher); }
  38. LPCWSTR PublisherCertIssuer() { return(m_pszPublisherCertIssuer); }
  39. LPCWSTR ControlWebPage() { return(m_pszControlWebPage); }
  40. LPCWSTR CAWebPage() { return(m_pszCAWebPage); }
  41. LPCWSTR AdvancedLink() { return(m_pszAdvancedLink); }
  42. LPCWSTR CertTimestamp() { return(m_pszCertTimestamp); }
  43. LPCWSTR TestCertInChain() { return(m_pszTestCertInChain); }
  44. LPCWSTR ErrorStatement() { return(m_pszErrorStatement); }
  45. PCRYPT_PROVIDER_DATA ProviderData() { return(m_pInvokeInfo->pProvData); }
  46. BOOL IsKnownPublisher() { return(m_fKnownPublisher); }
  47. BOOL IsCertViewPropertiesAvailable() { return(m_pfnCVPA != NULL); }
  48. //
  49. // Personal Trust management
  50. //
  51. HRESULT AddPublisherToPersonalTrust ();
  52. //
  53. // UI control management
  54. //
  55. HRESULT GetUIControl (IACUIControl** ppUI);
  56. VOID ReleaseUIControl (IACUIControl* pUI);
  57. inline BOOL CallCertViewProperties (HWND hwndParent);
  58. inline VOID CallAdvancedLink (HWND hwndParent);
  59. inline VOID CallWebLink(HWND hwndParent, WCHAR *pszLink);
  60. private:
  61. //
  62. // Invoke Info holder
  63. //
  64. PACUI_INVOKE_INFO m_pInvokeInfo;
  65. //
  66. // Subject, Publisher, Issuer and Error Statement strings
  67. //
  68. LPWSTR m_pszSubject;
  69. LPWSTR m_pszPublisher;
  70. LPWSTR m_pszPublisherCertIssuer;
  71. LPWSTR m_pszErrorStatement;
  72. LPWSTR m_pszCertTimestamp;
  73. LPWSTR m_pszAdvancedLink;
  74. LPWSTR m_pszTestCertInChain;
  75. LPWSTR m_pszControlWebPage;
  76. LPWSTR m_pszCAWebPage;
  77. //
  78. // Known publisher flag
  79. //
  80. BOOL m_fKnownPublisher;
  81. //
  82. // Cert view properties entry point
  83. //
  84. HINSTANCE m_hModCVPA;
  85. pfnCertViewProperties m_pfnCVPA;
  86. //
  87. // Private methods
  88. //
  89. HRESULT InitSubject();
  90. HRESULT InitPublisher();
  91. HRESULT InitPublisherCertIssuer();
  92. HRESULT InitErrorStatement();
  93. HRESULT InitCertTimestamp();
  94. VOID InitCertViewPropertiesEntryPoint();
  95. LPWSTR GetFormattedCertTimestamp(LPSYSTEMTIME pst);
  96. BOOL IsTestCertInPublisherChain();
  97. VOID InitAdvancedLink();
  98. VOID InitTestCertInChain();
  99. VOID InitControlWebPage();
  100. VOID InitCAWebPage();
  101. };
  102. //
  103. // Error mapping helper
  104. //
  105. HRESULT ACUIMapErrorToString (HRESULT hr, LPWSTR* ppsz);
  106. //
  107. // Inline methods
  108. //
  109. //+---------------------------------------------------------------------------
  110. //
  111. // Member: CInvokeInfoHelper::CallCertViewProperties, public
  112. //
  113. // Synopsis: calls the cert view properties entry point
  114. //
  115. // Arguments: [hwndParent] -- parent window handle
  116. //
  117. // Returns: Result of CertViewPropertiesW call
  118. //
  119. // Notes:
  120. //
  121. //----------------------------------------------------------------------------
  122. inline BOOL
  123. CInvokeInfoHelper::CallCertViewProperties (HWND hwndParent)
  124. {
  125. CRYPT_PROVIDER_SGNR *pSgnr;
  126. CRYPT_PROVIDER_CERT *pCert;
  127. //
  128. // Setup the common dialog call structure
  129. //
  130. CVP_STRUCTDEF cvsa;
  131. memset(&cvsa, 0, sizeof(CVP_STRUCTDEF));
  132. cvsa.dwSize = sizeof(CVP_STRUCTDEF);
  133. cvsa.hwndParent = hwndParent;
  134. # if (USE_IEv4CRYPT32)
  135. cvsa.hInstance = g_hModule;
  136. # else
  137. cvsa.pCryptProviderData = ProviderData();
  138. cvsa.fpCryptProviderDataTrustedUsage = (m_pInvokeInfo->hrInvokeReason == ERROR_SUCCESS) ? TRUE : FALSE;
  139. # endif
  140. if (pSgnr = WTHelperGetProvSignerFromChain(ProviderData(), 0, FALSE, 0))
  141. {
  142. if (pCert = WTHelperGetProvCertFromChain(pSgnr, 0))
  143. {
  144. cvsa.pCertContext = pCert->pCert;
  145. }
  146. }
  147. //
  148. // Bring up the dialog
  149. //
  150. # if (USE_IEv4CRYPT32)
  151. (*m_pfnCVPA)(&cvsa);
  152. # else
  153. (*m_pfnCVPA)(&cvsa, NULL); // TBDTBD: &fRefresh: show dialog
  154. # endif
  155. return( TRUE );
  156. }
  157. inline VOID
  158. CInvokeInfoHelper::CallAdvancedLink (HWND hwndParent)
  159. {
  160. if ((ProviderData()) &&
  161. (ProviderData()->psPfns->psUIpfns) &&
  162. (ProviderData()->psPfns->psUIpfns->pfnOnAdvancedClick))
  163. {
  164. (*ProviderData()->psPfns->psUIpfns->pfnOnAdvancedClick)(hwndParent, ProviderData());
  165. }
  166. }
  167. inline VOID
  168. CInvokeInfoHelper::CallWebLink(HWND hwndParent, WCHAR *pszLink)
  169. {
  170. TUIGoLink(hwndParent, pszLink);
  171. }
  172. #endif