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.

138 lines
3.0 KiB

  1. #ifndef _TAPI_OBJECT_SAFETY_
  2. #define _TAPI_OBJECT_SAFETY_
  3. #include "PromptedObjectSafety.h"
  4. #include "ScrpScrtDlg.h"
  5. #include "ObjectWithSite.h"
  6. /*++
  7. Copyright (c) 1999 Microsoft Corporation
  8. Module Name:
  9. TAPIObjectSafety.h
  10. Abstract:
  11. Implements IObjectSafety and IObjectWithSite
  12. Manages decision logic of whether tapi functionality should be allowed on
  13. the current page. Checks persistent settings for this page and prompts with
  14. a dialog if necessary.
  15. Objects that need this protection (CTTAPI, CRequest) derive from this
  16. class.
  17. --*/
  18. static const TCHAR gszCookieName[] = _T("TAPI");
  19. class CTAPIObjectSafety : public CPromptedObjectSafety, public CObjectWithSite
  20. {
  21. public:
  22. DECLARE_TRACELOG_CLASS(CTAPIObjectSafety)
  23. //
  24. // call CObjectWithSite's constructor and pass in the cookie name
  25. //
  26. CTAPIObjectSafety()
  27. :CObjectWithSite(gszCookieName)
  28. {
  29. }
  30. //
  31. // implementing CPromptedObjectSafety's pure virtual method
  32. // if the page is not in the safe list, and this is the first
  33. // time we are asking, prompt the user. act accordingly.
  34. // if the user chooses, mark the page safe for scripting (persistently)
  35. //
  36. virtual BOOL Ask()
  37. {
  38. //
  39. // if the object does not have a site pointer. we should not consider
  40. // it to be safe. Do not prompt the user
  41. //
  42. if ( !HaveSite() )
  43. {
  44. return FALSE;
  45. }
  46. EnValidation enCurrentValidation = GetValidation();
  47. //
  48. // if the page has not been validated, try to validate it.
  49. //
  50. if (UNVALIDATED == enCurrentValidation)
  51. {
  52. CScriptSecurityDialog *pDialog = new CScriptSecurityDialog;
  53. //
  54. // if succeeded displaying the dialog
  55. // validate the page based on user's input
  56. //
  57. if ( NULL != pDialog )
  58. {
  59. switch (pDialog->DoModalWithText(IDS_TAPI_SEC_PROMPT))
  60. {
  61. case ID_YES:
  62. Validate(VALIDATED_SAFE);
  63. break;
  64. case ID_NO:
  65. Validate(VALIDATED_UNSAFE);
  66. break;
  67. case ID_YES_DONT_ASK_AGAIN:
  68. Validate(VALIDATED_SAFE_PERMANENT);
  69. break;
  70. default:
  71. break;
  72. }
  73. delete pDialog;
  74. //
  75. // get the new validation.
  76. //
  77. enCurrentValidation = GetValidation();
  78. } // if (NULL != pDialog)
  79. }
  80. //
  81. // by now we either got the validation data or validation did not change
  82. //
  83. // return true if the page is validated as safe
  84. //
  85. return (VALIDATED_SAFE == enCurrentValidation);
  86. }
  87. };
  88. #endif // _TAPI_OBJECT_SAFETY_