Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
policy_engine.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 */
33#ifndef API_MIP_UPE_POLICY_ENGINE_H_
34#define API_MIP_UPE_POLICY_ENGINE_H_
35
36#include <memory>
37#include <string>
38#include <vector>
39
40#include "mip/common_types.h"
41#include "mip/error.h"
42#include "mip/mip_namespace.h"
43#include "mip/upe/action.h"
46#include "mip/upe/label.h"
49
50MIP_NAMESPACE_BEGIN
51
55class PolicyEngine {
56public:
60 class Settings {
61 public:
76 Settings(
77 const std::string& engineId,
78 const std::shared_ptr<AuthDelegate>& authDelegate,
79 const std::string& clientData,
80 const std::string& locale = "",
81 bool loadSensitivityTypes = false)
82 : mEngineId(engineId),
83 mAuthDelegate(authDelegate),
84 mClientData(clientData),
85 mLocale(locale),
86 mIsLoadSensitivityTypesEnabled(loadSensitivityTypes) {
87 if (mLocale.compare("") == 0) {
88 mLocale = "en-US";
89 }
90 }
91
105 Settings(
106 const Identity& identity,
107 const std::shared_ptr<AuthDelegate>& authDelegate,
108 const std::string& clientData,
109 const std::string& locale = "",
110 bool loadSensitivityTypes = false)
111 : mIdentity(identity),
112 mAuthDelegate(authDelegate),
113 mClientData(clientData),
114 mLocale(locale),
115 mIsLoadSensitivityTypesEnabled(loadSensitivityTypes) {
116 if (mLocale.compare("") == 0) {
117 mLocale = "en-US";
118 }
119 }
120
126 const std::string& GetEngineId() const { return mEngineId; }
127
133 void SetEngineId(const std::string& id) { mEngineId = id; }
134
141 const Identity& GetIdentity() const { return mIdentity; }
142
149 void SetIdentity(const Identity& identity) { mIdentity = identity; }
150
156 const std::string& GetClientData() const { return mClientData; }
157
163 void SetClientData(const std::string& clientData) { mClientData = clientData; }
164
170 const std::string& GetLocale() const { return mLocale; }
171
177 void SetCustomSettings(const std::vector<std::pair<std::string, std::string>>& customSettings) {
178 mCustomSettings = customSettings;
179 }
180
186 const std::vector<std::pair<std::string, std::string>>& GetCustomSettings() const {
187 return mCustomSettings;
188 }
189
196 void SetSessionId(const std::string& sessionId) {
197 mSessionId = sessionId;
198 }
199
205 const std::string& GetSessionId() const {
206 return mSessionId;
207 }
208
214 bool IsLoadSensitivityTypesEnabled() const {
215 return mIsLoadSensitivityTypesEnabled;
216 }
217
225 void SetCloud(Cloud cloud) {
226 mCloud = cloud;
227 }
228
234 Cloud GetCloud() const {
235 return mCloud;
236 }
237
245 void SetDataBoundary(DataBoundary dataBoundary) {
246 mDataBoundary = dataBoundary;
247 }
248
254 DataBoundary GetDataBoundary() const {
255 return mDataBoundary;
256 }
257
265 void SetCloudEndpointBaseUrl(const std::string& cloudEndpointBaseUrl) {
266 mCloudEndpointBaseUrl = cloudEndpointBaseUrl;
267 }
268
274 const std::string& GetCloudEndpointBaseUrl() const {
275 return mCloudEndpointBaseUrl;
276 }
277
285 void SetDelegatedUserEmail(const std::string& delegatedUserEmail) { mDelegatedUserEmail = delegatedUserEmail; }
286
294 const std::string& GetDelegatedUserEmail() const { return mDelegatedUserEmail; }
295
304#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
305 [[deprecated("SetLabelFilter is deprecated, use ConfigureFunctionality")]]
306#endif
307 void SetLabelFilter(const std::vector<LabelFilterType>& deprecatedLabelFilters) {
308 mDeprecatedLabelFilters = deprecatedLabelFilters;
309 }
317 const std::vector<LabelFilterType>& GetLabelFilter() const { return mDeprecatedLabelFilters; }
318
327 void ConfigureFunctionality(FunctionalityFilterType functionalityFilterType, bool enabled) {
328 if(functionalityFilterType == FunctionalityFilterType::None) {
329 throw BadInputError(
330 "FunctionalityFilterType::None is not supported");
331 }
332
333 mConfiguredFunctionality[functionalityFilterType] = enabled;
334 }
335
341 const std::map<FunctionalityFilterType, bool>& GetConfiguredFunctionality() const { return mConfiguredFunctionality; }
342
349 void SetVariableTextMarkingType(VariableTextMarkingType variableTextMarkingType) {
350 mVariableTextMarkingType = variableTextMarkingType;
351 }
352
359 VariableTextMarkingType GetVariableTextMarkingType() const {
360 return mVariableTextMarkingType;
361 }
362
368 void SetAuthDelegate(const std::shared_ptr<AuthDelegate>& authDelegate) {
369 mAuthDelegate = authDelegate;
370 }
371
377 std::shared_ptr<AuthDelegate> GetAuthDelegate() const { return mAuthDelegate; }
378
379#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
385 const std::shared_ptr<void>& GetLoggerContext() const { return mLoggerContext; }
386#endif
393 void SetLoggerContext(const std::shared_ptr<void>& loggerContext) {
394 mLoggerContext = loggerContext;
395 }
396
398 ~Settings() {}
399 private:
400 std::string mEngineId;
401 Identity mIdentity;
402 Cloud mCloud = Cloud::Unknown;
403 DataBoundary mDataBoundary = DataBoundary::Default;
404 std::shared_ptr<AuthDelegate> mAuthDelegate;
405 std::string mClientData;
406 std::vector<std::pair<std::string, std::string>> mCustomSettings;
407 std::vector<LabelFilterType> mDeprecatedLabelFilters; // Labels that the client does not want to view
408 std::map<FunctionalityFilterType, bool> mConfiguredFunctionality; // Functionality that has been turned on or off
409 std::string mLocale;
410 std::string mSessionId;
411 bool mIsLoadSensitivityTypesEnabled;
412 std::string mCloudEndpointBaseUrl;
413 std::string mDelegatedUserEmail;
415 std::map<Classifier, bool> mClassifierSupport; // Overwritten classifiers that the application elects to support or not
416 std::shared_ptr<void> mLoggerContext;
418 };
419
426 virtual const Settings& GetSettings() const = 0;
427
436 virtual const std::vector<std::shared_ptr<Label>> ListSensitivityLabels(
437 const std::vector<std::string>& contentFormats = std::vector<std::string>()) = 0;
438
444 virtual const std::vector<std::shared_ptr<SensitivityTypesRulePackage>>& ListSensitivityTypes() const = 0;
445
451 virtual const std::string& GetMoreInfoUrl() const = 0;
452
461 virtual bool IsLabelingRequired(const std::string& contentFormat = std::string()) const = 0;
462
468 virtual bool IsDowngradeJustificationRequired() const = 0;
469
478 virtual const std::shared_ptr<Label> GetDefaultSensitivityLabel(const std::string& contentFormat = std::string()) const = 0;
479
487 virtual std::shared_ptr<Label> GetLabelById(const std::string& id) const = 0;
488
498 virtual std::shared_ptr<PolicyHandler> CreatePolicyHandler(bool isAuditDiscoveryEnabled, bool isGetSensitivityLabelAuditDiscoveryEnabled = true) = 0;
499
507 virtual void SendApplicationAuditEvent(
508 const std::string& level,
509 const std::string& eventType,
510 const std::string& eventData) = 0;
511
517 virtual const std::string& GetTenantId() const = 0;
518
524 virtual const std::string& GetPolicyDataXml() const = 0;
525
531 virtual const std::string& GetSensitivityTypesDataXml() const = 0;
532
538 virtual const std::vector<std::pair<std::string, std::string>>& GetCustomSettings() const = 0;
539
545 virtual const std::string& GetPolicyFileId() const = 0;
546
552 virtual const std::string& GetSensitivityFileId() const = 0;
553
563 virtual bool HasClassificationRules(const std::vector<std::string>& contentFormats = std::vector<std::string>()) const = 0;
564
570 virtual std::chrono::time_point<std::chrono::system_clock> GetLastPolicyFetchTime() const = 0;
571
578 virtual uint32_t GetWxpMetadataVersion() const = 0;
579
585 virtual bool HasWorkloadConsent(Workload workload) const = 0;
586
588 virtual ~PolicyEngine() { }
589
590protected:
592 PolicyEngine() {}
594};
595
596MIP_NAMESPACE_END
597
598#endif // API_MIP_UPE_POLICY_ENGINE_H_
A file containing the Action base class and the ActionType enumerator.
Bad input error, thrown when the input to an SDK API is invalid.
Definition error.h:249
Abstraction for identity.
Definition common_types.h:278
A file Containing the common types used by the upe, file and protection modules.
Cloud
Azure cloud identifier.
Definition common_types.h:752
VariableTextMarkingType
various dynamic fields can be set into the text message of the application Some known: ${Item....
Definition common_types.h:167
Workload
The workload the application is working on, used primary to check for consent.
Definition common_types.h:210
LabelFilterType
Label filter types, optional set of properties that can be used to filter labels or label behavior wh...
Definition common_types.h:114
@ None
Definition common_types.h:115
DataBoundary
Diagnostic region identifier for non-sovereign clouds.
Definition common_types.h:769
A file Containing the ContentLabel class.
A file containing the MIP SDK error types.
This file contains the ExecutionState class.
This file contains the Label class.
MIP namespace macros.
This file contains the PolicyHandler class.
virtual const Settings & GetSettings() const =0
Get the settings set on the profile.