脱机发布允许客户端在与权限管理服务建立初始连接后,在不调用服务的情况下为新受保护的内容生成 发布许可证 。 这对于需要在脱机模式下运行或想要避免进行服务调用的应用程序非常有用。
要求
脱机发布功能具有以下要求:
- 支持的 MIP SDK 版本。
- 被许可使用Microsoft Purview 信息保护的用户。 许可要求
- 应用程序脱机初始化和缓存数据的 Internet 连接。
不支持
以下项目不支持用于脱机发布功能:
- 不支持 Active Directory Rights Management Services (AD RMS)。
- 双密钥加密(DKE):DKE 功能必须进行服务调用才能在发布时提取公钥。
使用保护 SDK 实现脱机发布
脱机发布需要执行三个步骤,使应用程序无需调用服务即可发布:
- 在配置文件设置(适用于适用的 SDK)上启用脱机发布设置。
- 设置模板刷新率。 此 API 设置缓存模板的有效期。
- 调用模板检索 API 以填充缓存(
GetTemplatesAsync()或GetTemplates())。
利用文件 SDK 进行脱机发布
默认情况下,文件 SDK 使用脱机发布,无需其他设置或配置。
缓存行为
在刷新周期过期或调用 GetTemplatesAsync() 或GetTemplates() 之前,应用程序不会为了获取模板而联系服务。 如果应用程序处于脱机状态并且缓存已过期,发布将失败。 刷新间隔应在最终用户的脱机使用与确保模板新鲜之间取得平衡。 对于大多数应用程序来说,24 小时或更少是理想的。
例子
以下代码片段取自这些示例应用程序:
完成以下步骤后,如果模板缓存未过期,则创建发布许可证将发生,而无需进行服务调用。
C++示例
配置 ProtectionProfileSettings (C++)
// Initialize ProtectionProfileSettings using MipContext
ProtectionProfile::Settings profileSettings(mMipContext,
mip::CacheStorageType::OnDiskEncrypted,
::make_shared<sample::consent::ConsentDelegateImpl>(),
std::make_shared<ProtectionProfileObserverImpl>()
);
// Enable Offline Publishing
profileSettings.SetOfflinePublishing(true);
设置模板刷新期(C++)
// Set the template refresh interval
engineSettings.SetTemplateRefreshArgs(std::chrono::hours(24));
提取模板以初始化缓存(C++)
auto loadPromise = std::make_shared<std::promise<vector<shared_ptr<mip::TemplateDescriptor>>>>();
std::future<vector<shared_ptr<mip::TemplateDescriptor>>> loadFuture = loadPromise->get_future();
mEngine->GetTemplatesAsync(engineObserver, loadPromise);
auto templates = loadFuture.get();
.NET 示例
配置 ProtectionProfileSettings (.NET)
// Initialize ProtectionProfileSettings
var profileSettings = new ProtectionProfileSettings(mipContext,
CacheStorageType.OnDisk,
new ConsentDelegateImplementation());
// Enable Offline Publishing
profileSettings.OfflinePublishing = true;
设置模板刷新期 (.NET)
// Initialize ProtectionEngineSettings
var engineSettings = new ProtectionEngineSettings(identity.Email, authDelegate, "", "")
{
Identity = identity
};
// Set the template refresh interval
engineSettings.TemplateRefreshRate = new TimeSpan(24, 0, 0);
var engine = profile.AddEngine(engineSettings);
提取模板以初始化缓存 (.NET)
List<TemplateDescriptor> templates = engine.GetTemplates();
Java 示例
配置 ProtectionProfileSettings (Java)
ProtectionProfileSettings profileSettings = new ProtectionProfileSettings();
profileSettings.setMipContext(mipContext);
profileSettings.setCacheStorageType(CacheStorageType.ON_DISK);
profileSettings.setConsentDelegate(new ConsentDelegateImplementation());
// Enable Offline Publishing
profileSettings.setOfflinePublishing(true);
设置模板刷新期 (Java)
ProtectionEngineSettings engineSettings = new ProtectionEngineSettings(identity.getEmail(), authDelegate, "", "");
engineSettings.setIdentity(identity);
// Set the template refresh interval in hours
engineSettings.setTemplateRefreshRate(Duration.ofHours(24));
提取模板以初始化缓存 (Java)
List<TemplateDescriptor> templates = engine.getTemplates();