1 | /* $Id: VBoxCredProvCredential.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxCredProvCredential - Class for keeping and handling the passed credentials.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvCredential_h
|
---|
29 | #define GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvCredential_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | #include <iprt/win/windows.h>
|
---|
36 | #include <NTSecAPI.h>
|
---|
37 | #define SECURITY_WIN32
|
---|
38 | #include <Security.h>
|
---|
39 | #include <ShlGuid.h>
|
---|
40 |
|
---|
41 | #include <iprt/win/shlwapi.h>
|
---|
42 |
|
---|
43 | #include <iprt/string.h>
|
---|
44 |
|
---|
45 | #include "VBoxCredentialProvider.h"
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 | class VBoxCredProvProvider;
|
---|
50 |
|
---|
51 | class VBoxCredProvCredential : public ICredentialProviderCredential
|
---|
52 | {
|
---|
53 | public:
|
---|
54 |
|
---|
55 | VBoxCredProvCredential(void);
|
---|
56 |
|
---|
57 | virtual ~VBoxCredProvCredential(void);
|
---|
58 |
|
---|
59 | /** @name IUnknown methods
|
---|
60 | * @{ */
|
---|
61 | IFACEMETHODIMP_(ULONG) AddRef(void);
|
---|
62 | IFACEMETHODIMP_(ULONG) Release(void);
|
---|
63 | IFACEMETHODIMP QueryInterface(REFIID interfaceID, void **ppvInterface);
|
---|
64 | /** @} */
|
---|
65 |
|
---|
66 | /** @name ICredentialProviderCredential methods.
|
---|
67 | * @{ */
|
---|
68 | IFACEMETHODIMP Advise(ICredentialProviderCredentialEvents* pcpce);
|
---|
69 | IFACEMETHODIMP UnAdvise(void);
|
---|
70 |
|
---|
71 | IFACEMETHODIMP SetSelected(PBOOL pfAutoLogon);
|
---|
72 | IFACEMETHODIMP SetDeselected(void);
|
---|
73 |
|
---|
74 | IFACEMETHODIMP GetFieldState(DWORD dwFieldID,
|
---|
75 | CREDENTIAL_PROVIDER_FIELD_STATE* pcpfs,
|
---|
76 | CREDENTIAL_PROVIDER_FIELD_INTERACTIVE_STATE* pcpfis);
|
---|
77 |
|
---|
78 | IFACEMETHODIMP GetStringValue(DWORD dwFieldID, PWSTR *ppwsz);
|
---|
79 | IFACEMETHODIMP GetBitmapValue(DWORD dwFieldID, HBITMAP *phbmp);
|
---|
80 | IFACEMETHODIMP GetCheckboxValue(DWORD dwFieldID, PBOOL pfChecked, PWSTR *ppwszLabel);
|
---|
81 | IFACEMETHODIMP GetComboBoxValueCount(DWORD dwFieldID, DWORD* pcItems, DWORD *pdwSelectedItem);
|
---|
82 | IFACEMETHODIMP GetComboBoxValueAt(DWORD dwFieldID, DWORD dwItem, PWSTR *ppwszItem);
|
---|
83 | IFACEMETHODIMP GetSubmitButtonValue(DWORD dwFieldID, DWORD *pdwAdjacentTo);
|
---|
84 |
|
---|
85 | IFACEMETHODIMP SetStringValue(DWORD dwFieldID, PCWSTR pwszValue);
|
---|
86 | IFACEMETHODIMP SetCheckboxValue(DWORD dwFieldID, BOOL fChecked);
|
---|
87 | IFACEMETHODIMP SetComboBoxSelectedValue(DWORD dwFieldID, DWORD dwSelectedItem);
|
---|
88 | IFACEMETHODIMP CommandLinkClicked(DWORD dwFieldID);
|
---|
89 |
|
---|
90 | IFACEMETHODIMP GetSerialization(CREDENTIAL_PROVIDER_GET_SERIALIZATION_RESPONSE *pcpGetSerializationResponse,
|
---|
91 | CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION *pcpCredentialSerialization,
|
---|
92 | PWSTR *ppwszOptionalStatusText, CREDENTIAL_PROVIDER_STATUS_ICON *pcpsiOptionalStatusIcon);
|
---|
93 | IFACEMETHODIMP ReportResult(NTSTATUS ntStatus, NTSTATUS ntSubStatus,
|
---|
94 | PWSTR *ppwszOptionalStatusText,
|
---|
95 | CREDENTIAL_PROVIDER_STATUS_ICON* pcpsiOptionalStatusIcon);
|
---|
96 | /** @} */
|
---|
97 |
|
---|
98 | PCRTUTF16 getField(DWORD dwFieldID);
|
---|
99 | HRESULT setField(DWORD dwFieldID, const PRTUTF16 pcwszString, bool fNotifyUI);
|
---|
100 | HRESULT Reset(void);
|
---|
101 | HRESULT Initialize(CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus);
|
---|
102 | int RetrieveCredentials(void);
|
---|
103 | BOOL TranslateAccountName(PWSTR pwszDisplayName, PWSTR *ppwszAccoutName);
|
---|
104 | static bool ExtractAccountData(PWSTR pwszAccountData, PWSTR *ppwszAccountName, PWSTR *ppwszDomain);
|
---|
105 |
|
---|
106 | protected:
|
---|
107 | HRESULT RTUTF16ToUnicode(PUNICODE_STRING pUnicodeDest, PRTUTF16 pwszSource, bool fCopy);
|
---|
108 | HRESULT RTUTF16ToUnicodeA(PUNICODE_STRING pUnicodeDest, PRTUTF16 pwszSource);
|
---|
109 | void UnicodeStringFree(PUNICODE_STRING pUnicode);
|
---|
110 |
|
---|
111 | HRESULT kerberosLogonCreate(KERB_INTERACTIVE_LOGON *pLogon,
|
---|
112 | CREDENTIAL_PROVIDER_USAGE_SCENARIO enmUsage,
|
---|
113 | PRTUTF16 pwszUser, PRTUTF16 pwszPassword, PRTUTF16 pwszDomain);
|
---|
114 | void kerberosLogonDestroy(KERB_INTERACTIVE_LOGON *pLogon);
|
---|
115 | HRESULT kerberosLogonSerialize(const KERB_INTERACTIVE_LOGON *pLogon, PBYTE *ppPackage, DWORD *pcbPackage);
|
---|
116 |
|
---|
117 | private:
|
---|
118 | /** Internal reference count. */
|
---|
119 | LONG m_cRefs;
|
---|
120 | /** The usage scenario for which we were enumerated. */
|
---|
121 | CREDENTIAL_PROVIDER_USAGE_SCENARIO m_enmUsageScenario;
|
---|
122 | /** The actual credential provider fields.
|
---|
123 | * Must be allocated as long as the credential provider is in charge. */
|
---|
124 | PRTUTF16 m_apwszFields[VBOXCREDPROV_NUM_FIELDS];
|
---|
125 | /** Pointer to event handler. */
|
---|
126 | ICredentialProviderCredentialEvents *m_pEvents;
|
---|
127 | /** Flag indicating whether credentials already were retrieved. */
|
---|
128 | bool m_fHaveCreds;
|
---|
129 | /** Flag indicating wheter a profile (user tile) current is selected or not. */
|
---|
130 | bool m_fIsSelected;
|
---|
131 | };
|
---|
132 | #endif /* !GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvCredential_h */
|
---|
133 |
|
---|