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.

234 lines
6.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, **/
  4. /**********************************************************************/
  5. /*
  6. pgencryp.cpp
  7. Definition of CPgEncryption -- property page to edit
  8. profile attributes related to encryption
  9. FILE HISTORY:
  10. */
  11. #include "stdafx.h"
  12. #include "resource.h"
  13. #include "PgEncryp.h"
  14. #include "helptable.h"
  15. #include "profsht.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CPgEncryptionMerge property page
  23. IMPLEMENT_DYNCREATE(CPgEncryptionMerge, CPropertyPage)
  24. #define NO_OLD_ET_VALUE
  25. CPgEncryptionMerge::CPgEncryptionMerge(CRASProfileMerge* profile)
  26. : CManagedPage(CPgEncryptionMerge::IDD),
  27. m_pProfile(profile)
  28. {
  29. //{{AFX_DATA_INIT(CPgEncryptionMerge)
  30. m_bBasic = FALSE;
  31. m_bNone = FALSE;
  32. m_bStrong = FALSE;
  33. m_bStrongest = FALSE;
  34. //}}AFX_DATA_INIT
  35. m_b128EnabledOnTheMachine = FALSE;
  36. // default case --- allow everything
  37. if (((m_pProfile->m_dwAttributeFlags & PABF_msRASAllowEncryption) == 0)
  38. && ((m_pProfile->m_dwAttributeFlags & PABF_msRASEncryptionType) == 0))
  39. {
  40. m_bBasic = TRUE;
  41. m_bNone = TRUE;
  42. m_bStrong = TRUE;
  43. m_bStrongest = TRUE;
  44. }
  45. else if (((m_pProfile->m_dwAttributeFlags & PABF_msRASAllowEncryption) != 0)
  46. && ((m_pProfile->m_dwAttributeFlags & PABF_msRASEncryptionType) != 0))
  47. {
  48. if (m_pProfile->m_dwEncryptionPolicy == RAS_EP_ALLOW)
  49. m_bNone = TRUE; // allow means None is OK
  50. m_bStrong = ((m_pProfile->m_dwEncryptionType & RAS_ET_STRONG ) != 0);
  51. m_bBasic = ((m_pProfile->m_dwEncryptionType & RAS_ET_BASIC ) != 0);
  52. m_bStrongest = ((m_pProfile->m_dwEncryptionType & RAS_ET_STRONGEST ) != 0);
  53. }
  54. SetHelpTable(g_aHelpIDs_IDD_ENCRYPTION_MERGE);
  55. }
  56. CPgEncryptionMerge::~CPgEncryptionMerge()
  57. {
  58. }
  59. void CPgEncryptionMerge::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CPropertyPage::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CPgEncryptionMerge)
  63. DDX_Check(pDX, IDC_CHECK_ENC_BASIC, m_bBasic);
  64. DDX_Check(pDX, IDC_CHECK_ENC_NONE, m_bNone);
  65. DDX_Check(pDX, IDC_CHECK_ENC_STRONG, m_bStrong);
  66. DDX_Check(pDX, IDC_CHECK_ENC_STRONGEST, m_bStrongest);
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(CPgEncryptionMerge, CPropertyPage)
  70. //{{AFX_MSG_MAP(CPgEncryptionMerge)
  71. ON_WM_HELPINFO()
  72. ON_WM_CONTEXTMENU()
  73. ON_BN_CLICKED(IDC_CHECK_ENC_BASIC, OnCheckEncBasic)
  74. ON_BN_CLICKED(IDC_CHECK_ENC_NONE, OnCheckEncNone)
  75. ON_BN_CLICKED(IDC_CHECK_ENC_STRONG, OnCheckEncStrong)
  76. ON_BN_CLICKED(IDC_CHECK_ENC_STRONGEST, OnCheckEncStrongest)
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CPgEncryption message handlers
  81. BOOL CPgEncryptionMerge::OnKillActive()
  82. {
  83. UpdateData();
  84. // at least one should be
  85. if(!(m_bNone || m_bBasic || m_bStrong || m_bStrongest))
  86. {
  87. AfxMessageBox(IDS_DATAENTRY_ENCRYPTIONTYPE);
  88. return FALSE;
  89. }
  90. return CPropertyPage::OnKillActive();
  91. }
  92. BOOL CPgEncryptionMerge::OnApply()
  93. {
  94. if (!GetModified()) return TRUE;
  95. // default case -- allow anything, -- remove the attributes
  96. if (m_bNone && m_bBasic && m_bStrong && m_bStrongest)
  97. {
  98. // remove both attributes
  99. m_pProfile->m_dwAttributeFlags &= (~PABF_msRASAllowEncryption);
  100. m_pProfile->m_dwAttributeFlags &= (~PABF_msRASEncryptionType);
  101. }
  102. else
  103. {
  104. // policy
  105. if (m_bNone)
  106. m_pProfile->m_dwEncryptionPolicy = RAS_EP_ALLOW;
  107. else
  108. m_pProfile->m_dwEncryptionPolicy = RAS_EP_REQUIRE;
  109. // type
  110. m_pProfile->m_dwEncryptionType = 0;
  111. if (m_bBasic)
  112. m_pProfile->m_dwEncryptionType |= RAS_ET_BASIC;
  113. if (m_bStrong)
  114. m_pProfile->m_dwEncryptionType |= RAS_ET_STRONG;
  115. if (m_bStrongest)
  116. m_pProfile->m_dwEncryptionType |= RAS_ET_STRONGEST;
  117. // at least one must be selected
  118. if (m_pProfile->m_dwEncryptionType == 0 && m_pProfile->m_dwEncryptionPolicy == RAS_EP_REQUIRE)
  119. {
  120. AfxMessageBox(IDS_DATAENTRY_ENCRYPTIONTYPE);
  121. return FALSE;
  122. }
  123. // set the flags
  124. m_pProfile->m_dwAttributeFlags |= PABF_msRASAllowEncryption;
  125. m_pProfile->m_dwAttributeFlags |= PABF_msRASEncryptionType;
  126. }
  127. return CManagedPage::OnApply();
  128. }
  129. BOOL CPgEncryptionMerge::OnInitDialog()
  130. {
  131. // always true for IAS
  132. m_b128EnabledOnTheMachine = TRUE;
  133. CPropertyPage::OnInitDialog();
  134. CProfileSheetMerge* pSheet = dynamic_cast<CProfileSheetMerge*>(GetManager());
  135. if (pSheet && (pSheet->m_dwTabFlags & RAS_IAS_PROFILEDLG_SHOW_RASTABS))
  136. {
  137. // if 128 bit is enabled
  138. RAS_NDISWAN_DRIVER_INFO Info;
  139. ZeroMemory(&Info, sizeof(RAS_NDISWAN_DRIVER_INFO));
  140. m_pProfile->GetRasNdiswanDriverCaps(&Info);
  141. if (Info.DriverCaps & RAS_NDISWAN_128BIT_ENABLED)
  142. m_b128EnabledOnTheMachine = TRUE;
  143. else
  144. m_b128EnabledOnTheMachine = FALSE;
  145. if(m_b128EnabledOnTheMachine)
  146. GetDlgItem(IDC_CHECK_ENC_STRONGEST)->ShowWindow(SW_SHOW);
  147. else
  148. GetDlgItem(IDC_CHECK_ENC_STRONGEST)->ShowWindow(SW_HIDE);
  149. }
  150. return TRUE; // return TRUE unless you set the focus to a control
  151. // EXCEPTION: OCX Property Pages should return FALSE
  152. }
  153. BOOL CPgEncryptionMerge::OnHelpInfo(HELPINFO* pHelpInfo)
  154. {
  155. // TODO: Add your message handler code here and/or call default
  156. return CManagedPage::OnHelpInfo(pHelpInfo);
  157. }
  158. void CPgEncryptionMerge::OnContextMenu(CWnd* pWnd, CPoint point)
  159. {
  160. CManagedPage::OnContextMenu(pWnd, point);
  161. }
  162. BOOL CPgEncryptionMerge::OnSetActive()
  163. {
  164. return CPropertyPage::OnSetActive();
  165. }
  166. void CPgEncryptionMerge::OnCheckEncBasic()
  167. {
  168. // TODO: Add your control notification handler code here
  169. SetModified();
  170. }
  171. void CPgEncryptionMerge::OnCheckEncNone()
  172. {
  173. // TODO: Add your control notification handler code here
  174. SetModified();
  175. }
  176. void CPgEncryptionMerge::OnCheckEncStrong()
  177. {
  178. // TODO: Add your control notification handler code here
  179. SetModified();
  180. }
  181. void CPgEncryptionMerge::OnCheckEncStrongest()
  182. {
  183. // TODO: Add your control notification handler code here
  184. SetModified();
  185. }