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.

168 lines
4.1 KiB

  1. // tls.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "nfaa.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CTLSSetting dialog
  12. CTLSSetting::CTLSSetting(CWnd* pParent /*=NULL*/)
  13. : CDialog(CTLSSetting::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(CTLSSetting)
  16. //m_dwValidateServerCertificate = FALSE;
  17. //}}AFX_DATA_INIT
  18. m_bReadOnly = FALSE;
  19. }
  20. void CTLSSetting::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CTLSSetting)
  24. DDX_Control(pDX, IDC_COMBO_TLS_CERT_TYPE, m_cbCertificateType);
  25. DDX_Check(pDX, IDC_TLS_VALIDATE_SERVER_CERT, m_dwValidateServerCertificate);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CTLSSetting, CDialog)
  29. //{{AFX_MSG_MAP(CTLSSetting)
  30. ON_WM_HELPINFO()
  31. ON_CBN_SELENDOK(IDC_COMBO_TLS_CERT_TYPE, OnSelCertType)
  32. ON_BN_CLICKED(IDC_TLS_VALIDATE_SERVER_CERT, OnCheckValidateServerCert)
  33. //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CTLSSetting message handlers
  37. BOOL CTLSSetting::OnInitDialog()
  38. {
  39. CDialog::OnInitDialog();
  40. CString pszTemp;
  41. DWORD dwCertTypeIndex = 0;
  42. if (!pTLSProperties) {
  43. return FALSE;
  44. }
  45. pszTemp.LoadString(IDS_CERT_TYPE_SMARTCARD);
  46. m_cbCertificateType.AddString(pszTemp);
  47. pszTemp.LoadString(IDS_CERT_TYPE_MC_CERT);
  48. m_cbCertificateType.AddString(pszTemp);
  49. switch (pTLSProperties->dwCertType)
  50. {
  51. case WIRELESS_CERT_TYPE_SMARTCARD:
  52. dwCertTypeIndex = 0;
  53. break;
  54. case WIRELESS_CERT_TYPE_MC_CERT:
  55. dwCertTypeIndex = 1;
  56. break;
  57. default:
  58. dwCertTypeIndex = 0;
  59. break;
  60. }
  61. m_cbCertificateType.SetCurSel(dwCertTypeIndex);
  62. m_dwValidateServerCertificate =
  63. pTLSProperties->dwValidateServerCert ? TRUE : FALSE;
  64. if (m_bReadOnly) {
  65. SAFE_ENABLEWINDOW(IDC_TLS_VALIDATE_SERVER_CERT, FALSE);
  66. SAFE_ENABLEWINDOW(IDC_COMBO_TLS_CERT_TYPE, FALSE);
  67. SAFE_ENABLEWINDOW(IDC_STATIC_CERT_TYPE, FALSE);
  68. }
  69. UpdateData(FALSE);
  70. return TRUE; // return TRUE unless you set the focus to a control
  71. // EXCEPTION: OCX Property Pages should return FALSE
  72. }
  73. void CTLSSetting::ControlsValuesToSM (PTLS_PROPERTIES pTLSProperties)
  74. {
  75. // pull all our data from the controls
  76. UpdateData(TRUE);
  77. DWORD dwCertificateTypeIndex = 0;
  78. DWORD dwCertificateType = 0;
  79. DWORD dwValidateServerCertificate = 0;
  80. dwCertificateTypeIndex = m_cbCertificateType.GetCurSel();
  81. switch (dwCertificateTypeIndex) {
  82. case 0 :
  83. dwCertificateType =
  84. WIRELESS_CERT_TYPE_SMARTCARD;
  85. break;
  86. case 1 :
  87. dwCertificateType =
  88. WIRELESS_CERT_TYPE_MC_CERT;
  89. break;
  90. }
  91. dwValidateServerCertificate =
  92. m_dwValidateServerCertificate ? 1 : 0;
  93. pTLSProperties->dwCertType = dwCertificateType;
  94. pTLSProperties->dwValidateServerCert = dwValidateServerCertificate;
  95. }
  96. void CTLSSetting::OnOK()
  97. {
  98. UpdateData (TRUE);
  99. ControlsValuesToSM(pTLSProperties);
  100. CDialog::OnOK();
  101. }
  102. BOOL CTLSSetting::OnHelpInfo(HELPINFO* pHelpInfo)
  103. {
  104. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  105. {
  106. DWORD* pdwHelp = (DWORD*) &g_aHelpIDs_IDD_TLS_SETTINGS[0];
  107. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  108. c_szWlsnpHelpFile,
  109. HELP_WM_HELP,
  110. (DWORD_PTR)(LPVOID)pdwHelp);
  111. }
  112. return TRUE;
  113. }
  114. void CTLSSetting::OnSelCertType()
  115. {
  116. UpdateData(TRUE);
  117. }
  118. void CTLSSetting::OnCheckValidateServerCert()
  119. {
  120. UpdateData(TRUE);
  121. }
  122. BOOL CTLSSetting::Initialize(
  123. PTLS_PROPERTIES paTLSProperties,
  124. BOOL bReadOnly
  125. )
  126. {
  127. pTLSProperties = paTLSProperties;
  128. m_bReadOnly = bReadOnly;
  129. if (!pTLSProperties) {
  130. return(FALSE);
  131. }
  132. return(TRUE);
  133. }