Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
FileHandler Class Referenceabstract

Interface for all file handling functions. More...

#include <src/api/mip/file/file_handler.h>

Classes

class  Observer
 Observer interface for clients to get notifications events related to file handler. More...
 

Public Member Functions

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.
 
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.
 
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.
 
virtual void DeleteLabel (const LabelingOptions &labelingOptions)=0
 Deletes the sensitivity label from the file.
 
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 content.
 
virtual void GetDecryptedTemporaryStreamAsync (const std::shared_ptr< void > &context)=0
 Returns a stream - representing the decrypted content.
 
virtual std::shared_ptr< ContentLabelGetLabel ()=0
 Starts retrieving the sensitivity label from the file.
 
virtual std::string GetOutputFileName ()=0
 Calculates the output file name and extension based on the original file name and the accumulated changes.
 
virtual std::vector< std::pair< std::string, std::string > > GetProperties (uint32_t version)=0
 Retrieves the file properties according to version.
 
virtual std::shared_ptr< ProtectionHandlerGetProtection ()=0
 Starts retrieving the protection policy from the file.
 
virtual void InspectAsync (const std::shared_ptr< void > &context)=0
 Create a file inspector object, used to retrieve file contents from compatible file formats.
 
virtual bool IsModified ()=0
 Checks if there are changes to commit to the file.
 
virtual void NotifyCommitSuccessful (const std::string &actualFilePath)=0
 To be called when the changes have been committed to disk.
 
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 void RemoveProtection ()=0
 Removes protection 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 void SetLabel (const std::shared_ptr< Label > &label, const LabelingOptions &labelingOptions, const ProtectionSettings &protectionSettings)=0
 Sets the sensitivity label to 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->GetProtectionType) to the file.
 
virtual void SetProtection (const std::shared_ptr< ProtectionHandler > &protectionHandler)=0
 Sets protection on a document using an existing protection handler.
 

Static Public Member Functions

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 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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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 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 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.
 
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.
 
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 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.
 

Detailed Description

Interface for all file handling functions.

Definition at line 52 of file file_handler.h.

Member Function Documentation

◆ ClassifyAsync()

virtual void FileHandler::ClassifyAsync ( const std::shared_ptr< void > & context)
pure virtual

Executes the rules in the handler and returns the list of actions to be executed.

Returns
list of actions that should be applied on the content.
Exceptions
NotSupportedErrorwhen a protection only engine is in use and no policy handler is found.

◆ CommitAsync() [1/2]

virtual void FileHandler::CommitAsync ( const std::shared_ptr< Stream > & outputStream,
const std::shared_ptr< void > & context )
pure virtual

Writes the changes to the stream specified by the |outputStream| parameter.

Note
|outputStream| must not be the same as inputStream used for creating the handler.
FileHandler::Observer will be called upon success or failure.
Warning
If the output file's disk space is insufficient, the FileHandler::CommitAsync function may generate corrupted files. In this case, delete the corrupted files and either adjust the disk size or choose another disk before retrying the operation.

◆ CommitAsync() [2/2]

virtual void FileHandler::CommitAsync ( const std::string & outputFilePath,
const std::shared_ptr< void > & context )
pure virtual

Writes the changes to the file specified by the |outputFilePath| parameter.

Note
FileHandler::Observer will be called upon success or failure.
Warning
If the output file's disk space is insufficient, the FileHandler::CommitAsync function may generate corrupted files. In this case, delete the corrupted files and either adjust the disk size or choose another disk before retrying the operation.

◆ DeleteLabel()

virtual void FileHandler::DeleteLabel ( const LabelingOptions & labelingOptions)
pure virtual

Deletes the sensitivity label from the file.

Note
Changes won't be written to the file until CommitAsync is called. Privileged and Auto method allows the API to override any existing label
Warning
Throws JustificationRequiredError when setting the label requires the operation to be justified (via the labelingOptions parameter).
Exceptions
NotSupportedErrorwhen a protection only engine is in use and no policy handler is found.

◆ GetDecryptedTemporaryFileAsync()

virtual void FileHandler::GetDecryptedTemporaryFileAsync ( const std::shared_ptr< void > & context)
pure virtual

Returns a path to a temporary file (that will be deleted if possible) - representing the decrypted content.

Note
FileHandler::Observer will be called upon success or failure.

◆ GetDecryptedTemporaryStreamAsync()

