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.

140 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. rndobjsf.h
  5. Abstract:
  6. Definitions for CRendObjectSafety class.
  7. --*/
  8. #ifndef _REND_OBJECT_SAFETY_
  9. #define _REND_OBJECT_SAFETY_
  10. #define IDD_TAPI_SECURITY_DIALOG 500
  11. #define IDC_SECURITY_WARNING_TEXT 502
  12. #define IDC_DONOT_PROMPT_IN_THE_FUTURE 503
  13. #define ID_YES 505
  14. #define ID_NO 506
  15. #define ID_YES_DONT_ASK_AGAIN 557
  16. #define IDS_REND_SEC_PROMPT 91
  17. #include <PromptedObjectSafety.h>
  18. #include <ScrpScrtDlg.h>
  19. #include <ObjectWithSite.h>
  20. static const TCHAR gszCookieName[] = _T("rend");
  21. class CRendObjectSafety : public CPromptedObjectSafety, public CObjectWithSite
  22. {
  23. public:
  24. //
  25. // call CObjectWithSite's constructor and pass in the cookie name
  26. //
  27. CRendObjectSafety()
  28. :CObjectWithSite(gszCookieName)
  29. {
  30. }
  31. //
  32. // implementing CPromptedObjectSafety's pure virtual method
  33. // if the page is not in the safe list, and this is the first
  34. // time we are asking, prompt the user. act accordingly.
  35. // if the user chooses, mark the page safe for scripting (persistently)
  36. //
  37. virtual BOOL Ask()
  38. {
  39. //
  40. // if the object does not have a site pointer. we should not consider
  41. // it to be safe. Do not prompt the user.
  42. //
  43. if ( !HaveSite() )
  44. {
  45. return FALSE;
  46. }
  47. EnValidation enCurrentValidation = GetValidation();
  48. //
  49. // if the page has not been validated, try to validate it.
  50. //
  51. if (UNVALIDATED == enCurrentValidation)
  52. {
  53. if( IsIntranet())
  54. {
  55. Validate(VALIDATED_SAFE);
  56. enCurrentValidation = GetValidation();
  57. return TRUE;
  58. }
  59. CScriptSecurityDialog *pDialog = new CScriptSecurityDialog;
  60. //
  61. // if succeeded displaying the dialog
  62. // validate the page based on user's input
  63. //
  64. if ( NULL != pDialog )
  65. {
  66. switch (pDialog->DoModalWithText(IDS_REND_SEC_PROMPT))
  67. {
  68. case ID_YES:
  69. Validate(VALIDATED_SAFE);
  70. break;
  71. case ID_NO:
  72. Validate(VALIDATED_UNSAFE);
  73. break;
  74. case ID_YES_DONT_ASK_AGAIN:
  75. Validate(VALIDATED_SAFE_PERMANENT);
  76. break;
  77. default:
  78. break;
  79. }
  80. delete pDialog;
  81. //
  82. // get the new validation.
  83. //
  84. enCurrentValidation = GetValidation();
  85. } // if (NULL != pDialog)
  86. }
  87. //
  88. // by now we either got the validation data or validation did not change
  89. //
  90. // return true if the page is validated as safe
  91. //
  92. return (VALIDATED_SAFE == enCurrentValidation) ;
  93. }
  94. };
  95. #endif // _REND_OBJECT_SAFETY_