Microsoft Information Protection SDK - 정책 SDK 엔진 개념

mip::PolicyEngine 는 프로필 로드를 제외하고 정책 SDK가 수행할 수 있는 모든 작업을 구현합니다.

구현: 정책 엔진 추가

구현: 정책 엔진 설정 만들기

프로필과 마찬가지로 엔진에는 설정 개체 mip::PolicyEngine::Settings도 필요합니다. 이 개체는 고유한 엔진 식별자, 구현 개체 mip::AuthDelegate , 디버깅 또는 원격 분석을 위한 사용자 지정 가능한 클라이언트 데이터 및 필요에 따라 로캘을 저장합니다.

다음 예제에서는 애플리케이션 사용자의 ID를 사용하여 engineSettings라는 개체를 만듭니다PolicyEngine::Settings.

PolicyEngine::Settings engineSettings(
  mip::Identity(mUsername), // mip::Identity.  
  authDelegateImpl,         // Auth delegate object
  "",                       // Client data. Customizable by developer, stored with engine.
  "en-US",                  // Locale.
  false);                   // Load sensitive information types for driving classification.

이러한 방식으로 engineSettings를 만들 때 고유한 engineId도 명시적으로 설정합니다.

engineSettings.SetEngineId(engineId);

사용자 이름 또는 전자 메일을 사용하면 사용자가 서비스 또는 애플리케이션을 사용할 때마다 동일한 엔진이 로드됩니다.

사용자 지정 엔진 ID를 제공하는 것도 유효합니다.

PolicyEngine::Settings engineSettings(
  "myEngineId",     // String
  authDelegateImpl, // Auth delegate object
  "",               // Client data in string format. Customizable by developer, stored with engine.
  "en-US",          // Locale. Default is en-US
  false);           // Load sensitive information types for driving classification. Default is false.

가장 좋은 방법은 엔진을 연결된 사용자(사용자 계정 이름)에 연결하는 첫 번째 매개 변수 ID를 사용하는 것입니다.

구현: 정책 엔진 추가

엔진을 추가하려면 프로필을 로드하는 데 사용되는 미래/약속 패턴으로 돌아갑니다. mip::Profile에 대한 Promise를 생성하는 대신 mip::PolicyEngine를 사용하세요.


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

  // Create the delegate
  auto authDelegateImpl = std::make_shared<sample::auth::AuthDelegateImpl>(appInfo, userName, password);


  // Create the PolicyEngine::Settings object.
  PolicyEngine::Settings engineSettings("UniqueID", authDelegateImpl, "");

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

  // 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::PolicyEngine>.
  auto engine = engineFuture.get();

이 코드는 인증된 사용자에 대한 엔진을 프로필에 추가합니다.

구현: 민감도 레이블 나열

추가된 엔진을 사용하여 인증된 사용자가 사용할 수 있는 모든 민감도 레이블을 호출 engine->ListSensitivityLabels()하여 나열할 수 있습니다.

ListSensitivityLabels() 는 서비스에서 특정 사용자에 대한 레이블 및 해당 레이블의 특성 목록을 가져옵니다. 결과는 벡터에 std::shared_ptr<mip::Label>저장됩니다.

구현: ListSensitivityLabels()

std::vector<shared_ptr<mip::Label>> labels = engine->ListSensitivityLabels();

구현: 레이블 인쇄

//Iterate through all labels in the vector
for (const auto& label : labels) {
  //print the label name
  cout << label->GetName() << endl;
  //Iterate through all child labels
  for (const auto& child : label->GetChildren()) {
    //Print the label with some formatting
    cout << "->  " << child->GetName() << endl;
  }
}

이름을 출력해 보면 애플리케이션이 서비스에서 정책을 성공적으로 가져오고 레이블도 받아왔다는 것을 확인할 수 있습니다. 레이블을 적용하려면 레이블 식별자가 필요합니다. 레이블 ID를 반환하도록 이전 코드 조각을 수정합니다.

for (const auto& label : labels) {
  //Print label name and GUID
  cout << label->GetName() << " : " << label->GetId() << endl;

  //Print child label name and GUID
  for (const auto& child : label->GetChildren()) {
    cout << "->  " << child->GetName() <<  " : " << child->GetId() << endl;
  }
}

반환된 ListSensitivityLabels() 컬렉션을 mip::Label 사용하여 사용자가 사용할 수 있는 모든 레이블을 표시한 다음, 선택하면 ID를 사용하여 파일에 레이블을 적용할 수 있습니다.

다음 단계