virtual void FileHandler::GetDecryptedTemporaryStreamAsync ( const std::shared_ptr< void > & context)
pure virtual

Returns a stream - representing the decrypted content.

Note
FileHandler::Observer will be called upon success or failure.

◆ GetFileStatus() [1/2]

static FILE_API std::shared_ptr< FileStatus > __CDECL FileHandler::GetFileStatus ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext = nullptr )
static

Checks whether a file is labeled, protected, or contains protected objects.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
The shared pointer of a FileStatus object.
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels. For container files like msg, this method will only detect if an unprotected container file contains protected non-container objects.

◆ GetFileStatus() [2/2]

static FILE_API std::shared_ptr< FileStatus > __CDECL FileHandler::GetFileStatus ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext = nullptr )
static

Checks whether a file is labeled, protected, or contains protected objects.

Parameters
filePathPath of file to check, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
The shared pointer of a FileStatus object.
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels. For container files like msg, this method will only detect if an unprotected container file contains protected non-container objects.

◆ GetLabel()

virtual std::shared_ptr< ContentLabel > FileHandler::GetLabel ( )
pure virtual

Starts retrieving the sensitivity label from the file.

Exceptions
NotSupportedErrorwhen a protection only engine is in use and no policy handler is found.

◆ GetOutputFileName()

virtual std::string FileHandler::GetOutputFileName ( )
pure virtual

Calculates the output file name and extension based on the original file name and the accumulated changes.

◆ GetProperties()

virtual std::vector< std::pair< std::string, std::string > > FileHandler::GetProperties ( uint32_t version)
pure virtual

Retrieves the file properties according to version.

◆ GetProtection()

virtual std::shared_ptr< ProtectionHandler > FileHandler::GetProtection ( )
pure virtual

Starts retrieving the protection policy from the file.

◆ GetSerializedPublishingLicense() [1/4]

static FILE_API std::vector< uint8_t > __CDECL FileHandler::GetSerializedPublishingLicense ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Get publishing license from the file.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
Returns
Publishing License if file has it.

◆ GetSerializedPublishingLicense() [2/4]

static FILE_API std::vector< uint8_t > __CDECL FileHandler::GetSerializedPublishingLicense ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Get publishing license from the file.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
Publishing License if file has it.

◆ GetSerializedPublishingLicense() [3/4]

static FILE_API std::vector< uint8_t > __CDECL FileHandler::GetSerializedPublishingLicense ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Get publishing license from the file.

Parameters
filePathPath of file to open, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
Returns
Publishing License if file has it.

◆ GetSerializedPublishingLicense() [4/4]

static FILE_API std::vector< uint8_t > __CDECL FileHandler::GetSerializedPublishingLicense ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Get publishing license from the file.

Parameters
filePathPath of file to open, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
Publishing License if file has it.

◆ InspectAsync()

virtual void FileHandler::InspectAsync ( const std::shared_ptr< void > & context)
pure virtual

Create a file inspector object, used to retrieve file contents from compatible file formats.

Returns
a file inspector.

◆ IsLabeledOrProtected() [1/4]

static FILE_API bool __CDECL FileHandler::IsLabeledOrProtected ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Checks whether a file is labeled/protected or not.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
Returns
True if file is protected or contains label metadata, else false
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.

◆ IsLabeledOrProtected() [2/4]

static FILE_API bool __CDECL FileHandler::IsLabeledOrProtected ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Checks whether a file is labeled/protected or not.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
True if file is protected or contains label metadata, else false
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.

◆ IsLabeledOrProtected() [3/4]

static FILE_API bool __CDECL FileHandler::IsLabeledOrProtected ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Checks whether a file is labeled/protected or not.

Parameters
filePathPath of file to check, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
Returns
True if file is protected or contains label metadata, else false
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.

◆ IsLabeledOrProtected() [4/4]

static FILE_API bool __CDECL FileHandler::IsLabeledOrProtected ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Checks whether a file is labeled/protected or not.

Parameters
filePathPath of file to check, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
True if file is protected or contains label metadata, else false
Note
This will only detect Microsoft labels. It will not detect 3rd-party labels, even if a tenant is configured to translate 3rd-party label metadata to Microsoft labels. The primary purpose of this API is to allow an application to quickly detect labeled/protected content without any HTTP calls. An HTTP call is required to retrieve the tenant-specific label mapping that is necessary for detecting 3rd-part labels.

◆ IsModified()

