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.

148 lines
3.3 KiB

  1. /*
  2. * s e c m g r . c p p
  3. *
  4. * Purpose:
  5. * Implement security manager callback
  6. *
  7. * History
  8. * August '96: brettm - created
  9. *
  10. * Copyright (C) Microsoft Corp. 1995, 1996.
  11. */
  12. #include <pch.hxx>
  13. #include <docobj.h>
  14. #include "dllmain.h"
  15. #include "secmgr.h"
  16. #include "urlmon.h"
  17. #define DEF_SECURITYZONE URLZONE_UNTRUSTED
  18. /*
  19. * Security Manger implementation
  20. *
  21. */
  22. CSecManager::CSecManager(IOleCommandTarget *pCmdTarget)
  23. {
  24. m_cRef=1;
  25. m_pCmdTarget = pCmdTarget; // loose reference as it's always around
  26. }
  27. CSecManager::~CSecManager()
  28. {
  29. }
  30. HRESULT CSecManager::QueryInterface(REFIID riid, LPVOID FAR *lplpObj)
  31. {
  32. if(!lplpObj)
  33. return E_INVALIDARG;
  34. *lplpObj = NULL;
  35. if (IsEqualIID(riid, IID_IInternetSecurityManager))
  36. *lplpObj = (IInternetSecurityManager*) this;
  37. else
  38. return E_NOINTERFACE;
  39. AddRef();
  40. return NOERROR;
  41. }
  42. ULONG CSecManager::AddRef()
  43. {
  44. return ++m_cRef;
  45. }
  46. ULONG CSecManager::Release()
  47. {
  48. if (--m_cRef==0)
  49. {
  50. delete this;
  51. return 0;
  52. }
  53. return m_cRef;
  54. }
  55. HRESULT CSecManager::SetSecuritySite(IInternetSecurityMgrSite *pSite)
  56. {
  57. return E_NOTIMPL;
  58. }
  59. HRESULT CSecManager::GetSecuritySite(IInternetSecurityMgrSite **ppSite)
  60. {
  61. return E_NOTIMPL;
  62. }
  63. HRESULT CSecManager::MapUrlToZone(LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags)
  64. {
  65. DWORD dwZone;
  66. if (pdwZone == NULL)
  67. return E_INVALIDARG;
  68. // run our resources in the trusted zone
  69. if (pwszUrl && !StrCmpNIW(pwszUrl, L"res:", 4))
  70. dwZone = URLZONE_TRUSTED;
  71. // run message content in the selected zone
  72. else
  73. dwZone = DwGetZone();
  74. if (dwZone > URLZONE_PREDEFINED_MAX)
  75. dwZone = DEF_SECURITYZONE;
  76. *pdwZone = dwZone;
  77. return S_OK;
  78. }
  79. HRESULT CSecManager::GetSecurityId(LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
  80. {
  81. return INET_E_DEFAULT_ACTION;
  82. }
  83. HRESULT CSecManager::ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE __RPC_FAR *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
  84. {
  85. return INET_E_DEFAULT_ACTION;
  86. }
  87. HRESULT CSecManager::QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved)
  88. {
  89. return INET_E_DEFAULT_ACTION;
  90. }
  91. HRESULT CSecManager::SetZoneMapping(DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags)
  92. {
  93. return INET_E_DEFAULT_ACTION;
  94. }
  95. HRESULT CSecManager::GetZoneMappings(DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
  96. {
  97. return INET_E_DEFAULT_ACTION;
  98. }
  99. DWORD CSecManager::DwGetZone()
  100. {
  101. VARIANTARG va;
  102. DWORD dwZone = DEF_SECURITYZONE;
  103. if (m_pCmdTarget &&
  104. m_pCmdTarget->Exec(&CMDSETID_MimeEditHost, MEHOSTCMDID_SECURITY_ZONE, OLECMDEXECOPT_DODEFAULT, NULL, &va)==S_OK &&
  105. va.vt == VT_I4)
  106. dwZone = va.lVal;
  107. return dwZone;
  108. }
  109. HRESULT CreateSecurityManger(IOleCommandTarget *pCmdTarget, LPSECMANAGER *ppSecMgr)
  110. {
  111. CSecManager *pSecMgr;
  112. TraceCall ("CreateSecurityManger");
  113. pSecMgr = new CSecManager(pCmdTarget);
  114. if (!pSecMgr)
  115. return TraceResult(E_OUTOFMEMORY);
  116. *ppSecMgr = pSecMgr;
  117. return S_OK;
  118. }