Microsoft Information Protection (MIP) SDK for C++: Reference 1.16
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
mip_context.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 * @brief File containing definition of MipContext
29 *
30 * @file mip_context.h
31 */
32
33#ifndef API_MIP_MIP_CONTEXT_H_
34#define API_MIP_MIP_CONTEXT_H_
35
36#include <map>
37#include <memory>
38
39#include "mip/common_types.h"
42#include "mip/json_delegate.h"
43#include "mip/logger_delegate.h"
45#include "mip/mip_export.h"
46#include "mip/mip_namespace.h"
48#include "mip/xml_delegate.h"
49
50MIP_NAMESPACE_BEGIN
51
52/** @cond DOXYGEN_HIDE */
53class AuditManager;
54class ProtectionCloudManager;
55class PolicyCloudManager;
56class OneDSCloudManager;
57class TelemetryManager;
58struct DiagnosticClientHandle {
59 DiagnosticClientHandle() {}
60 DiagnosticClientHandle(const char *diagnosticType, int64_t diagnosticHandle)
61 : type(diagnosticType),
62 handle(diagnosticHandle) {}
63
64 const char *type = {};
65 int64_t handle = {};
66};
67/** @endcond */
68
69/**
70 * @brief MipContext represents state that is shared across all profiles, engines, handlers
71 */
73public:
74
75#ifndef MIP_CORE_PACKAGE
76 /**
77 * @brief Create a new MipContext instance to be used when initializing profiles
78 *
79 * @param appInfo Description of host application
80 * @param path File path for logs, caches, etc.
81 * @param thresholdLogLevel Minimum log level for .miplog
82 * @param isOfflineOnly Enable/disable network operations (not all actions supported when offline)
83 * @param loggerDelegateOverride (Optional) LoggerDelegate override implementation
84 * @param diagnosticOverride (Optional) DiagnosticConfiguration override for audit/telemetry
85 *
86 * @return MipContext instance
87 */
88#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
89 [[deprecated("MipContext::Create(...) is deprecated, use MipContext::Create(const std::shared_ptr<const MipConfiguration>&)")]]
90#endif
91 MIP_API static std::shared_ptr<MipContext> __CDECL Create(
92 const ApplicationInfo& appInfo,
93 const std::string& path,
94 LogLevel thresholdLogLevel,
95 bool isOfflineOnly,
96 const std::shared_ptr<LoggerDelegate>& loggerDelegateOverride,
97 const std::shared_ptr<DiagnosticConfiguration>& diagnosticOverride);
98
99 /**
100 * @brief Create a new MipContext instance with custom feature settings
101 *
102 * @param appInfo Description of host application
103 * @param path File path for logs, caches, etc.
104 * @param thresholdLogLevel Minimum log level for .miplog
105 * @param isOfflineOnly Enable/disable network operations (not all actions supported when offline)
106 * @param loggerDelegateOverride (Optional) LoggerDelegate override implementation
107 * @param diagnosticOverride (Optional) DiagnosticConfiguration override for audit/telemetry
108 * @param featureSettingsOverride Flighting features which should be set to non-default values
109 *
110 * @return MipContext instance
111 */
112#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
113 [[deprecated("MipContext::CreateWithCustomFeatureSettings is deprecated, use MipContext::Create(const std::shared_ptr<const MipConfiguration>&)")]]
114#endif
115 MIP_API static std::shared_ptr<MipContext> __CDECL CreateWithCustomFeatureSettings(
116 const ApplicationInfo& appInfo,
117 const std::string& path,
118 LogLevel thresholdLogLevel,
119 bool isOfflineOnly,
120 const std::shared_ptr<LoggerDelegate>& loggerDelegateOverride,
121 const std::shared_ptr<DiagnosticConfiguration>& diagnosticOverride,
122 const std::map<FlightingFeature, bool>& featureSettingsOverride);
123#endif // !MIP_CORE_PACKAGE
124
125 /**
126 * @brief Create a new MipContext instance with mip configuration
127 *
128 * @param mipConfiguration mipConfiguration to be used across MIP
129 *
130 * @return MipContext instance
131 */
132 MIP_API static std::shared_ptr<MipContext> __CDECL Create(
133 const std::shared_ptr<const MipConfiguration>& configuration);
134
135 /**
136 * @brief Terminate MIP
137 *
138 * @note This method must be called prior to process/DLL shutdown
139 */
140 virtual void ShutDown() = 0;
141
142 /**
143 * @brief Gets whether or not a feature is enabled
144 *
145 * @param feature Feature to enable/disable
146 *
147 * @return Whether or not a feature is enabled
148 *
149 * @note If a FeatureFlightingDelegate has not been provided by an application, this will always return true
150 */
151 virtual bool IsFeatureEnabled(FlightingFeature feature) const = 0;
152
153 /**
154 * @brief Get application description
155 *
156 * @return Application description
157 */
158 virtual const ApplicationInfo& GetApplicationInfo() const = 0;
159
160 /**
161 * @brief Get file path for logs, caches, etc.
162 *
163 * @return File path (with "mip" leaf directory)
164 */
165 virtual const std::string& GetMipPath() const = 0;
166
167 /**
168 * @brief Get offline-only setting
169 *
170 * @return Whether or not application is running in offline-only mode
171 */
172 virtual bool IsOfflineOnly() const = 0;
173
174 /**
175 * @brief Get threshold log level
176 *
177 * @return threshold log level
178 */
179 virtual LogLevel GetThresholdLogLevel() const = 0;
180
181 /**
182 * @brief Get logger implementation
183 *
184 * @return Logger
185 */
186 virtual std::shared_ptr<LoggerDelegate> GetLoggerDelegate() const = 0;
187
188 /**
189 * @brief Get Http implementation
190 *
191 * @return HttpDelegate
192 */
193 virtual std::shared_ptr<HttpDelegate> GetHttpDelegate() const = 0;
194
195 /**
196 * @brief Get raw logger implementation
197 *
198 * @return Logger
199 */
201
202 /**
203 * @brief Get Storage Delegate implementation if provided
204 *
205 * @return StorageDelegate
206 */
207 virtual std::shared_ptr<StorageDelegate> GetStorageDelegate() const = 0;
208
209 /**
210 * @brief Get flighting feature set.
211 *
212 * @return Flighting feature map
213 */
214 virtual const std::map<FlightingFeature, bool>& GetFlightingFeatures() const = 0;
215
216 /**
217 * @brief Gets the mip configuration that was used to create the MipContext
218 *
219 * @return The mip configuration
220 */
221 virtual const std::shared_ptr<const MipConfiguration>& GetMipConfiguration() const = 0;
222
223 /**
224 * @brief Gets the logger configuration that will be used by the default logger
225 *
226 * @return Logger configuration
227 */
228 virtual const LoggerConfiguration& GetLoggerConfiguration() const = 0;
229
230 /** @cond DOXYGEN_HIDE */
231 virtual const ProtectionCloudManager& GetProtectionCloudManager() const = 0;
232 virtual const PolicyCloudManager& GetPolicyCloudManager() const = 0;
233 virtual const OneDSCloudManager& GetOneDSCloudManager() const = 0;
234 virtual std::shared_ptr<TelemetryManager> GetTelemetryManager() const = 0;
235 virtual std::shared_ptr<AuditManager> GetAuditManager() const = 0;
236 virtual TelemetryManager* GetRawTelemetryManager() const = 0;
237 virtual std::shared_ptr<JsonDelegate> GetJsonDelegate() const = 0;
238 virtual DiagnosticClientHandle AddDiagnosticClient(Cloud cloud, DataBoundary dataBoundary) const = 0;
239 virtual const std::shared_ptr<EventContext> GetDefaultEventContext() const = 0;
240
241 /**
242 * @brief Get the Xml Delegate that should be used when parsing.
243 * If the application provides a MipConfiguration with an xml delegate and is using MipCore
244 * this method returns that alternative delegate.
245 * Otherwise the default implementation will be used.
246 *
247 * @return A shared_ptr to the xml delegate
248 */
249 virtual std::shared_ptr<xml::XmlDelegate> GetXmlDelegate() const = 0;
250 virtual ~MipContext() {}
251 /** @endcond */
252};
253
254MIP_NAMESPACE_END
255#endif // API_MIP_MIP_CONTEXT_H_
256
A class that defines the interface to the MIP SDK logger.
MipContext represents state that is shared across all profiles, engines, handlers.
Definition mip_context.h:72
virtual const std::string & GetMipPath() const =0
Get file path for logs, caches, etc.
virtual std::shared_ptr< HttpDelegate > GetHttpDelegate() const =0
Get Http implementation.
static MIP_API std::shared_ptr< MipContext > __CDECL Create(const ApplicationInfo &appInfo, const std::string &path, LogLevel thresholdLogLevel, bool isOfflineOnly, const std::shared_ptr< LoggerDelegate > &loggerDelegateOverride, const std::shared_ptr< DiagnosticConfiguration > &diagnosticOverride)
Create a new MipContext instance to be used when initializing profiles.
static MIP_API std::shared_ptr< MipContext > __CDECL CreateWithCustomFeatureSettings(const ApplicationInfo &appInfo, const std::string &path, LogLevel thresholdLogLevel, bool isOfflineOnly, const std::shared_ptr< LoggerDelegate > &loggerDelegateOverride, const std::shared_ptr< DiagnosticConfiguration > &diagnosticOverride, const std::map< FlightingFeature, bool > &featureSettingsOverride)
Create a new MipContext instance with custom feature settings.
virtual const ApplicationInfo & GetApplicationInfo() const =0
Get application description.
virtual std::shared_ptr< LoggerDelegate > GetLoggerDelegate() const =0
Get logger implementation.
virtual std::shared_ptr< StorageDelegate > GetStorageDelegate() const =0
Get Storage Delegate implementation if provided.
virtual LogLevel GetThresholdLogLevel() const =0
Get threshold log level.
virtual const std::shared_ptr< const MipConfiguration > & GetMipConfiguration() const =0
Gets the mip configuration that was used to create the MipContext.
virtual bool IsFeatureEnabled(FlightingFeature feature) const =0
Gets whether or not a feature is enabled.
virtual void ShutDown()=0
Terminate MIP.
virtual LoggerDelegate * GetRawLoggerDelegate() const =0
Get raw logger implementation.
virtual bool IsOfflineOnly() const =0
Get offline-only setting.
virtual const std::map< FlightingFeature, bool > & GetFlightingFeatures() const =0
Get flighting feature set.
static MIP_API std::shared_ptr< MipContext > __CDECL Create(const std::shared_ptr< const MipConfiguration > &configuration)
Create a new MipContext instance with mip configuration.
virtual const LoggerConfiguration & GetLoggerConfiguration() const =0
Gets the logger configuration that will be used by the default logger.
A file Containing the common types used by the upe, file and protection modules.
Cloud
Azure cloud identifier.
DataBoundary
Diagnostic region identifier.
Defines custom telemetry or audit configurations.
A file containing the FlightingFeature definition.
FlightingFeature
Defines new features by name.
Contains the JsonDelegate interface used to parse and produce JSON data.
LogLevel
Different log levels used across the MIP SDK.
A file containing the LoggerDelegate class to be used to override MIP logger.
Defines configuration for all external mip delegates.
A file export/import macros.
MIP namespace macros.
A struct that includes application specific information.
Configuration to use when default logging is enabled. This is set only once per process and any later...
A file containing the TelemetryDelegate class to be used to override MIP telemetry.