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;
845 const std::shared_ptr<void>& context,
858 const std::shared_ptr<ProtectionEngine::Observer>& observer,
859 const std::shared_ptr<void>& context,
870 const std::vector<uint8_t>& serializedPublishingLicense,
871 const std::string& contentName,
872 bool isOwnerNotificationEnabled,
873 const std::shared_ptr<void>& context,
888 const std::vector<uint8_t>& serializedPublishingLicense,
889 const std::string& contentName,
890 bool isOwnerNotificationEnabled,
891 const std::shared_ptr<ProtectionEngine::Observer>& observer,
892 const std::shared_ptr<void>& context,
902 const std::vector<uint8_t>& serializedPublishingLicense,
903 const std::shared_ptr<void>& context,
916 const std::vector<uint8_t>& serializedPublishingLicense,
917 const std::shared_ptr<ProtectionEngine::Observer>& observer,
918 const std::shared_ptr<void>& context,
933 const std::shared_ptr<void>& context) = 0;
950 const std::shared_ptr<ProtectionEngine::Observer>& observer,
951 const std::shared_ptr<void>& context) = 0;
963 const std::shared_ptr<void>& context) = 0;
979 const std::shared_ptr<ProtectionEngine::Observer>& observer,
980 const std::shared_ptr<void>& context) = 0;
994 const std::vector<uint8_t>& serializedPublishingLicense,
995 const std::shared_ptr<void>& context,
1011 const std::vector<uint8_t>& serializedPublishingLicense,
1012 const std::shared_ptr<ProtectionEngine::Observer>& observer,
1013 const std::shared_ptr<void>& context,
Abstraction for identity.
Settings to use for protection operations.
Interface that receives notifications related to ProtectionEngine.
virtual void OnRevokeContentSuccess(const std::shared_ptr< void > &context)
Called when revocation of is successful.
virtual void OnCreateDelegatedLicensesFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when create delegated license fails.
virtual void OnGetTenantInformationAsyncFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when GetTenantInformationAsync fails.
virtual void OnGetTenantInformationAsyncSuccess(const std::shared_ptr< TenantInformation > &tenantInformation, const std::shared_ptr< void > &context)
Called when GetTenantInformationAsync is successful.
virtual void OnGetTemplatesFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when retrieving templates generated an error.
virtual void OnLoadUserCertSuccess(const std::shared_ptr< void > &context)
Called when user cert loaded successfully.
virtual void OnRegisterContentForTrackingAndRevocationSuccess(const std::shared_ptr< void > &context)
Called when registration of content for tracking & revocation is successful.
virtual void OnGetLicenseRightsDataSuccess(const std::shared_ptr< LicenseRightsData > &licenseRightsData, const std::shared_ptr< void > &context)
Called when license rights data were retrieved successfully.
virtual void OnGetTemplatesSuccess(const std::vector< std::shared_ptr< TemplateDescriptor > > &templateDescriptors, const std::shared_ptr< void > &context)
Called when templates were retrieved successfully.
virtual void OnRevokeContentFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when revocation of content is fails.
virtual void OnCreateDelegatedLicensesSuccess(std::vector< std::shared_ptr< DelegationLicense > > delegatedLicenses, const std::shared_ptr< void > &context)
Called when create delegated license is successful.
virtual void OnGetLicenseRightsDataFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when retrieving license rights data fails.
virtual void OnGetRightsForLabelIdSuccess(const std::shared_ptr< std::vector< std::string > > &rights, const std::shared_ptr< void > &context)
Called when rights were retrieved successfully.
virtual void OnRegisterContentForTrackingAndRevocationFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when registration of content for tracking & revocation fails.
virtual void OnLoadUserCertFailure(const std::exception_ptr &error, const std::shared_ptr< void > &context)
Called when user cert loaded failed.
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.
Settings used by ProtectionEngine during its creation and throughout its lifetime.
const std::string & GetSessionId() const
Gets the engine session ID.
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.
void SetCustomSettings(const std::vector< std::pair< std::string, std::string > > &value)
Sets name/value pairs used for testing and experimentation.
std::chrono::hours GetTemplateRefreshInterval() const
Gets the refresh rate of the protection templates.
void SetDataBoundary(DataBoundary dataBoundary)
Optionally sets the target diagnostic region.
const std::vector< std::pair< std::string, std::string > > & GetCustomSettings() const
Gets name/value pairs used for testing and experimentation.
void SetIdentity(const Identity &identity)
Sets the user Identity associated with the engine.
DataBoundary GetDataBoundary() const
Gets the data boundary region.
void SetClientData(const std::string &clientData)
Sets custom data specified by client.
bool GetAllowCloudServiceOnly() const
Gets whether or not only cloud service is allowed.
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.
const std::string & GetClientData() const
Gets custom data specified by client.
Cloud GetCloud() const
Gets the target cloud used by all service requests.
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.
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.
void SetCloud(Cloud cloud)
Optionally sets the target cloud.
void SetTemplateRefreshArgs(std::chrono::hours templateRefreshRateHours, int templateBatchSize=kMaxTemplateBatchNum)
Sets a custom refresh rate for templates.
void SetEngineId(const std::string &engineId)
Sets the engine ID.
int GetTemplateBatchSize() const
Gets the number of templates to be requested in each batch during GetTemplates.
void SetSessionId(const std::string &sessionId)
Sets the engine session ID, used for correlation of logging/telemetry.
void SetAuthDelegate(const std::shared_ptr< AuthDelegate > &authDelegate)
Set the Engine Auth Delegate.
const std::string & GetUnderlyingApplicationId() const
Gets the Underlying Application ID.
void SetAllowCloudServiceOnly(bool allowCloudServiceOnly)
Sets whether or not only cloud service is allowed.
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...
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 ...
const std::string & GetEngineId() const
Gets the engine ID.
void SetUnderlyingApplicationId(const std::string &underlyingApplicationId)
Sets the Underlying Application ID.
std::shared_ptr< AuthDelegate > GetAuthDelegate() const
Get the Engine Auth Delegate.
std::vector< std::string > GetRmsCapabilities() const
The the full set of client capabilities supported when fetching usage rights from RMS.
const std::string & GetLocale() const
Gets the locale in which engine data will be written.
void SetCloudEndpointBaseUrl(const std::string &cloudEndpointBaseUrl)
Sets the cloud endpoint base URL for custom cloud.
Manages protection-related actions related to a specific identity.
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.
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 bool LoadUserCert(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::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 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 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 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.
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.
Settings used to create a ProtectionHandler to protect new content.
A file Containing the common types used by the upe, file and protection modules.
FeatureId
Defines new features by name.
Cloud
Azure cloud identifier.
@ Unknown
Cloud not specified or URL not recognized as an Azure cloud.
DataBoundary
Diagnostic region identifier.
@ Default
Region is not specified.
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.