[40435] | 1 | /* $Id: VBoxCredProvProvider.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBoxCredProvProvider - The actual credential provider class.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
[40435] | 8 | *
|
---|
[96407] | 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
|
---|
[40435] | 26 | */
|
---|
| 27 |
|
---|
[76563] | 28 | #ifndef GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvProvider_h
|
---|
| 29 | #define GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvProvider_h
|
---|
[76540] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[40435] | 33 |
|
---|
[85121] | 34 | #include <iprt/win/credentialprovider.h>
|
---|
[62679] | 35 | #include <iprt/win/windows.h>
|
---|
[40435] | 36 |
|
---|
| 37 | #include <VBox/VBoxGuestLib.h>
|
---|
| 38 |
|
---|
| 39 | #include "VBoxCredProvCredential.h"
|
---|
| 40 | #include "VBoxCredProvPoller.h"
|
---|
| 41 |
|
---|
| 42 | class VBoxCredProvProvider : public ICredentialProvider
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 |
|
---|
| 46 | /** @name IUnknown methods.
|
---|
| 47 | * @{ */
|
---|
| 48 | IFACEMETHODIMP_(ULONG) AddRef(void);
|
---|
| 49 | IFACEMETHODIMP_(ULONG) Release(void);
|
---|
| 50 | IFACEMETHODIMP QueryInterface(REFIID interfaceID, void **ppvInterface);
|
---|
| 51 | /** @} */
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | /** @name ICredentialProvider interface
|
---|
| 55 | * @{ */
|
---|
| 56 | IFACEMETHODIMP SetUsageScenario(CREDENTIAL_PROVIDER_USAGE_SCENARIO cpUsageScenario, DWORD dwFlags);
|
---|
| 57 | IFACEMETHODIMP SetSerialization(const CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION *pcpCredentialSerialization);
|
---|
| 58 |
|
---|
| 59 | IFACEMETHODIMP Advise(__in ICredentialProviderEvents *pcpEvents, UINT_PTR upAdviseContext);
|
---|
| 60 | IFACEMETHODIMP UnAdvise();
|
---|
| 61 |
|
---|
| 62 | IFACEMETHODIMP GetFieldDescriptorCount(__out DWORD* pdwCount);
|
---|
| 63 | IFACEMETHODIMP GetFieldDescriptorAt(DWORD dwIndex, __deref_out CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR **ppFieldDescriptor);
|
---|
| 64 |
|
---|
| 65 | IFACEMETHODIMP GetCredentialCount(__out DWORD *pdwCount,
|
---|
| 66 | __out DWORD *pdwDefault,
|
---|
| 67 | __out BOOL *pfAutoLogonWithDefault);
|
---|
| 68 | IFACEMETHODIMP GetCredentialAt(DWORD dwIndex,
|
---|
[65099] | 69 | __out ICredentialProviderCredential **ppCredProvCredential);
|
---|
[40435] | 70 | /** @} */
|
---|
| 71 |
|
---|
[65099] | 72 | friend HRESULT VBoxCredProvProviderCreate(REFIID riid, __deref_out void **ppvInterface);
|
---|
[40435] | 73 |
|
---|
| 74 | protected:
|
---|
| 75 |
|
---|
| 76 | VBoxCredProvProvider(void);
|
---|
| 77 | virtual ~VBoxCredProvProvider(void);
|
---|
| 78 |
|
---|
| 79 | public:
|
---|
| 80 |
|
---|
| 81 | /** Loads the configuration from the registry. */
|
---|
| 82 | DWORD LoadConfiguration(void);
|
---|
| 83 | /** Determines whether the current session this provider is
|
---|
| 84 | * loaded into needs to be handled or not. */
|
---|
| 85 | bool HandleCurrentSession(void);
|
---|
| 86 | /** Event which gets triggered by the poller thread in case
|
---|
| 87 | * there are credentials available from the host. */
|
---|
| 88 | void OnCredentialsProvided(void);
|
---|
| 89 |
|
---|
| 90 | private:
|
---|
| 91 |
|
---|
| 92 | /** Interface reference count. */
|
---|
| 93 | LONG m_cRefs;
|
---|
| 94 | /** Our one and only credential. */
|
---|
| 95 | VBoxCredProvCredential *m_pCred;
|
---|
| 96 | /** Poller thread for credential lookup. */
|
---|
| 97 | VBoxCredProvPoller *m_pPoller;
|
---|
| 98 | /** Used to tell our owner to re-enumerate credentials. */
|
---|
| 99 | ICredentialProviderEvents *m_pEvents;
|
---|
| 100 | /** Used to tell our owner who we are when asking to re-enumerate credentials. */
|
---|
| 101 | UINT_PTR m_upAdviseContext;
|
---|
| 102 | /** Saved usage scenario. */
|
---|
| 103 | CREDENTIAL_PROVIDER_USAGE_SCENARIO m_enmUsageScenario;
|
---|
| 104 | /** Flag whether we need to handle remote session over Windows Remote
|
---|
| 105 | * Desktop Service. */
|
---|
| 106 | bool m_fHandleRemoteSessions;
|
---|
| 107 | };
|
---|
| 108 |
|
---|
[76563] | 109 | #endif /* !GA_INCLUDED_SRC_WINNT_VBoxCredProv_VBoxCredProvProvider_h */
|
---|
[40435] | 110 |
|
---|