Microsoft Information Protection SDK - 保護 SDK エンジンの概念

実装: 保護エンジンを追加する

File SDK では、 mip::ProtectionProfile クラスはすべての SDK 操作のルート クラスです。 プロファイルを作成したら、エンジンをプロファイルに追加できます。

次の例では、1 つの認証されたユーザーに対して 1 つのエンジンを使用する方法を示します。

実装: 保護エンジンの設定を作成する

プロファイルと同様に、エンジンには設定オブジェクト mip::ProtectionEngine::Settingsも必要です。 このオブジェクトには、一意のエンジン識別子、トークンの取得に使用される mip::AuthDelegate 、デバッグまたはテレメトリに使用できるカスタマイズ可能なクライアント データ、および必要に応じてロケールが格納されます。

次のコードでは、engineSettings というProtectionEngine::Settings オブジェクトを作成します。

ProtectionEngine::Settings engineSettings("UniqueID", authDelegate, "");

Note

この方法で保護設定オブジェクトを作成する場合は、SetCloud()を使用して、SetIdentity()またはターゲット クラウド環境を使用して、ProtectionEngine::Settings オブジェクトの ID も設定します。

ベスト プラクティスとして、最初のパラメーター id を使用して、関連付けられているユーザーを識別するか、 mip::Identity オブジェクトを使用します。 mip::Identityを使用して設定を初期化するには:

ProtectionEngine::Settings engineSettings(mip::Identity("Bob@Contoso.com"), authDelegate, "");

このように engineSettings を作成する場合は、次を使用して一意の engineId も明示的に設定します。

engineSettings.SetEngineId(engineId);

ユーザーがサービスまたはアプリケーションを使用するたびにエンジンが一貫して読み込まれるようにするには、ユーザー 名または電子メール を使用します。

実装: 保護エンジンを追加する

エンジンを追加するには、プロファイルの読み込みに使用している Future/Promise パターンを使用します。 mip::ProtectionProfileの約束を作成する代わりに、mip::ProtectionEngineを使用します。


  //auto profile will be std::shared_ptr<mip::ProtectionProfile>
  auto profile = profileFuture.get();

  //Create the ProtectionEngine::Settings object
  ProtectionEngine::Settings engineSettings("UniqueID", authDelegate, "");

  //Create a promise for std::shared_ptr<mip::ProtectionEngine>
  auto enginePromise = std::make_shared<std::promise<std::shared_ptr<mip::ProtectionEngine>>>();

  //Instantiate the future from the promise
  auto engineFuture = enginePromise->get_future();

  //Add the engine using AddEngineAsync, passing in the engine settings and the promise
  profile->AddEngineAsync(engineSettings, enginePromise);

  //get the future value and store in std::shared_ptr<mip::ProtectionEngine>
  auto engine = engineFuture.get();

このコードは、認証されたユーザーのエンジンをプロファイルに追加します。

実装: テンプレートを一覧表示する

エンジンを追加した後は、 engine->GetTemplatesAsync()を呼び出すことによって、認証されたユーザーが使用できるすべての秘密度テンプレートを一覧表示できます。

GetTemplatesAsync() は、テンプレート記述子のリストをフェッチします。 このメソッドは、結果を std::shared_ptr<mip::TemplateDescriptor> のベクターに格納します。

実装: ListSensitivityTemplates()

auto loadPromise = std::make_shared<std::promise<std::vector<std::shared_ptr<mip::TemplateDescriptor>>>>();
auto loadFuture = loadPromise->get_future();
engine->GetTemplatesAsync(engineObserver, loadPromise);
auto templates = loadFuture.get();

実装: テンプレート ID を印刷する

//Iterate through all template IDs in the vector
for (const auto& temp : templates) {
  cout << "Template:" << "\n\tId: " << temp->GetId() << endl;
}

名前を印刷すると、アプリケーションがサービスからポリシーを正常にプルし、テンプレートを取得したことが示されます。 テンプレートを適用するには、テンプレート識別子が必要です。

ComputeActions() の結果を確認することでのみ、Policy SDK を介してテンプレートをラベルに対応付けることができます。

次のステップ

プロファイルを読み込み、エンジンを追加し、テンプレートを用意したら、ハンドラーを追加して、ファイルのテンプレートの読み取り、書き込み、または削除を開始できます。 保護ハンドラーの概念を参照してください。