離線發佈

離線發佈可讓用戶端在建立與 Rights Management 服務的初始連線之後,為新受保護的內容產生 發佈授權 ,而不需要進行服務呼叫。 這對於需要在離線模式下運行或想要避免進行服務呼叫的應用程式很有用。

需求

離線發佈功能有以下要求:

  • 這是 MIP SDK 的支援版本。
  • 已獲得 Microsoft Purview 資訊保護授權的使用者。 授權要求
  • 應用程式需要網際網路連線來初始化並快取資料以供離線使用。

不支援

下列專案不支援作為離線發佈功能的一部分:

  • 不支援 Active Directory Rights Management Services (AD RMS)。
  • 雙金鑰加密 (DKE):DKE 功能必須進行服務呼叫,才能在發佈時擷取公開金鑰。

搭配 Protection SDK 使用離線發佈

離線發佈需要三個步驟,才能讓應用程式在不呼叫服務的情況下發佈:

  1. 在設定檔設定上啟用離線發佈設定 (適用於適用的 SDK)。
  2. 設定範本重新整理頻率。 此 API 會設定快取範本的有效期間。
  3. 呼叫範本擷取 API 以填入快取 (GetTemplatesAsync()GetTemplates())。

使用 File 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();