33#ifndef API_MIP_PROTECTION_PROTECTION_HANDLER_H_
34#define API_MIP_PROTECTION_PROTECTION_HANDLER_H_
83 const std::shared_ptr<ProtectionHandler>& protectionHandler,
84 const std::shared_ptr<void>& context) { UNUSED(protectionHandler); UNUSED(context); };
100 const std::exception_ptr& error,
101 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
128 const std::vector<uint8_t>& serializedPreLicense,
129 const std::vector<uint8_t>& serializedPublishingLicense)
130 : mLicenseInfo(std::make_shared<
PublishingLicenseInfo>(serializedPreLicense, serializedPublishingLicense)) {}
141 : mLicenseInfo(licenseInfo) {}
177 void SetContentName(
const std::string& contentName) { mContentName = contentName;}
212 if (mCapabilities ==
nullptr) {
return mCapabilities; }
213 return std::make_shared<std::vector<std::string>>(*mCapabilities);
218 std::shared_ptr<PublishingLicenseInfo> mLicenseInfo;
219 std::string mDelegatedUserEmail;
220 std::string mContentName;
221 std::shared_ptr<std::vector<std::string>> mCapabilities;
236 : mProtectionDescriptor(protectionDescriptor),
237 mIsAuditedExtractionAllowed(false),
238 mIsDeprecatedAlgorithmPreferred(false),
239 mIsPublishingFormatJson(false),
240 mRepairLabelIdAllowed(false),
241 mRegenerateContentKey(false) {}
250 const std::shared_ptr<ProtectionDescriptor>& protectionDescriptor,
251 const std::vector<uint8_t>& serializedPublishingLicense)
252 : mProtectionDescriptor(protectionDescriptor),
253 mRepublishingLicense(serializedPublishingLicense),
254 mIsAuditedExtractionAllowed(false),
255 mIsDeprecatedAlgorithmPreferred(false),
256 mIsPublishingFormatJson(false),
257 mRepairLabelIdAllowed(false),
258 mRegenerateContentKey(false) {}
267 const std::shared_ptr<ProtectionDescriptor>& protectionDescriptor,
268 const std::shared_ptr<ProtectionHandler>& protectionHandler)
269 : mProtectionDescriptor(protectionDescriptor),
270 mProtectionHandler(protectionHandler),
271 mIsAuditedExtractionAllowed(false),
272 mIsDeprecatedAlgorithmPreferred(false),
273 mIsPublishingFormatJson(false),
274 mRepairLabelIdAllowed(false),
275 mRegenerateContentKey(false) {}
297 mIsAuditedExtractionAllowed = isAuditedExtractionAllowed;
313 mIsDeprecatedAlgorithmPreferred = isDeprecatedAlgorithmPreferred;
348 mIsPublishingFormatJson = isPublishingFormatJson;
364 mRegenerateContentKey = regenerateContentKey;
374#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
375 [[deprecated(
"SetPreLicenseUserEmail is deprecated, use SetRequestPreLicense")]]
378 if(mPublishingUseLicenseRequest ==
nullptr) {
381 mPublishingUseLicenseRequest->SetDelegatedUserEmail(preLicenseUserEmail);
389#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
390 [[deprecated(
"GetPreLicenseUserEmail is deprecated, use GetPreLicenseRequest")]]
393 static std::string empty;
394 return mPublishingUseLicenseRequest !=
nullptr ? mPublishingUseLicenseRequest->GetDelegatedUserEmail() : empty; }
402 return mRepublishingLicense;
413 mPublishingUseLicenseRequest = publishingUseLicenseRequest;
422 return mPublishingUseLicenseRequest;
443 mRepairLabelIdAllowed = repairAllowed;
448 std::shared_ptr<ProtectionDescriptor> mProtectionDescriptor;
449 std::vector<uint8_t> mRepublishingLicense;
450 std::shared_ptr<ProtectionHandler> mProtectionHandler;
451 bool mIsAuditedExtractionAllowed;
452 bool mIsDeprecatedAlgorithmPreferred;
453 bool mIsPublishingFormatJson;
454 bool mRepairLabelIdAllowed;
455 bool mRegenerateContentKey;
456 std::string mDelegatedUserEmail;
457 std::shared_ptr<PublishingUseLicenseRequest> mPublishingUseLicenseRequest;
479 const std::shared_ptr<Stream>& backingStream,
480 int64_t contentStartPosition,
481 int64_t contentSize) = 0;
496 int64_t offsetFromStart,
497 const uint8_t* inputBuffer,
498 int64_t inputBufferSize,
499 uint8_t* outputBuffer,
500 int64_t outputBufferSize,
516 int64_t offsetFromStart,
517 const uint8_t* inputBuffer,
518 int64_t inputBufferSize,
519 uint8_t* outputBuffer,
520 int64_t outputBufferSize,
645 virtual const std::shared_ptr<CryptoProvider> GetCryptoProvider() = 0;
646 virtual const std::shared_ptr<CryptoProvider>& GetPolicyCryptoProvider()
const = 0;
Settings to use for protection operations.
Definition protection_common_settings.h:46
Settings used to create a ProtectionHandler to consume existing content.
Definition protection_handler.h:111
MIP_API bool RemoveRmsCapability(const std::string &capability)
Remove one of the added usage rights capabilities which get passed to RMS.
ConsumptionSettings(const std::shared_ptr< PublishingLicenseInfo > &licenseInfo)
ProtectionHandler::ConsumptionSettings constructor for creating a new handler.
Definition protection_handler.h:140
void SetContentName(const std::string &contentName)
Defines the content name to register with document tracking.
Definition protection_handler.h:177
ConsumptionSettings(const std::vector< uint8_t > &serializedPublishingLicense)
ProtectionHandler::ConsumptionSettings constructor for creating a new handler.
Definition protection_handler.h:118
const std::string & GetContentName() const
Gets the content name to register with document tracking.
Definition protection_handler.h:184
const std::string & GetDelegatedUserEmail() const
Gets the delegated user.
Definition protection_handler.h:168
ConsumptionSettings(const std::vector< uint8_t > &serializedPreLicense, const std::vector< uint8_t > &serializedPublishingLicense)
ProtectionHandler::ConsumptionSettings constructor for creating a new handler.
Definition protection_handler.h:127
std::shared_ptr< PublishingLicenseInfo > GetPublishingLicenseInfo() const
Get the publishing license associated with the protected content.
Definition protection_handler.h:148
const std::shared_ptr< std::vector< std::string > > GetRmsCapabilities() const
The the full set of client capabilities supported when fetching usage rights from RMS.
Definition protection_handler.h:211
void SetDelegatedUserEmail(const std::string &delegatedUserEmail)
Sets the delegated user.
Definition protection_handler.h:159
MIP_API void AddRmsCapability(const std::string &capability)
Add a capability which will be passed along to RMS when fetching usage rights.
Interface that receives notifications related to ProtectionHandler.
Definition protection_handler.h:67
virtual void OnCreateProtectionHandlerFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when ProtectionHandler creation failed.
Definition protection_handler.h:99
virtual void OnCreateProtectionHandlerSuccess(const std::shared_ptr< ProtectionHandler > &protectionHandler, const std::shared_ptr< void > &context)
Called when ProtectionHandler was created successfully.
Definition protection_handler.h:82
Settings used to create a ProtectionHandler to protect new content.
Definition protection_handler.h:228
bool GetIsDeprecatedAlgorithmPreferred() const
Gets whether or not deprecated crypto algorithm (ECB) is preferred for backwards compatibility.
Definition protection_handler.h:305
void SetRequestPreLicense(std::shared_ptr< PublishingUseLicenseRequest > publishingUseLicenseRequest)
Setting this will cause the publishing request to include a pre-license.
Definition protection_handler.h:412
const std::string & GetPreLicenseUserEmail() const
Gets the pre-license user.
Definition protection_handler.h:392
std::shared_ptr< ProtectionDescriptor > GetProtectionDescriptor() const
Definition protection_handler.h:277
bool GetRegenerateContentKey() const
Gets whether or not the content key and ID should be regenerated during republishing.
Definition protection_handler.h:356
void SetRepairLabelIdAllowed(bool repairAllowed)
Sets whether or not label id can be added to publishing license on republish.
Definition protection_handler.h:442
const std::string & GetDelegatedUserEmail() const
Gets the delegated user.
Definition protection_handler.h:332
const std::vector< uint8_t > & GetPublishingLicenseForRepublish() const
Gets the serialized republishing license.
Definition protection_handler.h:401
bool GetRepairLabelIdAllowed() const
Gets whether or not label id can be added to publishing license on republish.
Definition protection_handler.h:432
void SetPublishingFormatJson(bool isPublishingFormatJson)
Sets whether or not the returned pl is in json format (xml format is more widely accepted and is the ...
Definition protection_handler.h:347
PublishingSettings(const std::shared_ptr< ProtectionDescriptor > &protectionDescriptor)
PublishingSettings constructor for enforcing protection on content.
Definition protection_handler.h:235
PublishingSettings(const std::shared_ptr< ProtectionDescriptor > &protectionDescriptor, const std::vector< uint8_t > &serializedPublishingLicense)
PublishingSettings constructor for online republishing.
Definition protection_handler.h:249
void SetIsAuditedExtractionAllowed(bool isAuditedExtractionAllowed)
Sets whether or not non-MIP-aware applications are allowed to open protected content.
Definition protection_handler.h:296
void SetIsDeprecatedAlgorithmPreferred(bool isDeprecatedAlgorithmPreferred)
Sets whether or not deprecated crypto algorithm (ECB) is preferred for backwards compatibility.
Definition protection_handler.h:312
std::shared_ptr< PublishingUseLicenseRequest > GetPreLicenseRequest() const
Gets the pre-license request.
Definition protection_handler.h:421
bool GetIsAuditedExtractionAllowed() const
Gets whether or not non-MIP-aware applications are allowed to open protected content.
Definition protection_handler.h:289
void SetDelegatedUserEmail(const std::string &delegatedUserEmail)
Sets the delegated user.
Definition protection_handler.h:323
void SetRegenerateContentKey(bool regenerateContentKey)
Sets whether or not the content key and ID should be regenerated during republishing.
Definition protection_handler.h:363
bool IsPublishingFormatJson() const
Gets whether or not the returned pl is in json format (xml format is more widely accepted and is the ...
Definition protection_handler.h:340
PublishingSettings(const std::shared_ptr< ProtectionDescriptor > &protectionDescriptor, const std::shared_ptr< ProtectionHandler > &protectionHandler)
PublishingSettings constructor for offline republishing.
Definition protection_handler.h:266
std::shared_ptr< ProtectionHandler > GetProtectionHandlerForRepublish() const
Gets protection handler for republishing scenario.
Definition protection_handler.h:282
void SetPreLicenseUserEmail(const std::string &preLicenseUserEmail)
Sets pre-license user.
Definition protection_handler.h:377
Manages protection-related actions for a specific protection configuration.
Definition protection_handler.h:60
virtual const std::string GetContentId()=0
Gets unique identifier for the document/content.
virtual bool IsAuditedExtractAllowed()=0
Gets if protection handler grants user 'audited extract' right or not.
virtual bool IsIssuedToOwner()=0
Gets if the current user is the content owner or not.
virtual int64_t DecryptBuffer(int64_t offsetFromStart, const uint8_t *inputBuffer, int64_t inputBufferSize, uint8_t *outputBuffer, int64_t outputBufferSize, bool isFinal)=0
Decrypt a buffer.
virtual const std::vector< uint8_t > & GetSerializedPublishingLicense() const =0
Serialize ProtectionHandler into a publishing license (PL)
virtual int64_t GetProtectedContentLength(int64_t unprotectedLength, bool includesFinalBlock)=0
Calculates size (in bytes) of content if it were to be encrypted with this ProtectionHandler.
virtual bool UsesApplicationDefinedPadding()=0
Gets if protected content requires application-defined padding or if it is handled internally.
virtual std::shared_ptr< ProtectionDescriptor > GetProtectionDescriptor()=0
Gets protection details.
virtual std::shared_ptr< Stream > CreateProtectedStream(const std::shared_ptr< Stream > &backingStream, int64_t contentStartPosition, int64_t contentSize)=0
Create a protected stream that will allow for encryption/decryption of content.
virtual const std::string GetIssuedTo()=0
Gets user associated with the protection handler.
virtual const std::string GetOwner()=0
Gets email address of content owner.
virtual CipherMode GetCipherMode() const =0
Gets the cipher mode of the protection handler.
virtual const std::vector< uint8_t > & GetSerializedPreLicense(PreLicenseFormat format) const =0
Get pre-license.
virtual std::vector< std::string > GetRights() const =0
Gets the rights granted to the user/identity associated with this ProtectionHandler.
virtual bool DoesUseDeprecatedAlgorithms()=0
Gets if protection handler uses deprecated crypto algorithms (ECB) for backward compatibility or not.
PreLicenseFormat
Pre-license format.
Definition protection_handler.h:464
virtual int64_t EncryptBuffer(int64_t offsetFromStart, const uint8_t *inputBuffer, int64_t inputBufferSize, uint8_t *outputBuffer, int64_t outputBufferSize, bool isFinal)=0
Encrypt a buffer.
virtual bool AccessCheck(const std::string &right) const =0
Checks if protection handler grants user access to the specified right.
virtual int64_t GetBlockSize()=0
Gets the block size (in bytes) for the cipher mode used by this ProtectionHandler.
Holds the details of a Publishing License used to create a protection handler.
Definition protection_common_types.h:53
static MIP_API std::shared_ptr< PublishingUseLicenseRequest > __CDECL CreatePublishingUseLicenseRequest()
Creates a PublishingUseLicenseRequest object.
A file Containing the common types used by the upe, file and protection modules.
A file export/import macros.
Defines ProtectionCommonSettings interface.
A file containing the common types used by the protection module.
CipherMode
Cipher mode identifier.
Definition protection_common_types.h:149
Defines ProtectionDescriptor interface.
Defines the PublishingUseLicenseRequest interface.
A file containing the Stream interface/class definition.
Defines UserRights class.