virtual bool FileHandler::IsModified ( )
pure virtual

Checks if there are changes to commit to the file.


Note
Changes won't be written to the file until CommitAsync is called.

◆ IsProtected() [1/4]

static FILE_API bool __CDECL FileHandler::IsProtected ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Checks whether a file is protected or not.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
Returns
True if file is protected, else false

◆ IsProtected() [2/4]

static FILE_API bool __CDECL FileHandler::IsProtected ( const std::shared_ptr< Stream > & stream,
const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Checks whether a file is protected or not.

Parameters
streamStream containing file data to check
filePathFile path associated with data in 'stream', which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format. Passing in the wrong file extension will cause unexpected behavior.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
True if file is protected, else false

◆ IsProtected() [3/4]

static FILE_API bool __CDECL FileHandler::IsProtected ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext )
static

Checks whether a file is protected or not.

Parameters
filePathPath of file to check, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
Returns
True if file is protected, else false

◆ IsProtected() [4/4]

static FILE_API bool __CDECL FileHandler::IsProtected ( const std::string & filePath,
const std::shared_ptr< MipContext > & mipContext,
const std::shared_ptr< void > & loggerContext )
static

Checks whether a file is protected or not.

Parameters
filePathPath of file to check, which must include the file name and, if one exists, the file extension. The file extension is used to determine the file format.
mipContextGlobal MIP context
loggerContextLogger context that will be opaquely passed to the logger delegate
Returns
True if file is protected, else false

◆ NotifyCommitSuccessful()

virtual void FileHandler::NotifyCommitSuccessful ( const std::string & actualFilePath)
pure virtual

To be called when the changes have been committed to disk.

Parameters
actualFilePathThe actual file path for the output file
Note
Fires an Audit event
Exceptions
NotSupportedErrorwhen a protection only engine is in use and no policy handler is found.

◆ RegisterContentForTrackingAndRevocationAsync()

virtual void FileHandler::RegisterContentForTrackingAndRevocationAsync ( bool isOwnerNotificationEnabled,
const std::shared_ptr< ProtectionEngine::Observer > & observer,
const std::shared_ptr< void > & context )
pure virtual

Register the content for tracking and revocation.

Parameters
isOwnerNotificationEnabledSet to true to notify the owner via email whenever the document is decrypted, or false to not send the notification.
observerA class implementing the ProtectionHandler::Observer interface
contextClient context that will be opaquely forwarded to observers and optional HttpDelegate
Returns
Async control object.

◆ RemoveProtection()

virtual void FileHandler::RemoveProtection ( )
pure virtual

Removes protection from the file.

If the original file format does not support labeling, the label will be lost when protection is removed. When the native format supports labeling, the label metadata is maintained.

Note
Changes won't be written to the file until CommitAsync is called.

◆ RevokeContentAsync()

virtual void FileHandler::RevokeContentAsync ( const std::shared_ptr< ProtectionEngine::Observer > & observer,
const std::shared_ptr< void > & context )
pure virtual

Perform revocation for the content.

Parameters
observerA class implementing the ProtectionHandler::Observer interface
contextClient context that will be opaquely forwarded to observers and optional HttpDelegate
Returns
Async control object.

◆ SetLabel()

virtual void FileHandler::SetLabel ( const std::shared_ptr< Label > & label,
const LabelingOptions & labelingOptions,
const ProtectionSettings & protectionSettings )
pure virtual

Sets the sensitivity label to the file.

Note
Changes won't be written to the file until CommitAsync is called. Privileged and Auto method allows the API to override any existing label
Warning
Throws JustificationRequiredError when setting the label requires the operation to be justified (via the labelingOptions parameter).
Exceptions
NotSupportedErrorwhen a protection only engine is in use and no policy handler is found.

◆ SetProtection() [1/2]

virtual void FileHandler::SetProtection ( const std::shared_ptr< ProtectionDescriptor > & protectionDescriptor,
const ProtectionSettings & protectionSettings )
pure virtual

Sets either custom or template-based permissions (according to protectionDescriptor->GetProtectionType) to the file.

Note
Changes won't be written to the file until CommitAsync is called.

◆ SetProtection() [2/2]

virtual void FileHandler::SetProtection ( const std::shared_ptr< ProtectionHandler > & protectionHandler)
pure virtual

Sets protection on a document using an existing protection handler.

Note
Changes won't be written to the file until CommitAsync is called.

The documentation for this class was generated from the following file: