Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
file_profile.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27
28#ifndef API_MIP_FILE_FILE_PROFILE_H_
29#define API_MIP_FILE_FILE_PROFILE_H_
30
31#include <memory>
32#include <string>
33#include <vector>
34
35#include "mip/common_types.h"
36#include "mip/dns_redirection.h"
37#include "mip/error.h"
40#include "mip/http_delegate.h"
41#include "mip/logger_delegate.h"
42#include "mip/mip_context.h"
43#include "mip/mip_namespace.h"
45
46MIP_NAMESPACE_BEGIN
47
54public:
55
62 class Observer {
63 public:
64 virtual ~Observer() {}
65
69 virtual void OnLoadSuccess(
70 const std::shared_ptr<mip::FileProfile>& profile,
71 const std::shared_ptr<void>& context) { UNUSED(profile); UNUSED(context); }
72
76 virtual void OnLoadFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) {
77 UNUSED(error); UNUSED(context); }
78
83 const std::vector<std::string>& engineIds,
84 const std::shared_ptr<void>& context) { UNUSED(engineIds); UNUSED(context); }
85
90 const std::exception_ptr& error,
91 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
92
96 virtual void OnUnloadEngineSuccess(const std::shared_ptr<void>& context) { UNUSED(context); }
97
102 const std::exception_ptr& error,
103 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
104
108 virtual void OnAddEngineSuccess(
109 const std::shared_ptr<mip::FileEngine>& engine,
110 const std::shared_ptr<void>& context) { UNUSED(engine); UNUSED(context); }
111
115 virtual void OnAddEngineFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) {
116 UNUSED(error); UNUSED(context); }
117
121 virtual void OnDeleteEngineSuccess(const std::shared_ptr<void>& context) { UNUSED(context); }
122
127 const std::exception_ptr& error,
128 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
129
133 virtual void OnPolicyChanged(const std::string& engineId) { UNUSED(engineId); }
134
144 virtual void OnAddPolicyEngineStarting(bool requiresPolicyFetch) { UNUSED(requiresPolicyFetch); }
145
146 protected:
148 };
149
153 class Settings {
154 public:
164 const std::shared_ptr<MipContext>& mipContext,
165 CacheStorageType cacheStorageType,
166 std::shared_ptr<ConsentDelegate> consentDelegate,
167 std::shared_ptr<Observer> observer)
168 : mMipContext(mipContext),
169 mCacheStorageType(cacheStorageType),
170 mConsentDelegate(consentDelegate),
171 mObserver(observer),
172 mCanCacheLicenses(true),
174
176 ~Settings() {}
185
191 std::shared_ptr<ConsentDelegate> GetConsentDelegate() const { return mConsentDelegate; }
192
198 std::shared_ptr<Observer> GetObserver() const { return mObserver; }
199
205 std::shared_ptr<MipContext> GetMipContext() const { return mMipContext; }
206
212 std::shared_ptr<HttpDelegate> GetHttpDelegate() const { return mHttpDelegate; }
213
219 void SetHttpDelegate(const std::shared_ptr<HttpDelegate>& httpDelegate) { mHttpDelegate = httpDelegate; }
220
226 std::shared_ptr<TaskDispatcherDelegate> GetTaskDispatcherDelegate() const { return mTaskDispatcherDelegate; }
227
236 void SetTaskDispatcherDelegate(const std::shared_ptr<TaskDispatcherDelegate>& taskDispatcherDelegate) {
237 mTaskDispatcherDelegate = taskDispatcherDelegate;
238 }
239
245 void SetSessionId(const std::string& sessionId) {
246 mSessionId = sessionId;
247 }
248
254 const std::string& GetSessionId() const {
255 return mSessionId;
256 }
257
266 void SetCanCacheLicenses(bool canCacheLicenses) {
267 mCanCacheLicenses = canCacheLicenses;
268 }
269
275 bool CanCacheLicenses() const {
276 return mCanCacheLicenses;
277 }
278
279#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
285 const std::shared_ptr<void>& GetLoggerContext() const { return mLoggerContext; }
286#endif
293 void SetLoggerContext(const std::shared_ptr<void>& loggerContext) {
294 mLoggerContext = loggerContext;
295 }
296
305
311 void SetDnsRedirection(DnsRedirection dnsRedirection) {
312 mDnsRedirection = dnsRedirection;
313 }
314
315 private:
316 std::shared_ptr<MipContext> mMipContext;
317 std::string mPath;
319 std::shared_ptr<ConsentDelegate> mConsentDelegate;
320 std::shared_ptr<Observer> mObserver;
321 std::string mSessionId;
322 std::shared_ptr<HttpDelegate> mHttpDelegate;
323 std::shared_ptr<TaskDispatcherDelegate> mTaskDispatcherDelegate;
325 std::shared_ptr<void> mLoggerContext;
327 };
328
335 FILE_API static std::shared_ptr<AsyncControl> __CDECL LoadAsync(
336 const Settings& settings,
337 const std::shared_ptr<void>& context);
338
344 FILE_API static const char* __CDECL GetVersion();
345
347 virtual ~FileProfile() {}
353 virtual const Settings& GetSettings() const = 0;
354
361 virtual std::shared_ptr<AsyncControl> ListEnginesAsync(const std::shared_ptr<void>& context) = 0;
362
369 virtual std::shared_ptr<AsyncControl> UnloadEngineAsync(
370 const std::string& id,
371 const std::shared_ptr<void>& context) = 0;
372
379 virtual std::shared_ptr<AsyncControl> AddEngineAsync(
380 const FileEngine::Settings& settings,
381 const std::shared_ptr<void>& context) = 0;
382
389 virtual std::shared_ptr<AsyncControl> DeleteEngineAsync(
390 const std::string& id,
391 const std::shared_ptr<void>& context) = 0;
392
403 virtual void AcquirePolicyAuthToken(Cloud cloud, const std::shared_ptr<AuthDelegate>& authDelegate) const = 0;
404
405protected:
407 FileProfile() {}
409};
410
411MIP_NAMESPACE_END
412
413#endif // API_MIP_FILE_FILE_PROFILE_H_
Observer interface for clients to get notifications for profile related events.
Definition file_profile.h:62
virtual void OnDeleteEngineSuccess(const std::shared_ptr< void > &context)
Called when an engine was deleted successfully.
Definition file_profile.h:121
virtual void OnListEnginesSuccess(const std::vector< std::string > &engineIds, const std::shared_ptr< void > &context)
Called when list of engines was generated successfully.
Definition file_profile.h:82
virtual void OnLoadSuccess(const std::shared_ptr< mip::FileProfile > &profile, const std::shared_ptr< void > &context)
Called when profile was loaded successfully.
Definition file_profile.h:69
virtual void OnAddPolicyEngineStarting(bool requiresPolicyFetch)
Called prior to engine creation to describe whether or not the policy engine's policy data must be fe...
Definition file_profile.h:144
virtual void OnAddEngineFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when adding a new engine caused an error.
Definition file_profile.h:115
virtual void OnAddEngineSuccess(const std::shared_ptr< mip::FileEngine > &engine, const std::shared_ptr< void > &context)
Called when a new engine was added successfully.
Definition file_profile.h:108
virtual void OnUnloadEngineFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when unloading an engine caused an error.
Definition file_profile.h:101
virtual void OnListEnginesFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when listing engines caused an error.
Definition file_profile.h:89
virtual void OnLoadFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when loading a profile caused an error.
Definition file_profile.h:76
virtual void OnDeleteEngineFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when deleting an engine caused an error.
Definition file_profile.h:126
virtual ~Observer()
Definition file_profile.h:64
virtual void OnUnloadEngineSuccess(const std::shared_ptr< void > &context)
Called when an engine was unloaded successfully.
Definition file_profile.h:96
Observer()
Definition file_profile.h:147
virtual void OnPolicyChanged(const std::string &engineId)
Called when the policy has changed for the engine with the given ID.
Definition file_profile.h:133
Settings used by FileProfile during its creation and throughout its lifetime.
Definition file_profile.h:153
void SetCanCacheLicenses(bool canCacheLicenses)
Configures whether or not end user licenses (EULs) will be cached locally.
Definition file_profile.h:266
CacheStorageType GetCacheStorageType() const
Get whether caches are stored in memory or on disk.
Definition file_profile.h:184
DnsRedirection mDnsRedirection
Definition file_profile.h:326
std::shared_ptr< HttpDelegate > mHttpDelegate
Definition file_profile.h:322
void SetTaskDispatcherDelegate(const std::shared_ptr< TaskDispatcherDelegate > &taskDispatcherDelegate)
Override default asynchonous task dispatching handling with client's own.
Definition file_profile.h:236
std::shared_ptr< Observer > GetObserver() const
Gets the observer that receives notifications of events related to FileProfile.
Definition file_profile.h:198
std::string mSessionId
Definition file_profile.h:321
std::shared_ptr< ConsentDelegate > mConsentDelegate
Definition file_profile.h:319
std::shared_ptr< TaskDispatcherDelegate > mTaskDispatcherDelegate
Definition file_profile.h:323
void SetHttpDelegate(const std::shared_ptr< HttpDelegate > &httpDelegate)
Override default HTTP stack with client's own.
Definition file_profile.h:219
std::string mPath
Definition file_profile.h:317
Settings(const std::shared_ptr< MipContext > &mipContext, CacheStorageType cacheStorageType, std::shared_ptr< ConsentDelegate > consentDelegate, std::shared_ptr< Observer > observer)
FileProfile::Settings constructor.
Definition file_profile.h:163
std::shared_ptr< MipContext > mMipContext
Definition file_profile.h:316
CacheStorageType mCacheStorageType
Definition file_profile.h:318
bool CanCacheLicenses() const
Gets whether or not end user licenses (EULs) are cached locally.
Definition file_profile.h:275
bool mCanCacheLicenses
Definition file_profile.h:324
const std::string & GetSessionId() const
Gets the session ID.
Definition file_profile.h:254
std::shared_ptr< ConsentDelegate > GetConsentDelegate() const
Gets the consent delegate used to request user consent connecting to services.
Definition file_profile.h:191
DnsRedirection GetDnsRedirection() const
Gets the dns redirect mode.
Definition file_profile.h:302
void SetSessionId(const std::string &sessionId)
Sets the session ID.
Definition file_profile.h:245
std::shared_ptr< MipContext > GetMipContext() const
Get MIP context which represents shared state across all profiles.
Definition file_profile.h:205
std::shared_ptr< void > mLoggerContext
Definition file_profile.h:325
std::shared_ptr< Observer > mObserver
Definition file_profile.h:320
const std::shared_ptr< void > & GetLoggerContext() const
Get logger context that will be opaquely passed to the logger delegate for logs associated with the c...
Definition file_profile.h:285
std::shared_ptr< HttpDelegate > GetHttpDelegate() const
Get the HTTP delegate (if any) provided by the application.
Definition file_profile.h:212
void SetDnsRedirection(DnsRedirection dnsRedirection)
Sets the dns redirection mode that controls how redirection is handled during online operations.
Definition file_profile.h:311
std::shared_ptr< TaskDispatcherDelegate > GetTaskDispatcherDelegate() const
Get the TaskDispatcher delegate (if any) provided by the application.
Definition file_profile.h:226
void SetLoggerContext(const std::shared_ptr< void > &loggerContext)
Sets the logger context that will be opaquely passed to the logger delegate for logs associated with ...
Definition file_profile.h:293
FileProfile class is the root class for using the Microsoft Information Protection operations.
Definition file_profile.h:53
virtual std::shared_ptr< AsyncControl > ListEnginesAsync(const std::shared_ptr< void > &context)=0
Starts list engines operation.
virtual void AcquirePolicyAuthToken(Cloud cloud, const std::shared_ptr< AuthDelegate > &authDelegate) const =0
Trigger an authentication callback for policy.
static FILE_API std::shared_ptr< AsyncControl > __CDECL LoadAsync(const Settings &settings, const std::shared_ptr< void > &context)
Starts loading a profile based on the provided |settings|.
virtual std::shared_ptr< AsyncControl > DeleteEngineAsync(const std::string &id, const std::shared_ptr< void > &context)=0
Starts deleting the file engine with the given ID. All data for the given profile will be deleted.
virtual const Settings & GetSettings() const =0
Returns the profile settings.
virtual std::shared_ptr< AsyncControl > UnloadEngineAsync(const std::string &id, const std::shared_ptr< void > &context)=0
Starts unloading the file engine with the given ID.
virtual std::shared_ptr< AsyncControl > AddEngineAsync(const FileEngine::Settings &settings, const std::shared_ptr< void > &context)=0
Starts adding a new file engine to the profile.
static FILE_API const char *__CDECL GetVersion()
Gets library version.
A file Containing the common types used by the upe, file and protection modules.
Cloud
Azure cloud identifier.
Definition common_types.h:728
CacheStorageType
Storage type for the caches.
Definition common_types.h:710
A file Containing types used to control dns redirection.
DnsRedirection
Storage type for the caches.
Definition dns_redirection.h:43
A file containing the MIP SDK error types.
#define FILE_API
Definition file_export.h:49
Contains HttpDelegate interface definition used to override MIP HTTP stack.
A file containing the LoggerDelegate class to be used to override MIP logger.
File containing definition of MipContext.
MIP namespace macros.
A file containing the TaskDispatcherDelegate interface to be used to override MIP async task executor...