Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
file_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 */
27
28#ifndef API_MIP_FILE_FILE_ENGINE_H_
29#define API_MIP_FILE_FILE_ENGINE_H_
30
31#include <memory>
32#include <string>
33#include <utility>
34#include <vector>
35
36#include "mip/common_types.h"
37#include "mip/error.h"
40#include "mip/mip_namespace.h"
42#include "mip/upe/label.h"
44
45MIP_NAMESPACE_BEGIN
46
50class FileEngine {
51public:
52
53 class Settings {
54 public:
68 Settings(
69 const std::string& engineId,
70 const std::shared_ptr<AuthDelegate>& authDelegate,
71 const std::string& clientData,
72 const std::string& locale = "",
73 bool loadSensitivityTypes = false)
74 : mEngineId(engineId),
75 mAuthDelegate(authDelegate),
76 mClientData(clientData),
77 mLocale(locale),
78 mIsLoadSensitivityTypesEnabled(loadSensitivityTypes) {
79 if (mLocale.compare("") == 0) {
80 mLocale = "en-US";
81 }
82 }
83
97 Settings(
98 const Identity& identity,
99 const std::shared_ptr<AuthDelegate>& authDelegate,
100 const std::string& clientData,
101 const std::string& locale = "",
102 bool loadSensitivityTypes = false)
103 : mIdentity(identity),
104 mAuthDelegate(authDelegate),
105 mClientData(clientData),
106 mLocale(locale) ,
107 mIsLoadSensitivityTypesEnabled(loadSensitivityTypes) {
108 if (mLocale.compare("") == 0) {
109 mLocale = "en-US";
110 }
111 }
112
116 const std::string& GetEngineId() const { return mEngineId; }
117
123 void SetEngineId(const std::string& id) { mEngineId = id; }
124
128 const Identity& GetIdentity() const { return mIdentity; }
129
133 void SetIdentity(const Identity& identity) { mIdentity = identity; }
134
138 const std::string& GetClientData() const { return mClientData; }
139
143 const std::string& GetLocale() const { return mLocale; }
144
148 void SetCustomSettings(const std::vector<std::pair<std::string, std::string>>& value) { mCustomSettings = value; }
149
153 const std::vector<std::pair<std::string, std::string>>& GetCustomSettings() const { return mCustomSettings; }
154
158 void SetSessionId(const std::string& sessionId) {
159 mSessionId = sessionId;
160 }
161
165 const std::string& GetSessionId() const {
166 return mSessionId;
167 }
168
176 void SetCloud(Cloud cloud) {
177 mCloud = cloud;
178 }
179
185 Cloud GetCloud() const {
186 return mCloud;
187 }
188
196 void SetDataBoundary(DataBoundary dataBoundary) {
197 mDataBoundary = dataBoundary;
198 }
199
205 DataBoundary GetDataBoundary() const {
206 return mDataBoundary;
207 }
208
216 void SetProtectionCloudEndpointBaseUrl(const std::string& protectionCloudEndpointBaseUrl) {
217 mProtectionCloudEndpointBaseUrl = protectionCloudEndpointBaseUrl;
218 }
219
227 const std::string& GetProtectionCloudEndpointBaseUrl() const {
228 return mProtectionCloudEndpointBaseUrl;
229 }
230
236 void SetPolicyCloudEndpointBaseUrl(const std::string& policyCloudEndpointBaseUrl) {
237 mPolicyCloudEndpointBaseUrl = policyCloudEndpointBaseUrl;
238 }
239
245 const std::string& GetPolicyCloudEndpointBaseUrl() const {
246 return mPolicyCloudEndpointBaseUrl;
247 }
248
252 void SetProtectionOnlyEngine(bool protectionOnly) {
253 mProtectionOnlyEngine = protectionOnly;
254 }
255
259 const bool IsProtectionOnlyEngine() const {
260 return mProtectionOnlyEngine;
261 }
262
268 bool IsLoadSensitivityTypesEnabled() const {
269 return mIsLoadSensitivityTypesEnabled;
270 }
271
275 void EnablePFile(bool value) {
276 mEnablePFile = value;
277 }
278
284 const bool IsPFileEnabled() {
285 return mEnablePFile;
286 }
287
295 void SetDelegatedUserEmail(const std::string& delegatedUserEmail) { mDelegatedUserEmail = delegatedUserEmail; }
296
304 const std::string& GetDelegatedUserEmail() const { return mDelegatedUserEmail; }
305
314#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
315 [[deprecated("SetLabelFilter is deprecated, use ConfigureFunctionality")]]
316#endif
317 void SetLabelFilter(const std::vector<LabelFilterType>& deprecatedLabelFilters) { mDeprecatedLabelFilters = deprecatedLabelFilters; }
318
326 const std::vector<LabelFilterType>& GetLabelFilter() const { return mDeprecatedLabelFilters; }
327
336 void ConfigureFunctionality(FunctionalityFilterType functionalityFilterType, bool enabled) {
337 if(functionalityFilterType == FunctionalityFilterType::None) {
338 throw BadInputError(
339 "FunctionalityFilterType::None is not supported");
340 }
341
342 mConfiguredFunctionality[functionalityFilterType] = enabled;
343 }
344
350 const std::map<FunctionalityFilterType, bool>& GetConfiguredFunctionality() const {
351 return mConfiguredFunctionality;
352 }
353
359 void SetAuthDelegate(const std::shared_ptr<AuthDelegate>& authDelegate) {
360 mAuthDelegate = authDelegate;
361 }
362
368 std::shared_ptr<AuthDelegate> GetAuthDelegate() const { return mAuthDelegate; }
369
370#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
376 const std::shared_ptr<void>& GetLoggerContext() const { return mLoggerContext; }
377#endif
384 void SetLoggerContext(const std::shared_ptr<void>& loggerContext) {
385 mLoggerContext = loggerContext;
386 }
387
388 private:
389 std::string mEngineId;
390 Identity mIdentity;
391 Cloud mCloud = Cloud::Unknown;
392 DataBoundary mDataBoundary = DataBoundary::Default;
393 std::shared_ptr<AuthDelegate> mAuthDelegate;
394 std::string mClientData;
395 std::vector<std::pair<std::string, std::string>> mCustomSettings;
396 std::vector<LabelFilterType> mDeprecatedLabelFilters; //Labels that the client does not want to view
397 std::map<FunctionalityFilterType, bool> mConfiguredFunctionality; //Functionality that has been turned on or off
398 std::string mProtectionCloudEndpointBaseUrl;
399 std::string mPolicyCloudEndpointBaseUrl;
400 std::string mLocale;
401 std::string mSessionId;
402 bool mProtectionOnlyEngine = false;
403 bool mIsLoadSensitivityTypesEnabled;
404 bool mEnablePFile = true;
405 std::string mDelegatedUserEmail;
406 std::shared_ptr<void> mLoggerContext;
407 };
408
410 virtual ~FileEngine() {}
416 virtual const Settings& GetSettings() const = 0;
417
423 virtual const std::vector<std::shared_ptr<SensitivityTypesRulePackage>>& ListSensitivityTypes() const = 0;
424
430 virtual const std::shared_ptr<Label> GetDefaultSensitivityLabel() const = 0;
431
435 virtual std::shared_ptr<Label> GetLabelById(const std::string& id) const = 0;
436
440 virtual const std::vector<std::shared_ptr<Label>> ListSensitivityLabels() = 0;
441
447 virtual const std::string& GetMoreInfoUrl() const = 0;
448
454 virtual const std::string& GetPolicyFileId() const = 0;
455
461 virtual const std::string& GetSensitivityFileId() const = 0;
462
468 virtual bool IsLabelingRequired() const = 0;
469
475 virtual std::chrono::time_point<std::chrono::system_clock> GetLastPolicyFetchTime() const = 0;
476
482 virtual const std::string& GetPolicyDataXml() const = 0;
483
496 virtual std::shared_ptr<AsyncControl> CreateFileHandlerAsync(
497 const std::string& inputFilePath,
498 const std::string& filePathForAuditReporting,
499 bool isAuditDiscoveryEnabled,
500 const std::shared_ptr<FileHandler::Observer>& fileHandlerObserver,
501 const std::shared_ptr<void>& context,
502 const std::shared_ptr<FileExecutionState>& fileExecutionState = nullptr,
503 bool isGetSensitivityLabelAuditDiscoveryEnabled = true) = 0;
504
519 virtual std::shared_ptr<AsyncControl> CreateFileHandlerAsync(
520 const std::shared_ptr<Stream>& inputStream,
521 const std::string& actualFilePath,
522 bool isAuditDiscoveryEnabled,
523 const std::shared_ptr<FileHandler::Observer>& fileHandlerObserver,
524 const std::shared_ptr<void>& context,
525 const std::shared_ptr<FileExecutionState>& fileExecutionState = nullptr,
526 bool isGetSensitivityLabelAuditDiscoveryEnabled = true) = 0;
527
535 virtual void SendApplicationAuditEvent(
536 const std::string& level,
537 const std::string& eventType,
538 const std::string& eventData) = 0;
539
545 virtual const std::vector<std::pair<std::string, std::string>>& GetCustomSettings() const = 0;
546
553 virtual bool HasClassificationRules() const = 0;
554
560 virtual bool HasWorkloadConsent(Workload workload) const = 0;
561
562protected:
564 FileEngine() {}
566};
567
568MIP_NAMESPACE_END
569
570#endif // API_MIP_FILE_FILE_ENGINE_H_
Bad input error, thrown when the input to an SDK API is invalid.
Definition error.h:247
Abstraction for identity.
Definition common_types.h:270
A file Containing the common types used by the upe, file and protection modules.
Cloud
Azure cloud identifier.
Definition common_types.h:728
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.
Definition common_types.h:745
A file containing the MIP SDK error types.
This file contains the ExecutionState class.
This file contains the Label class.
MIP namespace macros.
virtual const Settings & GetSettings() const =0
Get the settings set on the profile.