Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Herhangi bir Policy SDK işlemi gerçekleştirmeden önce mip::Profile yükleyin.
Aşağıdaki iki örnek, durum depolaması veya yalnızca bellek içi depolama için yerel depolama kullanarak profileSettings nesnesinin nasıl oluşturulacağını gösterir.
Profil yükleme
ProfileObserver ile MipContext’i tanımladıktan sonra, mip::PolicyProfile örneğini oluşturmak için bunları kullanın.
mip::PolicyProfile nesnesini oluşturmak için mip::PolicyProfile::Settings ve mip::MipContext gereklidir.
Profil::Ayarlar parametreleri
Oluşturucu PolicyProfile::Settings aşağıdaki 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: Durumun nasıl depolanacağını tanımlar: Bellekte, diskte veya diskte ve şifrelenmiş olarak. Daha fazla ayrıntı için bkz . Önbellek depolama kavramları. -
std::shared_ptr<mip::PolicyProfile::Observer> observer:Observerprofili uygulamasının paylaşılan işaretçisi (PolicyProfile,ProtectionProfileveFileProfileiçinde).
Aşağıdaki iki örnek, durum depolaması veya yalnızca bellek içi depolama için yerel depolama kullanarak profileSettings nesnesinin nasıl oluşturulacağını gösterir.
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 modeli kullanarak Profile yükleyin.
auto profilePromise = std::make_shared<std::promise<std::shared_ptr<Profile>>>();
auto profileFuture = profilePromise->get_future();
Profile::LoadAsync(profileSettings, profilePromise);
Uygulama bir profili başarıyla yüklerse, ProfileObserver::OnLoadSuccess, mip::Profile::Observer::OnLoadSuccess uygulamasına bildirilir. SDK, sonuç nesnesini (bu örnekte bir mip::Profile) ve bağlamı gözlemci işlevine parametre olarak geçirir.
Bağlam, zaman uyumsuz işlemi işlemek için oluşturulan std::promise için bir işaretçidir. İşlev, sözün değerini ilk parametre olarak geçirilen Profile nesnesine ayarlar. Ana işlev Future.get() kullandığında, sonucu çağıran iş parçacığında yeni bir nesne içinde depolayabilir.
//get the future value and store in profile.
auto profile = profileFuture.get();
Bir araya getirmek
Gözlemcileri ve kimlik doğrulama temsilcisini uyguladıktan sonra bir profili tam olarak yükleyebilirsiniz. Aşağıdaki kod parçacığı, tüm gerekli üst bilgilerin zaten dahil olduğunu varsayar.
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();
}
Kod profili yükler ve adlı profilenesnede depolar.
Sonraki Adımlar
Profil eklendiğine göre, bir sonraki adım profile bir motor eklemektir.