33#ifndef API_MIP_PROTECTION_PROTECTION_ENGINE_H_
34#define API_MIP_PROTECTION_PROTECTION_ENGINE_H_
61const int kMinTemplateBatchNum = 1;
62const int kMaxTemplateBatchNum = 25;
94 const std::vector<std::shared_ptr<TemplateDescriptor>>& templateDescriptors,
95 const std::shared_ptr<void>& context) { UNUSED(templateDescriptors); UNUSED(context); }
108 const std::exception_ptr& error,
109 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
122 const std::shared_ptr<std::vector<std::string>>&
rights,
123 const std::shared_ptr<void>& context) { UNUSED(
rights); UNUSED(context); }
136 const std::exception_ptr& error,
137 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
149 const std::shared_ptr<void>& context) { UNUSED(context); }
162 const std::exception_ptr& error,
163 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
175 const std::shared_ptr<void>& context) { UNUSED(context); }
188 const std::exception_ptr& error,
189 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
201 const std::shared_ptr<void>& context) { UNUSED(context); }
214 const std::exception_ptr& error,
215 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
227 std::vector<std::shared_ptr<DelegationLicense>> delegatedLicenses,
228 const std::shared_ptr<void>& context) { UNUSED(delegatedLicenses); UNUSED(context); }
241 const std::exception_ptr& error,
242 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
254 const std::shared_ptr<TenantInformation>& tenantInformation,
255 const std::shared_ptr<void>& context) { UNUSED(tenantInformation); UNUSED(context); }
268 const std::exception_ptr& error,
269 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
282 const std::shared_ptr<LicenseRightsData>& licenseRightsData,
283 const std::shared_ptr<void>& context) { UNUSED(licenseRightsData); UNUSED(context); }
296 const std::exception_ptr& error,
297 const std::shared_ptr<void>& context) { UNUSED(error); UNUSED(context); }
324 const std::shared_ptr<AuthDelegate>& authDelegate,
325 const std::string& clientData,
326 const std::string& locale =
"")
327 : mIdentity(identity),
328 mAuthDelegate(authDelegate),
329 mClientData(clientData),
331 mAllowCloudServiceOnly(false),
332 mTemplateRefreshRate(std::chrono::hours::zero()),
333 mTemplateBatchSize(kMaxTemplateBatchNum) {
334 if (mLocale.compare(
"") == 0) {
351 const std::string& engineId,
352 const std::shared_ptr<AuthDelegate>& authDelegate,
353 const std::string& clientData,
354 const std::string& locale =
"")
355 : mEngineId(engineId),
356 mAuthDelegate(authDelegate),
357 mClientData(clientData),
359 mAllowCloudServiceOnly(false),
360 mTemplateRefreshRate(std::chrono::hours::zero()),
361 mTemplateBatchSize(kMaxTemplateBatchNum) {
362 if (mLocale.compare(
"") == 0) {
379 void SetEngineId(
const std::string& engineId) { mEngineId = engineId; }
407 void SetClientData(
const std::string& clientData) { mClientData = clientData; }
414 const std::string&
GetLocale()
const {
return mLocale; }
421 void SetCustomSettings(
const std::vector<std::pair<std::string, std::string>>& value) { mCustomSettings = value; }
428 const std::vector<std::pair<std::string, std::string>>&
GetCustomSettings()
const {
return mCustomSettings; }
436 mSessionId = sessionId;
477 mDataBoundary = dataBoundary;
486 return mDataBoundary;
497 mCloudEndpointBaseUrl = cloudEndpointBaseUrl;
506 return mCloudEndpointBaseUrl;
515 mAuthDelegate = authDelegate;
583 if (templateRefreshRateHours < std::chrono::hours::zero()) {
584 throw BadInputError(
"Template refresh interval is outside acceptable range.");
586 mTemplateRefreshRate = templateRefreshRateHours;
588 if (templateBatchSize < kMinTemplateBatchNum || templateBatchSize > kMaxTemplateBatchNum) {
589 throw BadInputError(
"Template batch size is outside acceptable range.");
591 mTemplateBatchSize = templateBatchSize;
613#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
629 mLoggerContext = loggerContext;
634 std::string mEngineId;
638 std::shared_ptr<AuthDelegate> mAuthDelegate;
639 std::string mClientData;
640 std::vector<std::pair<std::string, std::string>> mCustomSettings;
641 std::vector<std::string> mCapabilities;
642 std::string mCloudEndpointBaseUrl;
644 std::string mSessionId;
645 std::string mUnderlyingApplicationId;
646 bool mAllowCloudServiceOnly;
647 std::chrono::hours mTemplateRefreshRate;
648 int mTemplateBatchSize;
649 std::shared_ptr<void> mLoggerContext;
670 const std::shared_ptr<ProtectionEngine::Observer>& observer,
671 const std::shared_ptr<void>& context,
672 const std::shared_ptr<const GetTemplatesSettings>& templateSettings) = 0;
683 const std::shared_ptr<ProtectionEngine::Observer>& observer,
684 const std::shared_ptr<void>& context) = 0;
695 const std::shared_ptr<void>& context,
696 const std::shared_ptr<const GetTemplatesSettings>& templateSettings) = 0;
705 virtual std::vector<std::shared_ptr<TemplateDescriptor>>
GetTemplates(
const std::shared_ptr<void>& context) = 0;
731 const std::string& documentId,
732 const std::string& labelId,
733 const std::string& ownerEmail,
734 const std::string& delegatedUserEmail,
735 const std::shared_ptr<ProtectionEngine::Observer>& observer,
736 const std::shared_ptr<void>& context,
752 const std::string& documentId,
753 const std::string& labelId,
754 const std::string& ownerEmail,
755 const std::string& delegatedUserEmail,
756 const std::shared_ptr<void>& context,
773 const std::string& documentId,
774 const std::string& labelId,
775 const std::string& ownerEmail,
776 const std::string& delegatedUserEmail,
777 const std::shared_ptr<void>& context,
793 const std::shared_ptr<ProtectionHandler::Observer>& observer,
794 const std::shared_ptr<void>& context) = 0;
808 const std::shared_ptr<void>& context) = 0;
821 const std::shared_ptr<ProtectionHandler::Observer>& observer,
822 const std::shared_ptr<void>& context) = 0;
834 const std::shared_ptr<void>& context) = 0;
844#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
845 [[deprecated(
"ProtectionEngine::LoadUserCert is deprecated, use ProtectionEngine::LoadUserCertSync")]]
848 const std::shared_ptr<void>& context,
866 const std::shared_ptr<void>& context,
879 const std::shared_ptr<ProtectionEngine::Observer>& observer,
880 const std::shared_ptr<void>& context,
891 const std::vector<uint8_t>& serializedPublishingLicense,
892 const std::string& contentName,
893 bool isOwnerNotificationEnabled,
894 const std::shared_ptr<void>& context,
909 const std::vector<uint8_t>& serializedPublishingLicense,
910 const std::string& contentName,
911 bool isOwnerNotificationEnabled,
912 const std::shared_ptr<ProtectionEngine::Observer>& observer,
913 const std::shared_ptr<void>& context,
923 const std::vector<uint8_t>& serializedPublishingLicense,
924 const std::shared_ptr<void>& context,
937 const std::vector<uint8_t>& serializedPublishingLicense,
938 const std::shared_ptr<ProtectionEngine::Observer>& observer,
939 const std::shared_ptr<void>& context,
954 const std::shared_ptr<void>& context) = 0;
971 const std::shared_ptr<ProtectionEngine::Observer>& observer,
972 const std::shared_ptr<void>& context) = 0;
984 const std::shared_ptr<void>& context) = 0;
1000 const std::shared_ptr<ProtectionEngine::Observer>& observer,
1001 const std::shared_ptr<void>& context) = 0;
1015 const std::vector<uint8_t>& serializedPublishingLicense,
1016 const std::shared_ptr<void>& context,
1032 const std::vector<uint8_t>& serializedPublishingLicense,
1033 const std::shared_ptr<ProtectionEngine::Observer>& observer,
1034 const std::shared_ptr<void>& context,
1049 virtual void DeleteStoredData(std::chrono::time_point<std::chrono::system_clock> timePoint) = 0;
Definition delegation_license_settings.h:47
Abstraction for identity.
Definition common_types.h:278
Settings to use for protection operations.
Definition protection_common_settings.h:46
Interface that receives notifications related to ProtectionEngine.
Definition protection_engine.h:81
virtual void OnRevokeContentSuccess(const std::shared_ptr< void > &context)
Called when revocation of is successful.
Definition protection_engine.h:200
virtual void OnCreateDelegatedLicensesFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when create delegated license fails.
Definition protection_engine.h:240
virtual void OnGetTenantInformationAsyncFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when GetTenantInformationAsync fails.
Definition protection_engine.h:267
virtual void OnGetTenantInformationAsyncSuccess(const std::shared_ptr< TenantInformation > &tenantInformation, const std::shared_ptr< void > &context)
Called when GetTenantInformationAsync is successful.
Definition protection_engine.h:253
virtual void OnGetTemplatesFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when retrieving templates generated an error.
Definition protection_engine.h:107
virtual void OnLoadUserCertSuccess(const std::shared_ptr< void > &context)
Called when user cert loaded successfully.
Definition protection_engine.h:148
virtual void OnRegisterContentForTrackingAndRevocationSuccess(const std::shared_ptr< void > &context)
Called when registration of content for tracking & revocation is successful.
Definition protection_engine.h:174
virtual void OnGetLicenseRightsDataSuccess(const std::shared_ptr< LicenseRightsData > &licenseRightsData, const std::shared_ptr< void > &context)
Called when license rights data were retrieved successfully.
Definition protection_engine.h:281
virtual void OnGetTemplatesSuccess(const std::vector< std::shared_ptr< TemplateDescriptor > > &templateDescriptors, const std::shared_ptr< void > &context)
Called when templates were retrieved successfully.
Definition protection_engine.h:93
virtual void OnRevokeContentFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when revocation of content is fails.
Definition protection_engine.h:213
virtual void OnCreateDelegatedLicensesSuccess(std::vector< std::shared_ptr< DelegationLicense > > delegatedLicenses, const std::shared_ptr< void > &context)
Called when create delegated license is successful.
Definition protection_engine.h:226
virtual void OnGetLicenseRightsDataFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when retrieving license rights data fails.
Definition protection_engine.h:295
virtual void OnGetRightsForLabelIdSuccess(const std::shared_ptr< std::vector< std::string > > &rights, const std::shared_ptr< void > &context)
Called when rights were retrieved successfully.
Definition protection_engine.h:121
virtual void OnRegisterContentForTrackingAndRevocationFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when registration of content for tracking & revocation fails.
Definition protection_engine.h:187
virtual void OnLoadUserCertFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when user cert loaded failed.
Definition protection_engine.h:161
virtual void OnGetRightsForLabelIdFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when retrieving rights for a label ID for the user.
Definition protection_engine.h:135
Settings used by ProtectionEngine during its creation and throughout its lifetime.
Definition protection_engine.h:309
const std::string & GetSessionId() const
Gets the engine session ID.
Definition protection_engine.h:444
MIP_API void AddRmsCapability(const std::string &capability)
Add a capability which will be passed along to RMS when fetching usage rights.
const std::string & GetCloudEndpointBaseUrl() const
Gets the cloud base URL used by all service requests, if specified.
Definition protection_engine.h:505
void SetCustomSettings(const std::vector< std::pair< std::string, std::string > > &value)
Sets name/value pairs used for testing and experimentation.
Definition protection_engine.h:421
std::chrono::hours GetTemplateRefreshInterval() const
Gets the refresh rate of the protection templates.
Definition protection_engine.h:560
void SetDataBoundary(DataBoundary dataBoundary)
Optionally sets the target diagnostic region.
Definition protection_engine.h:476
const std::vector< std::pair< std::string, std::string > > & GetCustomSettings() const
Gets name/value pairs used for testing and experimentation.
Definition protection_engine.h:428
void SetIdentity(const Identity &identity)
Sets the user Identity associated with the engine.
Definition protection_engine.h:393
DataBoundary GetDataBoundary() const
Gets the data boundary region.
Definition protection_engine.h:485
void SetClientData(const std::string &clientData)
Sets custom data specified by client.
Definition protection_engine.h:407
bool GetAllowCloudServiceOnly() const
Gets whether or not only cloud service is allowed.
Definition protection_engine.h:544
Settings(const std::string &engineId, const std::shared_ptr< AuthDelegate > &authDelegate, const std::string &clientData, const std::string &locale="")
ProtectionEngine::Settings constructor for loading an existing engine.
Definition protection_engine.h:350
const std::string & GetClientData() const
Gets custom data specified by client.
Definition protection_engine.h:400
Cloud GetCloud() const
Gets the target cloud used by all service requests.
Definition protection_engine.h:465
Settings(const Identity &identity, const std::shared_ptr< AuthDelegate > &authDelegate, const std::string &clientData, const std::string &locale="")
ProtectionEngine::Settings constructor for creating a new engine.
Definition protection_engine.h:322
MIP_API bool RemoveRmsCapability(const std::string &capability)
Remove one of the added usage rights capabilities which get passed to RMS.
const Identity & GetIdentity() const
Gets the user Identity associated with the engine.
Definition protection_engine.h:386
void SetCloud(Cloud cloud)
Optionally sets the target cloud.
Definition protection_engine.h:456
void SetTemplateRefreshArgs(std::chrono::hours templateRefreshRateHours, int templateBatchSize=kMaxTemplateBatchNum)
Sets a custom refresh rate for templates.
Definition protection_engine.h:582
void SetEngineId(const std::string &engineId)
Sets the engine ID.
Definition protection_engine.h:379
int GetTemplateBatchSize() const
Gets the number of templates to be requested in each batch during GetTemplates.
Definition protection_engine.h:567
void SetSessionId(const std::string &sessionId)
Sets the engine session ID, used for correlation of logging/telemetry.
Definition protection_engine.h:435
void SetAuthDelegate(const std::shared_ptr< AuthDelegate > &authDelegate)
Set the Engine Auth Delegate.
Definition protection_engine.h:514
const std::string & GetUnderlyingApplicationId() const
Gets the Underlying Application ID.
Definition protection_engine.h:530
void SetAllowCloudServiceOnly(bool allowCloudServiceOnly)
Sets whether or not only cloud service is allowed.
Definition protection_engine.h:551
const std::shared_ptr< void > & GetLoggerContext() const
Get logger context that will be opaquely passed to the logger delegate for logs associated with the c...
Definition protection_engine.h:619
void SetLoggerContext(const std::shared_ptr< void > &loggerContext)
Sets the logger context that will be opaquely passed to the logger delegate for logs associated with ...
Definition protection_engine.h:628
const std::string & GetEngineId() const
Gets the engine ID.
Definition protection_engine.h:372
void SetUnderlyingApplicationId(const std::string &underlyingApplicationId)
Sets the Underlying Application ID.
Definition protection_engine.h:537
std::shared_ptr< AuthDelegate > GetAuthDelegate() const
Get the Engine Auth Delegate.
Definition protection_engine.h:523
std::vector< std::string > GetRmsCapabilities() const
The the full set of client capabilities supported when fetching usage rights from RMS.
Definition protection_engine.h:611
const std::string & GetLocale() const
Gets the locale in which engine data will be written.
Definition protection_engine.h:414
void SetCloudEndpointBaseUrl(const std::string &cloudEndpointBaseUrl)
Sets the cloud endpoint base URL for custom cloud.
Definition protection_engine.h:496
Manages protection-related actions related to a specific identity.
Definition protection_engine.h:74
virtual void DeleteStoredData(bool deleteAllData=false)=0
Removes stored data from the license store.
virtual std::shared_ptr< AsyncControl > LoadUserCertAsync(const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
pre-emptively load user licensor certificate, useful when background loading else using prelicense mi...
virtual std::shared_ptr< AsyncControl > GetLicenseRightsDataAsync(const std::vector< uint8_t > &serializedPublishingLicense, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Get the rights data for a license. This method requires the requesting identity to be included in the...
virtual std::shared_ptr< mip::LicenseInfo > GetLicenseInfoForLabelId(const std::string &documentId, const std::string &labelId, const std::string &ownerEmail, const std::string &delegatedUserEmail, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Get the collection of properties (including usage rights) associated with a user for a given label ID...
virtual void RevokeContent(const std::vector< uint8_t > &serializedPublishingLicense, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Perform revocation for content.
virtual std::vector< std::string > GetRightsForLabelId(const std::string &documentId, const std::string &labelId, const std::string &ownerEmail, const std::string &delegatedUserEmail, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Get collection of rights available to a user for a labelId.
virtual std::shared_ptr< AsyncControl > RevokeContentAsync(const std::vector< uint8_t > &serializedPublishingLicense, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Perform revocation for content.
virtual std::shared_ptr< AsyncControl > GetTemplatesAsync(const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const std::shared_ptr< const GetTemplatesSettings > &templateSettings)=0
Get collection of templates available to a user.
virtual std::shared_ptr< AsyncControl > CreateDelegationLicensesAsync(const DelegationLicenseSettings &settings, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context)=0
Creates a delegated license.
virtual std::shared_ptr< AsyncControl > CreateProtectionHandlerForConsumptionAsync(const ProtectionHandler::ConsumptionSettings &settings, const std::shared_ptr< ProtectionHandler::Observer > &observer, const std::shared_ptr< void > &context)=0
Creates a protection handler where rights/roles are assigned to specific users.
virtual std::vector< std::shared_ptr< TemplateDescriptor > > GetTemplates(const std::shared_ptr< void > &context)=0
Get collection of templates available to a user.
virtual void RegisterContentForTrackingAndRevocation(const std::vector< uint8_t > &serializedPublishingLicense, const std::string &contentName, bool isOwnerNotificationEnabled, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Register publishing license (PL) for document tracking & revocation.
virtual std::vector< std::shared_ptr< TemplateDescriptor > > GetTemplates(const std::shared_ptr< void > &context, const std::shared_ptr< const GetTemplatesSettings > &templateSettings)=0
Get collection of templates available to a user.
virtual void DeleteStoredData(std::chrono::time_point< std::chrono::system_clock > timePoint)=0
Removes stored data from the license store past a specific time point.
virtual std::shared_ptr< ProtectionHandler > CreateProtectionHandlerForPublishing(const ProtectionHandler::PublishingSettings &settings, const std::shared_ptr< void > &context)=0
Creates a protection handler where rights/roles are assigned to specific users.
virtual bool LoadUserCert(const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())
pre-emptively load user licensor certificate, useful when background loading else using prelicense mi...
Definition protection_engine.h:847
virtual std::shared_ptr< AsyncControl > CreateProtectionHandlerForPublishingAsync(const ProtectionHandler::PublishingSettings &settings, const std::shared_ptr< ProtectionHandler::Observer > &observer, const std::shared_ptr< void > &context)=0
Creates a protection handler where rights/roles are assigned to specific users.
virtual std::vector< std::shared_ptr< DelegationLicense > > CreateDelegationLicenses(const DelegationLicenseSettings &settings, const std::shared_ptr< void > &context)=0
Creates a delegated license.
virtual std::shared_ptr< ProtectionHandler > CreateProtectionHandlerForConsumption(const ProtectionHandler::ConsumptionSettings &settings, const std::shared_ptr< void > &context)=0
Creates a protection handler where rights/roles are assigned to specific users.
virtual std::shared_ptr< AsyncControl > GetRightsForLabelIdAsync(const std::string &documentId, const std::string &labelId, const std::string &ownerEmail, const std::string &delegatedUserEmail, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Get collection of rights available to a user for a label ID.
virtual bool IsFeatureSupported(FeatureId featureId)=0
Check is feature supported.
virtual std::shared_ptr< TenantInformation > GetTenantInformation(const ProtectionCommonSettings &settings, const std::shared_ptr< void > &context)=0
Loads user licensor certificate and returns information about the tenant.
virtual std::shared_ptr< AsyncControl > GetTenantInformationAsync(const ProtectionCommonSettings &settings, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context)=0
Loads user licensor certificate and returns information about the tenant.
virtual void LoadUserCertSync(const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
pre-emptively load user licensor certificate, useful when background loading else using prelicense mi...
virtual std::shared_ptr< AsyncControl > RegisterContentForTrackingAndRevocationAsync(const std::vector< uint8_t > &serializedPublishingLicense, const std::string &contentName, bool isOwnerNotificationEnabled, const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Register publishing license (PL) for document tracking & revocation.
virtual std::shared_ptr< LicenseRightsData > GetLicenseRightsData(const std::vector< uint8_t > &serializedPublishingLicense, const std::shared_ptr< void > &context, const ProtectionCommonSettings &settings=ProtectionCommonSettings())=0
Get the rights data for a license. This method requires the requesting identity to be included in the...
virtual const Settings & GetSettings() const =0
Gets the engine settings.
virtual std::shared_ptr< AsyncControl > GetTemplatesAsync(const std::shared_ptr< ProtectionEngine::Observer > &observer, const std::shared_ptr< void > &context)=0
Get collection of templates available to a user.
Settings used to create a ProtectionHandler to consume existing content.
Definition protection_handler.h:111
Settings used to create a ProtectionHandler to protect new content.
Definition protection_handler.h:228
A file Containing the common types used by the upe, file and protection modules.
FeatureId
Defines new features by name.
Definition common_types.h:151
Cloud
Azure cloud identifier.
Definition common_types.h:752
DataBoundary
Diagnostic region identifier for non-sovereign clouds.
Definition common_types.h:769
Defines DelegationLicense interface.
Defines DelegationLicenseSettings class.
A file containing the MIP SDK error types.
Defines GetTemplatesSettings interface.
Defines LicenseInfo interface.
Defines LicenseRightstData interface.
A file export/import macros.
A file containing the common types used by the protection module.
Defines ProtectionDescriptor interface.
Defines ProtectionHandler interface.
Defines TemplateDescriptor interface.