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