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.

342 lines
14 KiB

  1. /**********************************************************************/
  2. /** Microsoft Passport **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 2001 **/
  4. /**********************************************************************/
  5. /*
  6. manager.h
  7. Define CManager class for passport manager interface
  8. FILE HISTORY:
  9. */
  10. // Manager.h : Declaration of the CManager
  11. #ifndef __MANAGER_H_
  12. #define __MANAGER_H_
  13. #include "resource.h" // main symbols
  14. #include "Passport.h"
  15. #include "Ticket.h"
  16. #include "Profile.h"
  17. #include "passportservice.h"
  18. #include <httpext.h>
  19. #include <httpfilt.h>
  20. using namespace ATL;
  21. inline bool IsEmptyString(LPCWSTR str)
  22. {
  23. if (!str) return true;
  24. if (*str == 0) return true;
  25. return false;
  26. };
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CManager
  29. class ATL_NO_VTABLE CManager :
  30. public CComObjectRootEx<CComMultiThreadModel>,
  31. public CComCoClass<CManager, &CLSID_Manager>,
  32. public ISupportErrorInfo,
  33. public IPassportService,
  34. public IDispatchImpl<IPassportManager3, &IID_IPassportManager3, &LIBID_PASSPORTLib>,
  35. public IDomainMap
  36. {
  37. public:
  38. CManager();
  39. ~CManager();
  40. public:
  41. DECLARE_REGISTRY_RESOURCEID(IDR_MANAGER)
  42. DECLARE_GET_CONTROLLING_UNKNOWN()
  43. DECLARE_PROTECT_FINAL_CONSTRUCT()
  44. BEGIN_COM_MAP(CManager)
  45. COM_INTERFACE_ENTRY(IPassportManager)
  46. COM_INTERFACE_ENTRY(IPassportManager2)
  47. COM_INTERFACE_ENTRY(IPassportManager3)
  48. COM_INTERFACE_ENTRY(IDispatch)
  49. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  50. COM_INTERFACE_ENTRY(IPassportService)
  51. COM_INTERFACE_ENTRY(IDomainMap)
  52. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  53. END_COM_MAP()
  54. HRESULT FinalConstruct()
  55. {
  56. if(m_pUnkMarshaler.p != NULL)
  57. return S_OK;
  58. return CoCreateFreeThreadedMarshaler(
  59. GetControllingUnknown(), &m_pUnkMarshaler.p);
  60. }
  61. void FinalRelease()
  62. {
  63. m_pUnkMarshaler.Release();
  64. }
  65. CComPtr<IUnknown> m_pUnkMarshaler;
  66. // ISupportsErrorInfo
  67. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  68. // IPassportManager
  69. public:
  70. STDMETHOD(HaveConsent)(/*[in]*/ VARIANT_BOOL bNeedFullConsent, /*[in]*/ VARIANT_BOOL bNeedBirthdate, /*[out,retval]*/ VARIANT_BOOL* pbHaveConsent);
  71. STDMETHOD(GetServerInfo)(/*[out,retval]*/ BSTR *pbstrOut);
  72. STDMETHOD(Commit)(BSTR *newProf);
  73. STDMETHOD(get_HasSavedPassword)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  74. STDMETHOD(get_ProfileByIndex)(/*[in]*/ int index, /*[out, retval]*/ VARIANT *pVal);
  75. STDMETHOD(put_ProfileByIndex)(/*[in]*/ int index, /*[in]*/ VARIANT newVal);
  76. STDMETHOD(get_Profile)(/*[in]*/ BSTR attributeName, /*[out, retval]*/ VARIANT *pVal);
  77. STDMETHOD(put_Profile)(/*[in]*/ BSTR attributeName, /*[in]*/ VARIANT newVal);
  78. STDMETHOD(DomainFromMemberName)(/*[in,optional]*/ VARIANT memberName, /*[out,retval]*/ BSTR *pDomainName);
  79. STDMETHOD(GetDomainAttribute)(/*[in]*/ BSTR attributeName, /*[in,optional]*/ VARIANT lcid, /*[in,optional]*/ VARIANT domain, /*[out,retval]*/ BSTR *pAttrVal);
  80. STDMETHOD(get_TimeSinceSignIn)(/*[out, retval]*/ int *pVal);
  81. STDMETHOD(get_TicketAge)(/*[out, retval]*/ int *pVal);
  82. STDMETHOD(get_SignInTime)(/*[out, retval]*/ long *pVal);
  83. STDMETHOD(get_TicketTime)(/*[out, retval]*/ long *pVal);
  84. STDMETHOD(HasFlag)(/*[in]*/ VARIANT flagMask, /*[out, retval]*/ VARIANT_BOOL *pVal);
  85. STDMETHOD(get_FromNetworkServer)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  86. STDMETHOD(get_HasTicket)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  87. STDMETHOD(HasProfile)(/*[in]*/ VARIANT profileName, /*[out, retval]*/ VARIANT_BOOL *pVal);
  88. STDMETHOD(LogoTag)(/*[in]*/ VARIANT returnUrl, /*[in]*/ VARIANT TimeWindow, /*[in]*/ VARIANT ForceLogin, VARIANT coBrandTemplate, VARIANT lang_id, VARIANT bSecure, VARIANT NameSpace, /*[in, optional*/ VARIANT KPP, /*[in, optional]*/ VARIANT SecureLevel, /*[out, retval]*/ BSTR *pVal);
  89. STDMETHOD(LogoTag2)(/*[in]*/ VARIANT returnUrl, /*[in]*/ VARIANT TimeWindow, /*[in]*/ VARIANT ForceLogin, VARIANT coBrandTemplate, VARIANT lang_id, VARIANT bSecure, VARIANT NameSpace, /*[in, optional*/ VARIANT KPP, /*[in, optional]*/ VARIANT SecureLevel, /*[out, retval]*/ BSTR *pVal);
  90. STDMETHOD(IsAuthenticated)(/*[in]*/ VARIANT TimeWindow, /*[in]*/ VARIANT ForceLogin, /*[in,optional]*/ VARIANT SecureLevel, /*[out, retval]*/ VARIANT_BOOL *pVal);
  91. STDMETHOD(AuthURL)(/*[in]*/ VARIANT returnUrl, /*[in]*/ VARIANT TimeWindow, /*[in]*/ VARIANT ForceLogin, VARIANT coBrandTemplate, VARIANT lang_id, VARIANT NameSpace, /*[in, optional]*/ VARIANT KPP, /*[in, optional]*/ VARIANT SecureLevel, /*[out,retval]*/ BSTR *pAuthUrl);
  92. STDMETHOD(AuthURL2)(/*[in]*/ VARIANT returnUrl, /*[in]*/ VARIANT TimeWindow, /*[in]*/ VARIANT ForceLogin, VARIANT coBrandTemplate, VARIANT lang_id, VARIANT NameSpace, /*[in, optional]*/ VARIANT KPP, /*[in, optional]*/ VARIANT SecureLevel, /*[out,retval]*/ BSTR *pAuthUrl);
  93. // New API. call it to generate user logon. ASP caller will get a redirect.
  94. // isapi callers should not do any more work after this
  95. STDMETHOD(LoginUser)(/*[in]*/ VARIANT returnUrl,
  96. /*[in]*/ VARIANT TimeWindow,
  97. /*[in]*/ VARIANT ForceLogin,
  98. /*[in]*/ VARIANT coBrandTemplate,
  99. /*[in]*/ VARIANT lang_id,
  100. /*[in]*/ VARIANT NameSpace,
  101. /*[in, optional]*/ VARIANT KPP,
  102. /*[in, optional]*/ VARIANT SecureLevel,
  103. /*[in, optional]*/ VARIANT ExtraParams);
  104. //Active Server Pages Methods
  105. STDMETHOD(OnStartPage)(IUnknown* IUnk);
  106. STDMETHOD(OnStartPageManual)(BSTR qsT, BSTR qsP, BSTR mspauth, BSTR mspprof, BSTR mspconsent, VARIANT vmspsec, VARIANT *pCookies);
  107. STDMETHOD(OnStartPageECB)(/*[in]*/ LPBYTE pECB, /*[in,out]*/ DWORD *pBufSize, /*[out]*/ LPSTR pCookieHeader);
  108. STDMETHOD(OnStartPageFilter)(/*[in]*/ LPBYTE pPFC, /*[in,out]*/ DWORD *pBufSize, /*[out]*/ LPSTR pCookieHeader);
  109. STDMETHOD(OnStartPageASP)(/*[in]*/ IDispatch* pdispRequest, /*[in]*/ IDispatch* pdispResponse);
  110. STDMETHOD(OnEndPage)();
  111. STDMETHOD(_Ticket)(IPassportTicket** piTicket);
  112. STDMETHOD(_Profile)(IPassportProfile** piProfile);
  113. STDMETHOD(get_Domains)(VARIANT* pArrayVal);
  114. STDMETHOD(get_Error)(long* pErrorVal);
  115. // IPassportManager3
  116. STDMETHOD(get_Ticket)(/*[in]*/ BSTR attributeName, /*[out, retval]*/ VARIANT *pVal);
  117. STDMETHOD(GetCurrentConfig)(/*[in]*/ BSTR name, /*[out, retval]*/ VARIANT *pVal)
  118. {
  119. if (!m_pRegistryConfig)
  120. {
  121. AtlReportError(CLSID_Manager, PP_E_NOT_INITIALIZEDSTR,
  122. IID_IPassportManager, PP_E_NOT_INITIALIZED);
  123. return PP_E_NOT_INITIALIZED;
  124. }
  125. else
  126. return m_pRegistryConfig->GetCurrentConfig(name, pVal);
  127. };
  128. STDMETHOD(LogoutURL)(
  129. /* [optional][in] */ VARIANT returnUrl,
  130. /* [optional][in] */ VARIANT coBrandArgs,
  131. /* [optional][in] */ VARIANT lang_id,
  132. /* [optional][in] */ VARIANT NameSpace,
  133. /* [optional][in] */ VARIANT bSecure,
  134. /* [retval][out] */ BSTR *pVal);
  135. STDMETHOD(GetLoginChallenge)(/*[in]*/ VARIANT returnUrl,
  136. /*[in]*/ VARIANT TimeWindow,
  137. /*[in]*/ VARIANT ForceLogin,
  138. /*[in]*/ VARIANT coBrandTemplate,
  139. /*[in]*/ VARIANT lang_id,
  140. /*[in]*/ VARIANT NameSpace,
  141. /*[in, optional]*/ VARIANT KPP,
  142. /*[in, optional]*/ VARIANT SecureLevel,
  143. /*[in, optional]*/ VARIANT ExtraParams,
  144. // /*[out, optional]*/ VARIANT *pAuthHeader,
  145. /*[out, retval]*/ BSTR* pAuthHeader
  146. );
  147. STDMETHOD(get_HexPUID)(/*[out, retval]*/ BSTR *pVal);
  148. STDMETHOD(get_PUID)(/*[out, retval]*/ BSTR *pVal);
  149. STDMETHOD(OnStartPageHTTPRawEx)(
  150. /* [in] */ LPCSTR method,
  151. /* [in] */ LPCSTR path,
  152. /* [in] */ LPCSTR QS,
  153. /* [in] */ LPCSTR HTTPVer,
  154. /* [string][in] */ LPCSTR headers,
  155. /* [in] */ DWORD flags,
  156. /* [out][in] */ DWORD *bufSize,
  157. /* [size_is][out]*/ LPSTR pCookieHeader);
  158. STDMETHOD(OnStartPageHTTPRaw)(
  159. /* [string][in] */ LPCSTR request_line,
  160. /* [string][in] */ LPCSTR headers,
  161. /* [in] */ DWORD flags,
  162. /* [out][in] */ DWORD *pBufSize,
  163. /* [size_is][out] */ LPSTR pCookieHeader);
  164. STDMETHOD(ContinueStartPageHTTPRaw)(
  165. /* [in] */ DWORD bodyLen,
  166. /* [size_is][in] */ byte *body,
  167. /* [out][in] */ DWORD *pBufSize,
  168. /* [size_is][out] */ LPSTR pRespHeaders,
  169. /* [out][in] */ DWORD *pRespBodyLen,
  170. /* [size_is][out] */ byte *pRespBody);
  171. STDMETHOD(get_Option)(
  172. /* [in] */ BSTR name,
  173. /* [retval][out] */ VARIANT *pVal);
  174. STDMETHOD(put_Option)(
  175. /* [in] */ BSTR name,
  176. /* [in] */ VARIANT newVal);
  177. // IDomainMap
  178. public:
  179. // GetDomainAttribute and get_Domains declared above.
  180. STDMETHOD(DomainExists)(BSTR bstrDomainName, VARIANT_BOOL* pbExists);
  181. // IPassportService
  182. public:
  183. STDMETHOD(Initialize)(BSTR, IServiceProvider*);
  184. STDMETHOD(Shutdown)();
  185. STDMETHOD(ReloadState)(IServiceProvider*);
  186. STDMETHOD(CommitState)(IServiceProvider*);
  187. STDMETHOD(DumpState)( BSTR* );
  188. protected:
  189. void wipeState();
  190. // return S_OK -- altered, should use two returned output params for MSPAuth and MSPSecAuth as cookies
  191. HRESULT IfAlterAuthCookie(BSTR* pMSPAuth, BSTR* pMSPSecAuth);
  192. // return S_OK -- should use the generated MSPConsent cookie
  193. HRESULT IfConsentCookie(BSTR* pMSPConsent);
  194. private:
  195. STDMETHOD(GetLoginChallengeInternal)(/*[in]*/ VARIANT returnUrl,
  196. /*[in]*/ VARIANT TimeWindow,
  197. /*[in]*/ VARIANT ForceLogin,
  198. /*[in]*/ VARIANT coBrandTemplate,
  199. /*[in]*/ VARIANT lang_id,
  200. /*[in]*/ VARIANT NameSpace,
  201. /*[in, optional]*/ VARIANT KPP,
  202. /*[in, optional]*/ VARIANT SecureLevel,
  203. /*[in, optional]*/ VARIANT ExtraParams,
  204. /*[out, optional]*/ VARIANT *pAuthHeader,
  205. /*[out, retval]*/ BSTR* pAuthVal
  206. );
  207. STDMETHOD(CommonAuthURL)(VARIANT returnUrl,
  208. VARIANT TimeWindow,
  209. VARIANT ForceLogin,
  210. VARIANT coBrandTemplate,
  211. VARIANT lang_id,
  212. VARIANT NameSpace,
  213. VARIANT KPP,
  214. VARIANT SecureLevel,
  215. BOOL fRedirToSelf,
  216. VARIANT functionArea,
  217. BSTR *pAuthUrl);
  218. BOOL handleQueryStringData(BSTR a, BSTR p);
  219. BOOL handleCookieData(BSTR a, BSTR p, BSTR c, BSTR s);
  220. BOOL checkForPassportChallenge(IRequestDictionaryPtr piServerVariables);
  221. BOOL HeaderFromQS(PWSTR pszQS, _bstr_t& bstrHeader);
  222. STDMETHODIMP FormatAuthHeaderFromParams(PCWSTR pszLoginUrl, // unused for now
  223. PCWSTR pszRetUrl,
  224. ULONG ulTimeWindow,
  225. BOOL fForceLogin,
  226. time_t ct,
  227. PCWSTR pszCBT, // unused for now
  228. PCWSTR pszNamespace,
  229. int nKpp,
  230. PWSTR pszlcid,
  231. ULONG ulSecLevel,
  232. _bstr_t& strHeader // return result
  233. );
  234. STDMETHOD(CommonLogoTag)(VARIANT returnUrl,
  235. VARIANT TimeWindow,
  236. VARIANT ForceLogin,
  237. VARIANT coBrandTemplate,
  238. VARIANT lang_id,
  239. VARIANT bSecure,
  240. VARIANT NameSpace,
  241. VARIANT KPP,
  242. VARIANT SecureLevel,
  243. BOOL fRedirToSelf,
  244. BSTR *pVal);
  245. // helper for coming up with login paramers based on
  246. // what the site passed in and registry configs
  247. // someone should put all these in a class, so the number of
  248. // params stays manageable
  249. STDMETHOD(GetLoginParams)(// this is what the caller passed in
  250. VARIANT vRU,
  251. VARIANT vTimeWindow,
  252. VARIANT vForceLogin,
  253. VARIANT vCoBrand,
  254. VARIANT vLCID,
  255. VARIANT vNameSpace,
  256. VARIANT vKPP,
  257. VARIANT vSecureLevel,
  258. // these are the processed values
  259. _bstr_t& url,
  260. _bstr_t& returnUrl,
  261. UINT& TimeWindow,
  262. VARIANT_BOOL& ForceLogin,
  263. time_t& ct,
  264. _bstr_t& strCBT,
  265. _bstr_t& strNameSpace,
  266. int& nKpp,
  267. ULONG& ulSecureLevel,
  268. PWSTR pszlcid);
  269. VARIANT_BOOL m_profileValid;
  270. VARIANT_BOOL m_ticketValid;
  271. CComObject<CTicket> *m_piTicket;
  272. CComObject<CProfile> *m_piProfile;
  273. CRegistryConfig* m_pRegistryConfig;
  274. IRequestPtr m_piRequest; //Request Object
  275. IResponsePtr m_piResponse; //Response Object
  276. bool m_bOnStartPageCalled; //OnStartPage successful?
  277. bool m_fromQueryString;
  278. // for ISAPI ....
  279. EXTENSION_CONTROL_BLOCK *m_pECB;
  280. PHTTP_FILTER_CONTEXT m_pFC;
  281. // is it 1.4 capable client?
  282. BOOL m_bIsTweenerCapable;
  283. long m_lNetworkError;
  284. // secure sign in
  285. bool m_bSecureTransported;
  286. CComVariant m_iModeOption;
  287. BOOL IfCreateTPF()
  288. {
  289. if (V_VT(&m_iModeOption) == VT_BOOL && V_BOOL(&m_iModeOption) == VARIANT_TRUE)
  290. return FALSE;
  291. return TRUE;
  292. }
  293. };
  294. #endif //__MANAGER_H_