Microsoft Information Protection SDK - 정책 SDK 프로필 개념

Policy SDK 작업을 수행하기 전에 mip::Profile를 로드하세요.

다음 두 예제에서는 상태 스토리지 또는 메모리 내 전용 로컬 스토리지를 사용하여 profileSettings 개체를 만드는 방법을 보여 줍니다.

프로필 로드

MipContext 및 ProfileObserver을 정의한 후 이를 사용하여 mip::PolicyProfile를 인스턴스화합니다. mip::PolicyProfile 객체를 생성하려면 mip::PolicyProfile::Settings 및 mip::MipContext가 필요합니다.

Profile::Settings 매개 변수

PolicyProfile::Settings 생성자는 다음 네 개의 매개 변수를 허용합니다.

  • const std::shared_ptr<MipContext>: 애플리케이션 정보, 상태 경로 등을 저장하도록 초기화된 mip::MipContext 개체입니다.
  • mip::CacheStorageType: 메모리 내, 디스크 내 또는 디스크 내 및 암호화된 상태를 저장하는 방법을 정의합니다. 자세한 내용은 캐시 스토리지 개념을 참조하세요.
  • std::shared_ptr<mip::PolicyProfile::Observer> observer: Observer, PolicyProfile 및 ProtectionProfile에서 프로필 FileProfile 구현에 대한 공유 포인터입니다.

다음 두 예제에서는 상태 스토리지 또는 메모리 내 전용 로컬 스토리지를 사용하여 profileSettings 개체를 만드는 방법을 보여 줍니다.

메모리에만 상태 저장

mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };

std::shared_ptr<mip::MipConfiguration> mipConfiguration = std::make_shared<mip::MipConfiguration>(mAppInfo,
				                                                                                  "mip_data",
                                                                                        		  mip::LogLevel::Trace,
                                                                                                  false);

std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);

PolicyProfile::Settings profileSettings(
    mMipContext,                                  // mipContext object
    mip::CacheStorageType::InMemory,              // use in memory storage
    std::make_shared<PolicyProfileObserverImpl>()); // new protection profile observer

디스크의 스토리지 경로에서 프로필 설정 읽기/쓰기

mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };

std::shared_ptr<mip::MipConfiguration> mipConfiguration = std::make_shared<mip::MipConfiguration>(mAppInfo,
			                                                                                      "mip_data",
                                                                                       			  mip::LogLevel::Trace,
                                                                                                  false);

std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);

PolicyProfile::Settings profileSettings(
    mipContext,                                    // mipContext object
    mip::CacheStorageType::OnDisk,                 // use on disk storage
    std::make_shared<PolicyProfileObserverImpl>());  // new protection profile observer

다음으로 promise/future 패턴을 사용하여 Profile을(를) 로드하십시오.

auto profilePromise = std::make_shared<std::promise<std::shared_ptr<Profile>>>();
auto profileFuture = profilePromise->get_future();
Profile::LoadAsync(profileSettings, profilePromise);

애플리케이션이 프로필을 성공적으로 로드하면 mip::Profile::Observer::OnLoadSuccess의 구현이 ProfileObserver::OnLoadSuccess알림을 받습니다. SDK는 결과 개체(이 경우) 및 컨텍스트를 mip::Profile관찰자 함수에 매개 변수로 전달합니다.

컨텍스트는 비동기 std::promise 작업을 처리하기 위해 만든 항목에 대한 포인터입니다. 이 함수는 promise 값을 첫 번째 매개 변수에 전달된 Profile 개체로 설정합니다. main 함수가 사용하는 Future.get()경우 호출 스레드의 새 개체에 결과를 저장할 수 있습니다.

//get the future value and store in profile.
auto profile = profileFuture.get();

조립하기

관찰자 및 인증 대리자를 구현한 후 프로필을 완전히 로드할 수 있습니다. 다음 코드 조각에서는 필요한 모든 헤더가 이미 포함되어 있다고 가정합니다.

int main()
{
    const string userName = "MyTestUser@contoso.com";
    const string password = "P@ssw0rd!";
    const string clientId = "MyClientId";

    mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };
 
    std::shared_ptr<mip::MipConfiguration> mipConfiguration = std::make_shared<mip::MipConfiguration>(mAppInfo,
				                                                                                       "mip_data",
                                                                                        			   mip::LogLevel::Trace,
                                                                                                       false);

    std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);

    PolicyProfile::Settings profileSettings(
        mMipContext,                                    // mipContext object
        mip::CacheStorageType::OnDisk,                 // use on disk storage
        std::make_shared<PolicyProfileObserverImpl>());  // new protection profile observer

    auto profilePromise = std::make_shared<promise<shared_ptr<PolicyProfile>>>();
    auto profileFuture = profilePromise->get_future();
    Profile::LoadAsync(profileSettings, profilePromise);
    auto profile = profileFuture.get();
}

코드는 프로필을 로드하고 호출 profile된 개체에 저장합니다.

다음 단계

이제 프로필이 추가되었으므로 다음 단계는 프로필에 엔진을 추가하는 것입니다.

정책 엔진 개념