Aracılığıyla paylaş


Microsoft Information Protection SDK - İlke SDK'sı profil kavramları

herhangi bir İlke SDK'sı mip::Profile işleminin gerçekleştirilebilmesi için önce öğesinin yüklenmesi gerekir.

Aşağıdaki iki örnek, hem durum depolaması hem de yalnızca bellek içi depolama için yerel depolama kullanarak profil Ayarlar nesnesinin nasıl oluşturulacağını göstermektedir.

Profil Yükleme

ve ProfileObserver tanımlandığına göreMipContext, bunları kullanarak örneği mip::PolicyProfileoluşturacağız. nesnesini oluşturmak mip::PolicyProfile için ve mip::MipContextgerekirmip::PolicyProfile::Settings.

Profil::Ayarlar Parametreleri

PolicyProfile::Settings Oluşturucu aşağıda listelenen dört parametreyi kabul eder:

  • const std::shared_ptr<MipContext>mip::MipContext: Uygulama bilgilerini, durum yolunu vb. depolamak için başlatılan nesne.
  • mip::CacheStorageType: Durumu depolamayı tanımlar: Bellekte, diskte veya diskte ve şifrelenmiş. Daha fazla ayrıntı için bkz . Önbellek depolama kavramları.
  • std::shared_ptr<mip::PolicyProfile::Observer> observer: Profil Observer uygulamasının paylaşılan işaretçisi (, ProtectionProfileve FileProfileiçindePolicyProfile).

Aşağıdaki iki örnek, hem durum depolaması hem de yalnızca bellek içi depolama için yerel depolama kullanarak profil Ayarlar nesnesinin nasıl oluşturulacağını göstermektedir.

Durumu yalnızca bellekte depolama

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

Disk üzerindeki depolama yolundan profil ayarlarını okuma/yazma

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

Ardından, promise/future desenini kullanarak dosyasını Profileyükleyin.

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

Bir profil başarıyla yüklenirse, ProfileObserver::OnLoadSuccessuygulamamıza mip::Profile::Observer::OnLoadSuccess bildirilir. Bu durumda elde edilen nesne, bağlamın yanı sıra, mip::Profilegözlemci işlevine parametre olarak geçirilir.

Bağlam, zaman uyumsuz işlemi işlemek için oluşturduğumuz işaretçidirstd::promise. İşlev, ilk parametre için geçirilen Profile nesnesine promise değerini ayarlar. Main işlevi kullandığında Future.get()sonuç, çağıran iş parçacığındaki yeni bir nesnede depolanabilir.

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

Bir Araya Getirmek

Gözlemcileri ve kimlik doğrulama temsilcisini tam olarak uyguladıktan sonra artık bir profili tam olarak yüklemek mümkündür. Aşağıdaki kod alıntısı, tüm gerekli üst bilgilerin zaten dahil olduğunu varsayar.

int main()
{
    const string userName = "MyTestUser@consoto.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();
}

Sonuç olarak, profili başarıyla yükledik ve adlı profilenesnede depoladık.

Sonraki Adımlar

Profil eklendiğine göre, bir sonraki adım profile bir altyapı eklemektir.

İlke altyapısı kavramları