Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
file_handler.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_HANDLER_H_
29#define API_MIP_FILE_FILE_HANDLER_H_
30
31#include <memory>
32
38#include "mip/mip_context.h"
39#include "mip/mip_namespace.h"
42#include "mip/stream.h"
43#include "mip/upe/action.h"
46
47MIP_NAMESPACE_BEGIN
48
49/**
50 * @brief Interface for all file handling functions.
51 */
53public:
54
55 /**
56 * @brief Observer interface for clients to get notifications events related to file handler.
57 *
58 * @note All errors inherit from mip::Error.
59 * @note Client should not call the engine back on the thread that calls the observer.
60 */
61 class Observer {
62 public:
63 /** @cond DOXYGEN_HIDE */
64 virtual ~Observer() {}
65 /** @endcond */
66
67 /**
68 * @brief Called when the handler is created successfully.
69 */
71 const std::shared_ptr<FileHandler>& fileHandler,
72 const std::shared_ptr<void>& context) { UNUSED(fileHandler); UNUSED(context); }
73
74 /**
75 * @brief Called when creating the handler failed.
76 */
78 const std::exception_ptr& error,
79 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
80
81 /**
82 * @brief Called when classify success.
83 */
84 virtual void OnClassifySuccess(
85 const std::vector<std::shared_ptr<Action>>& actions, const std::shared_ptr<void>& context) {
86 UNUSED(actions);
87 UNUSED(context);
88 }
89
90 /**
91 * @brief Called when classify failed.
92 */
93 virtual void OnClassifyFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) {
94 UNUSED(error);
95 UNUSED(context);
96 }
97
98 /**
99 * @brief Called when getting the decrypted temporary file success.
100 */
102 const std::string& decryptedFilePath, const std::shared_ptr<void>& context) {
103 UNUSED(decryptedFilePath);
104 UNUSED(context);
105 }
106
107 /**
108 * @brief Called when getting the decrypted temporary file failed.
109 */
110 virtual void OnGetDecryptedTemporaryFileFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) {
111 UNUSED(error);
112 UNUSED(context);
113 }
114
115 /**
116 * @brief Called when getting the decrypted temporary stream success.
117 */
119 const std::shared_ptr<Stream>& decryptedStream, const std::shared_ptr<void>& context) {
120 UNUSED(decryptedStream);
121 UNUSED(context);
122 }
123
124 /**
125 * @brief Called when getting the decrypted temporary stream failed.
126 */
128 const std::exception_ptr& error, const std::shared_ptr<void>& context) {
129 UNUSED(error);
130 UNUSED(context);
131 }
132
133 /**
134 * @brief Called when committing the changes to the file were successful.
135 */
136 virtual void OnCommitSuccess(
137 bool committed,
138 const std::shared_ptr<void>& context) { UNUSED(committed); UNUSED(context); }
139
140 /**
141 * @brief Called when committing the changes to the file failed.
142 */
143 virtual void OnCommitFailure(
144 const std::exception_ptr& error,
145 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
146
147 /**
148 * @brief Called when inspect success.
149 */
150 virtual void OnInspectSuccess(
151 const std::shared_ptr<FileInspector>& fileInspector, const std::shared_ptr<void>& context) {
152 UNUSED(fileInspector);
153 UNUSED(context);
154 }
155
156 /**
157 * @brief Called when inspect failed.
158 */
159 virtual void OnInspectFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) {
160 UNUSED(error);
161 UNUSED(context);
162 }
163
164 protected:
165 /** @cond DOXYGEN_HIDE */
166 Observer() {}
167 /** @endcond */
168 };
169
170 /**
171 * @brief Starts retrieving the sensitivity label from the file.
172 * @throw NotSupportedError when a protection only engine is in use and no policy handler is found.
173 */
174 virtual std::shared_ptr<ContentLabel> GetLabel() = 0;
175
176 /**
177 * @brief Retrieves the file properties according to version.
178 */
179 virtual std::vector<std::pair<std::string, std::string>> GetProperties(uint32_t version) = 0;
180
181 /**
182 * @brief Starts retrieving the protection policy from the file.
183 */
184 virtual std::shared_ptr<ProtectionHandler> GetProtection() = 0;
185
186 /**
187 * @brief Register the content for tracking and revocation
188 *
189 * @param isOwnerNotificationEnabled Set to true to notify the owner via email whenever the document is decrypted, or
190 * false to not send the notification.
191 * @param observer A class implementing the ProtectionHandler::Observer interface
192 * @param context Client context that will be opaquely forwarded to observers and optional HttpDelegate
193 *
194 * @return Async control object.
195 */
197 bool isOwnerNotificationEnabled,
198 const std::shared_ptr<ProtectionEngine::Observer>& observer,
199 const std::shared_ptr<void>& context) = 0;
200
201 /**
202 * @brief Perform revocation for the content
203 *
204 * @param observer A class implementing the ProtectionHandler::Observer interface
205 * @param context Client context that will be opaquely forwarded to observers and optional HttpDelegate
206 *
207 * @return Async control object.
208 */
209 virtual void RevokeContentAsync(
210 const std::shared_ptr<ProtectionEngine::Observer>& observer, const std::shared_ptr<void>& context) = 0;
211
212 /**
213 * @brief Checks whether a file is protected or not.
214 *
215 * @param filePath Path of file to check, which must include the file name and,
216 * if one exists, the file extension. The file extension is used to determine the file format.
217 * @param mipContext Global MIP context
218 *
219 * @return True if file is protected, else false
220 */
221 FILE_API static bool __CDECL IsProtected(
222 const std::string& filePath,
223 const std::shared_ptr<MipContext>& mipContext);
224
225 /**
226 * @brief Checks whether a file is protected or not.
227 *
228 * @param filePath Path of file to check, which must include the file name and,
229 * if one exists, the file extension. The file extension is used to determine the file format.
230 * @param mipContext Global MIP context
231 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
232 *
233 * @return True if file is protected, else false
234 */
235 FILE_API static bool __CDECL IsProtected(
236 const std::string& filePath,
237 const std::shared_ptr<MipContext>& mipContext,
238 const std::shared_ptr<void>& loggerContext);
239
240 /**
241 * @brief Checks whether a file is protected or not.
242 *
243 * @param stream Stream containing file data to check
244 * @param filePath File path associated with data in 'stream', which must include the file name and,
245 * if one exists, the file extension. The file extension is used to determine the file format.
246 * Passing in the wrong file extension will cause unexpected behavior.
247 * @param mipContext Global MIP context
248 *
249 * @return True if file is protected, else false
250 */
251 FILE_API static bool __CDECL IsProtected(
252 const std::shared_ptr<Stream>& stream,
253 const std::string& filePath,
254 const std::shared_ptr<MipContext>& mipContext);
255
256 /**
257 * @brief Checks whether a file is protected or not.
258 *
259 * @param stream Stream containing file data to check
260 * @param filePath File path associated with data in 'stream', which must include the file name and,
261 * if one exists, the file extension. The file extension is used to determine the file format.
262 * Passing in the wrong file extension will cause unexpected behavior.
263 * @param mipContext Global MIP context
264 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
265 *
266 * @return True if file is protected, else false
267 */
268 FILE_API static bool __CDECL IsProtected(
269 const std::shared_ptr<Stream>& stream,
270 const std::string& filePath,
271 const std::shared_ptr<MipContext>& mipContext,
272 const std::shared_ptr<void>& loggerContext);
273
274 /**
275 * @brief Checks whether a file is labeled/protected or not.
276 *
277 * @param filePath Path of file to check, which must include the file name and,
278 * if one exists, the file extension. The file extension is used to determine the file format.
279 * @param mipContext Global MIP context
280 *
281 * @return True if file is protected or contains label metadata, else false
282 *
283 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
284 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
285 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
286 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
287 */
288 FILE_API static bool __CDECL IsLabeledOrProtected(
289 const std::string& filePath,
290 const std::shared_ptr<MipContext>& mipContext);
291
292 /**
293 * @brief Checks whether a file is labeled/protected or not.
294 *
295 * @param filePath Path of file to check, which must include the file name and,
296 * if one exists, the file extension. The file extension is used to determine the file format.
297 * @param mipContext Global MIP context
298 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
299 *
300 * @return True if file is protected or contains label metadata, else false
301 *
302 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
303 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
304 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
305 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
306 */
307 FILE_API static bool __CDECL IsLabeledOrProtected(
308 const std::string& filePath,
309 const std::shared_ptr<MipContext>& mipContext,
310 const std::shared_ptr<void>& loggerContext);
311
312 /**
313 * @brief Checks whether a file is labeled/protected or not.
314 *
315 * @param stream Stream containing file data to check
316 * @param filePath File path associated with data in 'stream', which must include the file name and,
317 * if one exists, the file extension. The file extension is used to determine the file format.
318 * Passing in the wrong file extension will cause unexpected behavior.
319 * @param mipContext Global MIP context
320 *
321 * @return True if file is protected or contains label metadata, else false
322 *
323 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
324 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
325 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
326 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
327 */
328 FILE_API static bool __CDECL IsLabeledOrProtected(
329 const std::shared_ptr<Stream>& stream,
330 const std::string& filePath,
331 const std::shared_ptr<MipContext>& mipContext);
332
333 /**
334 * @brief Checks whether a file is labeled/protected or not.
335 *
336 * @param stream Stream containing file data to check
337 * @param filePath File path associated with data in 'stream', which must include the file name and,
338 * if one exists, the file extension. The file extension is used to determine the file format.
339 * Passing in the wrong file extension will cause unexpected behavior.
340 * @param mipContext Global MIP context
341 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
342 *
343 * @return True if file is protected or contains label metadata, else false
344 *
345 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
346 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
347 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
348 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
349 */
350 FILE_API static bool __CDECL IsLabeledOrProtected(
351 const std::shared_ptr<Stream>& stream,
352 const std::string& filePath,
353 const std::shared_ptr<MipContext>& mipContext,
354 const std::shared_ptr<void>& loggerContext);
355
356 /**
357 * @brief Checks whether a file is labeled, protected, or contains protected objects.
358 *
359 * @param filePath Path of file to check, which must include the file name and,
360 * if one exists, the file extension. The file extension is used to determine the file format.
361 * @param mipContext Global MIP context
362 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
363 *
364 * @return The shared pointer of a FileStatus object.
365 *
366 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
367 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
368 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
369 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
370 * For container files like msg, this method will only detect if an unprotected container file contains protected
371 * non-container objects.
372 */
373 FILE_API static std::shared_ptr<FileStatus> __CDECL GetFileStatus(
374 const std::string& filePath,
375 const std::shared_ptr<MipContext>& mipContext,
376 const std::shared_ptr<void>& loggerContext = nullptr);
377
378 /**
379 * @brief Checks whether a file is labeled, protected, or contains protected objects.
380 *
381 * @param stream Stream containing file data to check
382 * @param filePath File path associated with data in 'stream', which must include the file name and,
383 * if one exists, the file extension. The file extension is used to determine the file format.
384 * Passing in the wrong file extension will cause unexpected behavior.
385 * @param mipContext Global MIP context
386 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
387 *
388 * @return The shared pointer of a FileStatus object.
389 *
390 * @note This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured
391 * to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an
392 * application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to
393 * retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.
394 * For container files like msg, this method will only detect if an unprotected container file contains protected
395 * non-container objects.
396 */
397 FILE_API static std::shared_ptr<FileStatus> __CDECL GetFileStatus(
398 const std::shared_ptr<Stream>& stream,
399 const std::string& filePath,
400 const std::shared_ptr<MipContext>& mipContext,
401 const std::shared_ptr<void>& loggerContext = nullptr);
402
403 /**
404 * @brief Get publishing license from the file
405 * @param filePath Path of file to open, which must include the file name and,
406 * if one exists, the file extension. The file extension is used to determine the file format.
407 * @param mipContext Global MIP context
408 * @return Publishing License if file has it.
409 */
410 FILE_API static std::vector<uint8_t> __CDECL GetSerializedPublishingLicense(
411 const std::string& filePath,
412 const std::shared_ptr<MipContext>& mipContext);
413
414 /**
415 * @brief Get publishing license from the file
416 * @param filePath Path of file to open, which must include the file name and,
417 * if one exists, the file extension. The file extension is used to determine the file format.
418 * @param mipContext Global MIP context
419 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
420 * @return Publishing License if file has it.
421 */
422 FILE_API static std::vector<uint8_t> __CDECL GetSerializedPublishingLicense(
423 const std::string& filePath,
424 const std::shared_ptr<MipContext>& mipContext,
425 const std::shared_ptr<void>& loggerContext);
426
427 /**
428 * @brief Get publishing license from the file
429 * @param stream Stream containing file data to check
430 * @param filePath File path associated with data in 'stream', which must include the file name and,
431 * if one exists, the file extension. The file extension is used to determine the file format.
432 * Passing in the wrong file extension will cause unexpected behavior.
433 * @param mipContext Global MIP context
434 * @return Publishing License if file has it.
435 */
436 FILE_API static std::vector<uint8_t> __CDECL GetSerializedPublishingLicense(
437 const std::shared_ptr<Stream>& stream,
438 const std::string& filePath,
439 const std::shared_ptr<MipContext>& mipContext);
440
441 /**
442 * @brief Get publishing license from the file
443 * @param stream Stream containing file data to check
444 * @param filePath File path associated with data in 'stream', which must include the file name and,
445 * if one exists, the file extension. The file extension is used to determine the file format.
446 * Passing in the wrong file extension will cause unexpected behavior.
447 * @param mipContext Global MIP context
448 * @param loggerContext Logger context that will be opaquely passed to the logger delegate
449 * @return Publishing License if file has it.
450 */
451 FILE_API static std::vector<uint8_t> __CDECL GetSerializedPublishingLicense(
452 const std::shared_ptr<Stream>& stream,
453 const std::string& filePath,
454 const std::shared_ptr<MipContext>& mipContext,
455 const std::shared_ptr<void>& loggerContext);
456
457 /**
458 * @brief Executes the rules in the handler and returns the list of actions
459 * to be executed.
460 *
461 * @return list of actions that should be applied on the content.
462 * @throw NotSupportedError when a protection only engine is in use and no policy handler is found.
463 */
464 virtual void ClassifyAsync(const std::shared_ptr<void>& context) = 0;
465
466 /**
467 * @brief Create a file inspector object, used to retrieve file contents from compatible file formats.
468 *
469 * @return a file inspector.
470 */
471 virtual void InspectAsync(const std::shared_ptr<void>& context) = 0;
472
473 /**
474 * @brief Sets the sensitivity label to the file.
475 *
476 * @note Changes won't be written to the file until CommitAsync is called.
477 * Privileged and Auto method allows the API to override any existing label
478 * @warning Throws JustificationRequiredError when setting the label requires
479 * the operation to be justified (via the labelingOptions parameter).
480 * @throw NotSupportedError when a protection only engine is in use and no policy handler is found.
481 */
482 virtual void SetLabel(
483 const std::shared_ptr<Label>& label,
484 const LabelingOptions& labelingOptions,
485 const ProtectionSettings& protectionSettings) = 0;
486
487 /**
488 * @brief Deletes the sensitivity label from the file.
489 *
490 * @note Changes won't be written to the file until CommitAsync is called.
491 * Privileged and Auto method allows the API to override any existing label
492 * @warning Throws JustificationRequiredError when setting the label requires the
493 * operation to be justified (via the labelingOptions parameter).
494 * @throw NotSupportedError when a protection only engine is in use and no policy handler is found.
495 */
496 virtual void DeleteLabel(const LabelingOptions& labelingOptions) = 0;
497
498 /**
499 * @brief Sets either custom or template-based permissions
500 * (according to protectionDescriptor->GetProtectionType) to the file.
501 *
502 * @note Changes won't be written to the file until CommitAsync is called.
503 */
504 virtual void SetProtection(
505 const std::shared_ptr<ProtectionDescriptor>& protectionDescriptor,
506 const ProtectionSettings& protectionSettings) = 0;
507
508 /**
509 * @brief Sets protection on a document using an existing protection handler.
510 *
511 * @note Changes won't be written to the file until CommitAsync is called.
512 */
513 virtual void SetProtection(
514 const std::shared_ptr<ProtectionHandler>& protectionHandler) = 0;
515
516 /**
517 * @brief Removes protection from the file.
518 * If the original file format does not support labeling,
519 * the label will be lost when protection is removed.
520 * When the native format supports labeling, the label metadata is maintained.
521 *
522 * @note Changes won't be written to the file until CommitAsync is called.
523 */
524 virtual void RemoveProtection() = 0;
525
526 /**
527 * @brief Writes the changes to the file specified by the |outputFilePath| parameter.
528 *
529 * @note FileHandler::Observer will be called upon success or failure.
530 *
531 * @warning If the output file's disk space is insufficient, the FileHandler::CommitAsync function may generate corrupted files.
532 * In this case, delete the corrupted files and either adjust the disk size or choose another disk before retrying the operation.
533 */
534 virtual void CommitAsync(const std::string& outputFilePath, const std::shared_ptr<void>& context) = 0;
535
536 /**
537 * @brief Writes the changes to the stream specified by the |outputStream| parameter.
538 *
539 * @note |outputStream| must not be the same as inputStream used for creating the handler.
540 *
541 * @note FileHandler::Observer will be called upon success or failure.
542 *
543 * @warning If the output file's disk space is insufficient, the FileHandler::CommitAsync function may generate corrupted files.
544 * In this case, delete the corrupted files and either adjust the disk size or choose another disk before retrying the operation.
545 */
546 virtual void CommitAsync(const std::shared_ptr<Stream>& outputStream, const std::shared_ptr<void>& context) = 0;
547
548 /**
549 * @brief Checks if there are changes to commit to the file.
550 * @note Changes won't be written to the file until CommitAsync is called.
551 */
552 virtual bool IsModified() = 0;
553
554 /**
555 * @brief Returns a path to a temporary file (that will be deleted if possible) - representing the decrypted content.
556 *
557 * @note FileHandler::Observer will be called upon success or failure.
558 */
559 virtual void GetDecryptedTemporaryFileAsync(const std::shared_ptr<void>& context) = 0;
560
561 /**
562 * @brief Returns a stream - representing the decrypted content.
563 *
564 * @note FileHandler::Observer will be called upon success or failure.
565 */
566 virtual void GetDecryptedTemporaryStreamAsync(const std::shared_ptr<void>& context) = 0;
567
568 /**
569 * @brief To be called when the changes have been committed to disk
570 * @param actualFilePath The actual file path for the output file
571 * @note Fires an Audit event
572 * @throw NotSupportedError when a protection only engine is in use and no policy handler is found.
573 */
574 virtual void NotifyCommitSuccessful(const std::string& actualFilePath) = 0;
575
576 /**
577 * @brief Calculates the output file name and extension based on the original file name and the accumulated changes.
578 */
579 virtual std::string GetOutputFileName() = 0;
580
581/** @cond DOXYGEN_HIDE */
582 virtual ~FileHandler() {}
583 /** @endcond */
584
585protected:
586/** @cond DOXYGEN_HIDE */
587 FileHandler() {}
588 /** @endcond */
589};
590
591MIP_NAMESPACE_END
592
593#endif // API_MIP_FILE_FILE_HANDLER_H_
A file containing the Action base class and the ActionType enumerator.
Observer interface for clients to get notifications events related to file handler.
virtual void OnCommitFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when committing the changes to the file failed.
virtual void OnCreateFileHandlerFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when creating the handler failed.
virtual void OnInspectSuccess(const std::shared_ptr< FileInspector > &fileInspector, const std::shared_ptr< void > &context)
Called when inspect success.
virtual void OnGetDecryptedTemporaryFileFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when getting the decrypted temporary file failed.
virtual void OnGetDecryptedTemporaryFileSuccess(const std::string &decryptedFilePath, const std::shared_ptr< void > &context)
Called when getting the decrypted temporary file success.
virtual void OnGetDecryptedTemporaryStreamSuccess(const std::shared_ptr< Stream > &decryptedStream, const std::shared_ptr< void > &context)
Called when getting the decrypted temporary stream success.
virtual void OnClassifySuccess(const std::vector< std::shared_ptr< Action > > &actions, const std::shared_ptr< void > &context)
Called when classify success.
virtual void OnGetDecryptedTemporaryStreamFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when getting the decrypted temporary stream failed.
virtual void OnClassifyFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when classify failed.
virtual void OnCommitSuccess(bool committed, const std::shared_ptr< void > &context)
Called when committing the changes to the file were successful.
virtual void OnInspectFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when inspect failed.
virtual void OnCreateFileHandlerSuccess(const std::shared_ptr< FileHandler > &fileHandler, const std::shared_ptr< void > &context)
Called when the handler is created successfully.
Interface for all file handling functions.
virtual void DeleteLabel(const LabelingOptions &labelingOptions)=0
Deletes the sensitivity label from the file.
static FILE_API bool __CDECL IsLabeledOrProtected(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Checks whether a file is labeled/protected or not.
static FILE_API bool __CDECL IsProtected(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Checks whether a file is protected or not.
static FILE_API std::shared_ptr< FileStatus > __CDECL GetFileStatus(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext=nullptr)
Checks whether a file is labeled, protected, or contains protected objects.
virtual void SetLabel(const std::shared_ptr< Label > &label, const LabelingOptions &labelingOptions, const ProtectionSettings &protectionSettings)=0
Sets the sensitivity label to the file.
static FILE_API std::shared_ptr< FileStatus > __CDECL GetFileStatus(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext=nullptr)
Checks whether a file is labeled, protected, or contains protected objects.
static FILE_API bool __CDECL IsProtected(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Checks whether a file is protected or not.
static FILE_API bool __CDECL IsProtected(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Checks whether a file is protected or not.
static FILE_API std::vector< uint8_t > __CDECL GetSerializedPublishingLicense(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Get publishing license from the file.
virtual void RemoveProtection()=0
Removes protection from the file.
virtual void CommitAsync(const std::shared_ptr< Stream > &outputStream, const std::shared_ptr< void > &context)=0
Writes the changes to the stream specified by the |outputStream| parameter.
static FILE_API std::vector< uint8_t > __CDECL GetSerializedPublishingLicense(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Get publishing license from the file.
virtual void SetProtection(const std::shared_ptr< ProtectionHandler > &protectionHandler)=0
Sets protection on a document using an existing protection handler.
virtual void InspectAsync(const std::shared_ptr< void > &context)=0
Create a file inspector object, used to retrieve file contents from compatible file formats.
static FILE_API bool __CDECL IsLabeledOrProtected(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Checks whether a file is labeled/protected or not.
static FILE_API bool __CDECL IsProtected(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Checks whether a file is protected or not.
virtual void RegisterContentForTrackingAndRevocationAsync(bool isOwnerNotificationEnabled, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context)=0
Register the content for tracking and revocation.
virtual std::shared_ptr< ProtectionHandler > GetProtection()=0
Starts retrieving the protection policy from the file.
virtual void GetDecryptedTemporaryStreamAsync(const std::shared_ptr< void > &context)=0
Returns a stream - representing the decrypted content.
virtual std::shared_ptr< ContentLabel > GetLabel()=0
Starts retrieving the sensitivity label from the file.
virtual void SetProtection(const std::shared_ptr< ProtectionDescriptor > &protectionDescriptor, const ProtectionSettings &protectionSettings)=0
Sets either custom or template-based permissions (according to protectionDescriptor->GetProtectionTyp...
virtual void GetDecryptedTemporaryFileAsync(const std::shared_ptr< void > &context)=0
Returns a path to a temporary file (that will be deleted if possible) - representing the decrypted co...
static FILE_API std::vector< uint8_t > __CDECL GetSerializedPublishingLicense(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Get publishing license from the file.
virtual void RevokeContentAsync(const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context)=0
Perform revocation for the content.
virtual std::vector< std::pair< std::string, std::string > > GetProperties(uint32_t version)=0
Retrieves the file properties according to version.
virtual void NotifyCommitSuccessful(const std::string &actualFilePath)=0
To be called when the changes have been committed to disk.
static FILE_API bool __CDECL IsLabeledOrProtected(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Checks whether a file is labeled/protected or not.
virtual void ClassifyAsync(const std::shared_ptr< void > &context)=0
Executes the rules in the handler and returns the list of actions to be executed.
static FILE_API bool __CDECL IsLabeledOrProtected(const std::shared_ptr< Stream > &stream, const std::string &filePath, const std::shared_ptr< MipContext > &mipContext)
Checks whether a file is labeled/protected or not.
virtual std::string GetOutputFileName()=0
Calculates the output file name and extension based on the original file name and the accumulated cha...
static FILE_API std::vector< uint8_t > __CDECL GetSerializedPublishingLicense(const std::string &filePath, const std::shared_ptr< MipContext > &mipContext, const std::shared_ptr< void > &loggerContext)
Get publishing license from the file.
virtual bool IsModified()=0
Checks if there are changes to commit to the file.
virtual void CommitAsync(const std::string &outputFilePath, const std::shared_ptr< void > &context)=0
Writes the changes to the file specified by the |outputFilePath| parameter.
Interface for configuring labeling options for the SetLabel/DeleteLabel methods.
Interface for configuring protection options for the SetLabel method.
A file Containing the ContentLabel class.
#define FILE_API
Definition file_export.h:47
File containing definition of MipContext.
MIP namespace macros.
Defines ProtectionDescriptor interface.
Defines ProtectionEngine interface.
Defines ProtectionHandler interface.
A file containing the Stream interface/class definition.