Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
mip_configuration.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 Defines configuration for all external mip delegates
29 *
30 * @file mip_configuration.h
31 */
32
33#ifndef API_MIP_MIP_CONFIGURATION_H_
34#define API_MIP_MIP_CONFIGURATION_H_
35
36#include <map>
37#include <memory>
38
41#include "mip/json_delegate.h"
42#include "mip/logger_delegate.h"
45#include "mip/xml_delegate.h"
46
47MIP_NAMESPACE_BEGIN
48
49 /**
50 * @brief Configuration used by MIP sdk during its creation and throughout its lifetime
51 */
52
54public:
56 const ApplicationInfo& appInfo,
57 const std::string& path,
58 LogLevel thresholdLogLevel,
59 bool isOfflineOnly)
60 : mAppInfo(appInfo),
61 mPath(path),
62 mThresholdLogLevel(thresholdLogLevel),
63 mIsOfflineOnly(isOfflineOnly),
64 mfeatureSettings(),
65 mApiLogCacheMaxMessages(1024) {}
66
67 /**
68 * @brief Get the Description of host application
69 *
70 * @return Description of host application
71 */
72 const ApplicationInfo& GetApplicationInfo() const { return mAppInfo; }
73
74 /**
75 * @brief Get the File path for logs, caches, etc.
76 *
77 * @return File path for logs, caches, etc.
78 */
79 const std::string& GetPath() const { return mPath; }
80
81 /**
82 * @brief Get the Minimum log level for .miplog
83 *
84 * @return Minimum log level for .miplog.
85 */
86 const LogLevel& GetThresholdLogLevel() const { return mThresholdLogLevel; }
87
88 /**
89 * @brief whether Network operations is enabled or disabled(not all actions supported when offline)
90 *
91 * @return Network operations state
92 */
93 const bool isOfflineOnly() const { return mIsOfflineOnly; }
94 /**
95 * @brief Get the Diagnostic (if any) provided by the application
96 *
97 * @return Diagnostic Configuration to be used for configuring telemetry/audit.
98 */
99 std::shared_ptr<DiagnosticConfiguration> GetDiagnosticConfiguration() const { return mDiagnosticConfiguration; }
100
101 /**
102 * @brief Override default configuration of diagnostic
103 *
104 * @param diagnosticConfiguration diagnostic configuration to be used for configuring telemetry/audit.
105 */
106 void SetDiagnosticConfiguration(const std::shared_ptr<DiagnosticConfiguration>& diagnosticConfiguration) { mDiagnosticConfiguration = diagnosticConfiguration; }
107
108 /**
109 * @brief Get the LoggerDelegate (if any) override implementation
110 *
111 * @return LoggerDelegate (if any) override implementation.
112 */
113 std::shared_ptr<LoggerDelegate> GetLoggerDelegate() const { return mLoggerDelegate; }
114
115 /**
116 * @brief Set the LoggerDelegate (if any) override implementation
117 *
118 * @param loggerDelegate LoggerDelegate override implementation
119 */
120 void SetLoggerDelegate(const std::shared_ptr<LoggerDelegate>& loggerDelegate) { mLoggerDelegate = loggerDelegate; }
121
122 /**
123 * @brief Get the override configuration (if any) for the default logger implementation
124 *
125 * @return LoggerConfiguration override (if any)
126 */
127 std::shared_ptr<LoggerConfiguration> GetLoggerConfiguration() const { return mLoggerConfiguration; }
128
129 /**
130 * @brief Override the default logger configuration
131 *
132 * @param loggerConfiguration LoggerConfiguration override
133 */
134 void SetLoggerConfiguration(const std::shared_ptr<LoggerConfiguration>& loggerConfiguration) { mLoggerConfiguration = loggerConfiguration; }
135
136 /**
137 * @brief Get the StorageDelegate (if any) override implementation
138 *
139 * @return StorageDelegate (if any) override implementation.
140 */
141 std::shared_ptr<StorageDelegate> GetStorageDelegate() const { return mStorageDelegate; }
142
143 /**
144 * @brief Set the StorageDelegate (if any) override implementation. It's a required delegate for MIP Core Context.
145 *
146 * @param storageDelegate StorageDelegate override implementation
147 */
148 void SetStorageDelegate(const std::shared_ptr<StorageDelegate>& storageDelegate) { mStorageDelegate = storageDelegate; }
149
150 /**
151 * @brief Get the HttpDelegate (if any) override implementation.
152 *
153 * @return HttpDelegate (if any) override implementation.
154 */
155 std::shared_ptr<HttpDelegate> GetHttpDelegate() const { return mHttpDelegate; }
156
157 /**
158 * @brief Set the HttpDelegate (if any) override implementation. It's a required delegate for MIP Core Context.
159 *
160 * @param httpDelegate HttpDelegate override implementation
161 */
162 void SetHttpDelegate(const std::shared_ptr<HttpDelegate>& httpDelegate) { mHttpDelegate = httpDelegate; }
163
164 /**
165 * @brief Get the JsonDelegate (if any) override implementation
166 *
167 * @return JsonDelegate (if any) override implementation.
168 */
169 std::shared_ptr<JsonDelegate> GetJsonDelegate() const {
170 return mJsonDelegate;
171 }
172
173 /**
174 * @brief Get the XmlDelegate (if any) override implementation.
175 * MipConfiguration needs to be derived from to override the internal xmlDelegate with an alternative.
176 * This delegate is only configurable when using the MIP Core Context and only for the protection and upe sdk.
177 *
178 * @return XmlDelegate (if any) override implementation. nullptr by default.
179 */
180 std::shared_ptr<xml::XmlDelegate> GetXmlDelegate() const { return mXmlDelegate; }
181
182 /**
183 * @brief Get the Flighting features which should be set to non-default values
184 *
185 * @return Flighting features which should be set to non-default values
186 */
187 std::map<FlightingFeature, bool> GetFeatureSettings() const { return mfeatureSettings; }
188
189 /**
190 * @brief Set the Flighting features which should be set to non-default values
191 *
192 * @param featureSettings Flighting features to be used.
193 */
194 void SetFeatureSettings(const std::map<FlightingFeature, bool>& featureSettings) { mfeatureSettings = featureSettings; }
195
196 /**
197 * @brief Get the max messages per Api call that will be logged in the api log cache
198 *
199 * @return The max messages
200 */
201 size_t GetApiLogCacheMaxMessages() const { return mApiLogCacheMaxMessages; }
202
203 /**
204 * @brief Set the max messages per Api call that will be logged in the api log cache. Setting this to 0 will disable api log caching
205 *
206 * @param maxMessages
207 */
208 void SetApiLogCacheMaxMessages(size_t maxMessages) { mApiLogCacheMaxMessages = maxMessages; }
209
211
212protected:
213 std::shared_ptr<JsonDelegate> mJsonDelegate;
214 std::shared_ptr<xml::XmlDelegate> mXmlDelegate;
215
216private:
217 ApplicationInfo mAppInfo;
218 std::string mPath;
219 LogLevel mThresholdLogLevel;
220 bool mIsOfflineOnly;
221 std::shared_ptr<LoggerDelegate> mLoggerDelegate;
222 std::shared_ptr<DiagnosticConfiguration> mDiagnosticConfiguration;
223 std::shared_ptr<StorageDelegate> mStorageDelegate;
224 std::map<FlightingFeature, bool> mfeatureSettings;
225 size_t mApiLogCacheMaxMessages;
226 std::shared_ptr<HttpDelegate> mHttpDelegate;
227 std::shared_ptr<LoggerConfiguration> mLoggerConfiguration;
228/** @endcond */
229 };
230
231MIP_NAMESPACE_END
232#endif // API_MIP_MIP_CONFIGURATION_H_
Configuration used by MIP sdk during its creation and throughout its lifetime.
std::shared_ptr< xml::XmlDelegate > mXmlDelegate
std::shared_ptr< DiagnosticConfiguration > GetDiagnosticConfiguration() const
Get the Diagnostic (if any) provided by the application.
MipConfiguration(const ApplicationInfo &appInfo, const std::string &path, LogLevel thresholdLogLevel, bool isOfflineOnly)
std::shared_ptr< xml::XmlDelegate > GetXmlDelegate() const
Get the XmlDelegate (if any) override implementation.
const ApplicationInfo & GetApplicationInfo() const
Get the Description of host application.
void SetLoggerDelegate(const std::shared_ptr< LoggerDelegate > &loggerDelegate)
Set the LoggerDelegate (if any) override implementation.
const LogLevel & GetThresholdLogLevel() const
Get the Minimum log level for .miplog.
std::shared_ptr< JsonDelegate > mJsonDelegate
void SetFeatureSettings(const std::map< FlightingFeature, bool > &featureSettings)
Set the Flighting features which should be set to non-default values.
void SetLoggerConfiguration(const std::shared_ptr< LoggerConfiguration > &loggerConfiguration)
Override the default logger configuration.
std::map< FlightingFeature, bool > GetFeatureSettings() const
Get the Flighting features which should be set to non-default values.
const std::string & GetPath() const
Get the File path for logs, caches, etc.
void SetHttpDelegate(const std::shared_ptr< HttpDelegate > &httpDelegate)
Set the HttpDelegate (if any) override implementation.
std::shared_ptr< StorageDelegate > GetStorageDelegate() const
Get the StorageDelegate (if any) override implementation.
const bool isOfflineOnly() const
whether Network operations is enabled or disabled(not all actions supported when offline)
std::shared_ptr< HttpDelegate > GetHttpDelegate() const
Get the HttpDelegate (if any) override implementation.
std::shared_ptr< JsonDelegate > GetJsonDelegate() const
Get the JsonDelegate (if any) override implementation.
std::shared_ptr< LoggerDelegate > GetLoggerDelegate() const
Get the LoggerDelegate (if any) override implementation.
void SetDiagnosticConfiguration(const std::shared_ptr< DiagnosticConfiguration > &diagnosticConfiguration)
Override default configuration of diagnostic.
std::shared_ptr< LoggerConfiguration > GetLoggerConfiguration() const
Get the override configuration (if any) for the default logger implementation.
size_t GetApiLogCacheMaxMessages() const
Get the max messages per Api call that will be logged in the api log cache.
void SetStorageDelegate(const std::shared_ptr< StorageDelegate > &storageDelegate)
Set the StorageDelegate (if any) override implementation.
void SetApiLogCacheMaxMessages(size_t maxMessages)
Set the max messages per Api call that will be logged in the api log cache.
Defines custom telemetry or audit configurations.
A file containing the FlightingFeature definition.
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 StorageDelegate interface.
A struct that includes application specific information.
A file containing the TaskDispatcherDelegate interface to be used to override MIP async task executor...
Contains XmlDelegate interface definition used to parse xml recieved by mip.