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.
İlke SDK işlemleri gerçekleştirilebilmesi için mip::Profile öğesi mutlaka önce yüklenmelidir.
Aşağıdaki iki örnek, hem durum depolaması hem de yalnızca bellek içi depolama için yerel depolama kullanarak profileSettings nesnesinin nasıl oluşturulacağını göstermektedir.
Profil Yükleme
MipContext ve ProfileObserver tanımlandığına göre, bunları kullanarak mip::PolicyProfile örneğini oluşturacağız.
mip::PolicyProfile nesnesini oluşturmak için mip::PolicyProfile::Settings ve mip::MipContext gereklidir.
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: 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, hem durum depolaması hem de yalnızca bellek içi depolama için yerel depolama kullanarak profileSettings 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 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);
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.
Context, zaman uyumsuz işlemi işlemek için oluşturduğumuz bir işaretçidirstd::promise. İşlev, promise olarak adlandırılan değeri, ilk parametre olarak geçirilen Profile nesnesine ayarlar. Ana işlev Future.get() kullanıldığında, 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 motor eklemektir.