1 | /* $Id: VBoxCredProvCredential.h 46385 2013-06-04 14:12:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxCredProvCredential - Class for keeping and handling the passed credentials.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___VBOX_CREDPROV_CREDENTIAL_H___
|
---|
19 | #define ___VBOX_CREDPROV_CREDENTIAL_H___
|
---|
20 |
|
---|
21 |
|
---|
22 | /*******************************************************************************
|
---|
23 | * Header Files *
|
---|
24 | *******************************************************************************/
|
---|
25 | #include <Windows.h>
|
---|
26 | #include <NTSecAPI.h>
|
---|
27 | #define SECURITY_WIN32
|
---|
28 | #include <Security.h>
|
---|
29 | #include <ShlGuid.h>
|
---|
30 | #include <strsafe.h>
|
---|
31 |
|
---|
32 | #pragma warning(push)
|
---|
33 | #pragma warning(disable : 4995)
|
---|
34 | #include <Shlwapi.h>
|
---|
35 | #pragma warning(pop)
|
---|
36 |
|
---|
37 | #include <iprt/string.h>
|
---|
38 |
|
---|
39 | #include "VBoxCredentialProvider.h"
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | class VBoxCredProvProvider;
|
---|
44 |
|
---|
45 | class VBoxCredProvCredential : public ICredentialProviderCredential
|
---|
46 | {
|
---|
47 | public:
|
---|
48 |
|
---|
49 | VBoxCredProvCredential(void);
|
---|
50 |
|
---|
51 | virtual ~VBoxCredProvCredential(void);
|
---|
52 |
|
---|
53 | /** @name IUnknown methods
|
---|
54 | * @{ */
|
---|
55 | IFACEMETHODIMP_(ULONG) AddRef(void);
|
---|
56 | IFACEMETHODIMP_(ULONG) Release(void);
|
---|
57 | IFACEMETHODIMP QueryInterface(REFIID interfaceID, void **ppvInterface);
|
---|
58 | /** @} */
|
---|
59 |
|
---|
60 | /** @name ICredentialProviderCredential methods.
|
---|
61 | * @{ */
|
---|
62 | IFACEMETHODIMP Advise(ICredentialProviderCredentialEvents* pcpce);
|
---|
63 | IFACEMETHODIMP UnAdvise(void);
|
---|
64 |
|
---|
65 | IFACEMETHODIMP SetSelected(PBOOL pfAutoLogon);
|
---|
66 | IFACEMETHODIMP SetDeselected(void);
|
---|
67 |
|
---|
68 | IFACEMETHODIMP GetFieldState(DWORD dwFieldID,
|
---|
69 | CREDENTIAL_PROVIDER_FIELD_STATE* pcpfs,
|
---|
70 | CREDENTIAL_PROVIDER_FIELD_INTERACTIVE_STATE* pcpfis);
|
---|
71 |
|
---|
72 | IFACEMETHODIMP GetStringValue(DWORD dwFieldID, PWSTR *ppwsz);
|
---|
73 | IFACEMETHODIMP GetBitmapValue(DWORD dwFieldID, HBITMAP *phbmp);
|
---|
74 | IFACEMETHODIMP GetCheckboxValue(DWORD dwFieldID, PBOOL pfChecked, PWSTR *ppwszLabel);
|
---|
75 | IFACEMETHODIMP GetComboBoxValueCount(DWORD dwFieldID, DWORD* pcItems, DWORD *pdwSelectedItem);
|
---|
76 | IFACEMETHODIMP GetComboBoxValueAt(DWORD dwFieldID, DWORD dwItem, PWSTR *ppwszItem);
|
---|
77 | IFACEMETHODIMP GetSubmitButtonValue(DWORD dwFieldID, DWORD *pdwAdjacentTo);
|
---|
78 |
|
---|
79 | IFACEMETHODIMP SetStringValue(DWORD dwFieldID, PCWSTR pcwzString);
|
---|
80 | IFACEMETHODIMP SetCheckboxValue(DWORD dwFieldID, BOOL fChecked);
|
---|
81 | IFACEMETHODIMP SetComboBoxSelectedValue(DWORD dwFieldID, DWORD dwSelectedItem);
|
---|
82 | IFACEMETHODIMP CommandLinkClicked(DWORD dwFieldID);
|
---|
83 |
|
---|
84 | IFACEMETHODIMP GetSerialization(CREDENTIAL_PROVIDER_GET_SERIALIZATION_RESPONSE *pcpGetSerializationResponse,
|
---|
85 | CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION *pcpCredentialSerialization,
|
---|
86 | PWSTR *ppwszOptionalStatusText, CREDENTIAL_PROVIDER_STATUS_ICON *pcpsiOptionalStatusIcon);
|
---|
87 | IFACEMETHODIMP ReportResult(NTSTATUS ntStatus, NTSTATUS ntSubStatus,
|
---|
88 | PWSTR *ppwszOptionalStatusText,
|
---|
89 | CREDENTIAL_PROVIDER_STATUS_ICON* pcpsiOptionalStatusIcon);
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | HRESULT Reset(void);
|
---|
93 | HRESULT Initialize(CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus);
|
---|
94 | int RetrieveCredentials(void);
|
---|
95 | BOOL TranslateAccountName(PWSTR pwszDisplayName, PWSTR *ppwszAccoutName);
|
---|
96 | BOOL ExtractAccoutData(PWSTR pwszAccountData, PWSTR *ppwszAccoutName, PWSTR *ppwszDomain);
|
---|
97 |
|
---|
98 | protected:
|
---|
99 | HRESULT RTUTF16ToUnicode(PUNICODE_STRING pUnicodeDest, PRTUTF16 pwszSource, bool fCopy);
|
---|
100 | HRESULT AllocateLogonPackage(const KERB_INTERACTIVE_UNLOCK_LOGON &rUnlockLogon,
|
---|
101 | BYTE **ppPackage, DWORD *pcbPackage);
|
---|
102 |
|
---|
103 | private:
|
---|
104 | /** Internal reference count. */
|
---|
105 | LONG m_cRefs;
|
---|
106 | /** The usage scenario for which we were enumerated. */
|
---|
107 | CREDENTIAL_PROVIDER_USAGE_SCENARIO m_enmUsageScenario;
|
---|
108 | /** The actual credential strings. */
|
---|
109 | PRTUTF16 m_apwszCredentials[VBOXCREDPROV_NUM_FIELDS];
|
---|
110 | /** Pointer to event handler. */
|
---|
111 | ICredentialProviderCredentialEvents *m_pEvents;
|
---|
112 | /** Flag indicating whether credentials already were retrieved. */
|
---|
113 | bool m_fHaveCreds;
|
---|
114 | };
|
---|
115 | #endif /* !___VBOX_CREDPROV_CREDENTIAL_H___ */
|
---|
116 |
|
---|