Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
policy_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 */
34#ifndef API_MIP_UPE_POLICY_PROFILE_H_
35#define API_MIP_UPE_POLICY_PROFILE_H_
36
37#include <memory>
38#include <string>
39#include <vector>
40
41#include "mip/common_types.h"
42#include "mip/error.h"
43#include "mip/http_delegate.h"
44#include "mip/logger_delegate.h"
45#include "mip/mip_context.h"
46#include "mip/mip_export.h"
47#include "mip/mip_namespace.h"
50
51MIP_NAMESPACE_BEGIN
52
57class PolicyProfile {
58public:
65 class Observer {
66 public:
67
74 virtual void OnLoadSuccess(
75 const std::shared_ptr<PolicyProfile>& profile,
76 const std::shared_ptr<void>& context) { UNUSED(profile); UNUSED(context); }
77
84 virtual void OnLoadFailure(
85 const std::exception_ptr& error,
86 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
87
94 virtual void OnListEnginesSuccess(
95 const std::vector<std::string>& engineIds,
96 const std::shared_ptr<void>& context) { UNUSED(engineIds); UNUSED(context); }
97
104 virtual void OnListEnginesFailure(
105 const std::exception_ptr& error,
106 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
107
113 virtual void OnUnloadEngineSuccess(const std::shared_ptr<void>& context) { UNUSED(context); }
114
121 virtual void OnUnloadEngineFailure(
122 const std::exception_ptr& error,
123 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
124
131 virtual void OnAddEngineSuccess(
132 const std::shared_ptr<PolicyEngine>& engine,
133 const std::shared_ptr<void>& context) { UNUSED(engine); UNUSED(context); }
134
144 virtual void OnAddEngineStarting(bool requiresPolicyFetch) { UNUSED(requiresPolicyFetch); }
145
152 virtual void OnAddEngineFailure(
153 const std::exception_ptr& error,
154 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
155
161 virtual void OnDeleteEngineSuccess(const std::shared_ptr<void>& context) { UNUSED(context); }
162
169 virtual void OnDeleteEngineFailure(
170 const std::exception_ptr& error,
171 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
172
180 virtual void OnPolicyChanged(const std::string& engineId) { UNUSED(engineId); }
181
183 virtual ~Observer() { }
184 protected:
185 Observer() { }
187 };
188
192 class Settings {
193 public:
201 Settings(
202 const std::shared_ptr<MipContext>& mipContext,
203 CacheStorageType cacheStorageType,
204 const std::shared_ptr<PolicyProfile::Observer>& observer)
205 : mMipContext(mipContext),
206 mCacheStorageType(cacheStorageType),
207 mObserver(observer) {}
208
214 CacheStorageType GetCacheStorageType() const { return mCacheStorageType; }
215
221 const std::shared_ptr<PolicyProfile::Observer>& GetObserver() const { return mObserver; }
222
228 std::shared_ptr<MipContext> GetMipContext() const { return mMipContext; }
229
235 std::shared_ptr<HttpDelegate> GetHttpDelegate() const { return mHttpDelegate; }
236
242 void SetHttpDelegate(const std::shared_ptr<HttpDelegate>& httpDelegate) { mHttpDelegate = httpDelegate; }
243
249 std::shared_ptr<StorageDelegate> GetStorageDelegate() const { return mStorageDelegate; }
250
256 void SetStorageDelegate(const std::shared_ptr<StorageDelegate>& storageDelegate) { mStorageDelegate = storageDelegate; }
257
263 std::shared_ptr<TaskDispatcherDelegate> GetTaskDispatcherDelegate() const { return mTaskDispatcherDelegate; }
264
273 void SetTaskDispatcherDelegate(const std::shared_ptr<TaskDispatcherDelegate>& taskDispatcherDelegate) {
274 mTaskDispatcherDelegate = taskDispatcherDelegate;
275 }
276
277 void SetSessionId(const std::string& sessionId) {
278 mSessionId = sessionId;
279 }
280
281 const std::string& GetSessionId() const {
282 return mSessionId;
283 }
284
290 void SetCustomSettings(const std::vector<std::pair<std::string, std::string>>& customSettings) {
291 mCustomSettings = customSettings;
292 }
293
299 const std::vector<std::pair<std::string, std::string>>& GetCustomSettings() const {
300 return mCustomSettings;
301 }
302#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
308 const std::shared_ptr<void>& GetLoggerContext() const { return mLoggerContext; }
309#endif
316 void SetLoggerContext(const std::shared_ptr<void>& loggerContext) {
317 mLoggerContext = loggerContext;
318 }
319
320 ~Settings() { }
321 private:
322 std::shared_ptr<MipContext> mMipContext;
323 CacheStorageType mCacheStorageType;
324 std::shared_ptr<PolicyProfile::Observer> mObserver;
325 std::shared_ptr<HttpDelegate> mHttpDelegate;
326 std::shared_ptr<TaskDispatcherDelegate> mTaskDispatcherDelegate;
327 std::string mSessionId;
328 std::vector<std::pair<std::string, std::string>> mCustomSettings;
329 std::shared_ptr<void> mLoggerContext;
330 std::shared_ptr<StorageDelegate> mStorageDelegate;
332 };
333
341 MIP_API static std::shared_ptr<AsyncControl> __CDECL LoadAsync(
342 const Settings& settings,
343 const std::shared_ptr<void>& context);
344
352 MIP_API static std::shared_ptr<PolicyProfile> __CDECL Load(const Settings& settings);
353
359 MIP_API static const char* __CDECL GetVersion();
360
366 virtual const Settings& GetSettings() const = 0;
367
374 virtual std::shared_ptr<AsyncControl> ListEnginesAsync(const std::shared_ptr<void>& context) = 0;
375
381 virtual std::vector<std::string> ListEngines() = 0;
382
390 virtual std::shared_ptr<AsyncControl> UnloadEngineAsync(
391 const std::string& id,
392 const std::shared_ptr<void>& context) = 0;
393
399 virtual void UnloadEngine(const std::string& id) = 0;
400
408 virtual std::shared_ptr<AsyncControl> AddEngineAsync(
409 const PolicyEngine::Settings& settings,
410 const std::shared_ptr<void>& context) = 0;
411
420 virtual std::shared_ptr<PolicyEngine> AddEngine(
421 const PolicyEngine::Settings& settings,
422 const std::shared_ptr<void>& context) = 0;
423
431 virtual std::shared_ptr<AsyncControl> DeleteEngineAsync(
432 const std::string& id,
433 const std::shared_ptr<void>& context) = 0;
434
440 virtual void DeleteEngine(const std::string& engineId) = 0;
441
452 virtual void AcquireAuthToken(Cloud cloud, const std::shared_ptr<AuthDelegate>& authDelegate) const = 0;
453
464 virtual void AcquireAuthToken(const std::string& domainInfo, const std::shared_ptr<AuthDelegate>& authDelegate) const = 0;
465
467 virtual ~PolicyProfile() { }
468protected:
469 PolicyProfile() { }
471};
472
473MIP_NAMESPACE_END
474
475#endif // API_MIP_UPE_POLICY_PROFILE_H_
A file Containing the common types used by the upe, file and protection modules.
Cloud
Azure cloud identifier.
Definition common_types.h:752
CacheStorageType
Storage type for the caches.
Definition common_types.h:734
A file containing the MIP SDK error types.
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.
A file export/import macros.
MIP namespace macros.
This file contains the PolicyEngine class which includes the PolicyEngine::Settings class.
virtual std::shared_ptr< AsyncControl > ListEnginesAsync(const std::shared_ptr< void > &context)=0
Starts list engines operation.
static MIP_API std::shared_ptr< PolicyProfile > __CDECL Load(const Settings &settings)
Loading a profile based on the provided settings.
static MIP_API const char *__CDECL GetVersion()
Get the library version.
virtual const Settings & GetSettings() const =0
Get the settings set on the profile.
virtual std::shared_ptr< PolicyEngine > AddEngine(const PolicyEngine::Settings &settings, const std::shared_ptr< void > &context)=0
Add a new policy engine to the profile.
virtual std::shared_ptr< AsyncControl > DeleteEngineAsync(const std::string &id, const std::shared_ptr< void > &context)=0
Starts deleting the policy engine with the given ID. All data for the given profile will be deleted.
virtual std::shared_ptr< AsyncControl > UnloadEngineAsync(const std::string &id, const std::shared_ptr< void > &context)=0
Starts unloading the policy engine with the given ID.
static MIP_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 void UnloadEngine(const std::string &id)=0
Starts unloading the policy engine with the given ID.
virtual void DeleteEngine(const std::string &engineId)=0
Delete the policy engine with the given ID. All data for the given engine will be deleted.
virtual std::vector< std::string > ListEngines()=0
List of engines.
virtual std::shared_ptr< AsyncControl > AddEngineAsync(const PolicyEngine::Settings &settings, const std::shared_ptr< void > &context)=0
Starts adding a new policy engine to the profile.
virtual void AcquireAuthToken(Cloud cloud, const std::shared_ptr< AuthDelegate > &authDelegate) const =0
Trigger an authentication callback.
A file containing the TaskDispatcherDelegate interface to be used to override MIP async task executor...