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.
Aşağıdaki iki örnek, yalnızca durum depolaması veya bellek için yerel depolama kullanarak profileSettings nesnesinin nasıl oluşturulacağını gösterir.
Profil yükleme
Artık ProtectionProfileObserverImpl tanımlandığına göre, mip::ProtectionProfile örneğini oluşturmak için onu kullanın.
mip::ProtectionProfile nesnesini oluşturmak için mip::ProtectionProfile::Settings gerekir.
ProtectionProfile::Settings parametreleri
-
std::shared_ptr<MipContext>: Uygulamamip::MipContextbilgilerini, durum yolunu ve diğer ayarları depolamak için başlatılan nesne. -
mip::CacheStorageType: Durumun nasıl depolanacağını tanımlar: bellekte, diskte veya diskte şifreli olarak. -
std::shared_ptr<mip::ConsentDelegate>:mip::ConsentDelegatesınıfının paylaşılan işaretçisi. -
std::shared_ptr<mip::ProtectionProfile::Observer> observer: ProfilObserveruygulamasına yönelik paylaşılan işaretçi (PolicyProfile,ProtectionProfile, veFileProfileiçinde).
Aşağıdaki iki örnek, yalnızca durum depolaması veya bellek 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>(appInfo,
"mip_data",
mip::LogLevel::Trace,
false, mip::CacheStorageType::OnDisk);
std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);
ProtectionProfile::Settings profileSettings(
mMipContext, // mipContext object
mip::CacheStorageType::InMemory, // use in memory storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<ProtectionProfileObserverImpl>()); // 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>(appInfo,
"mip_data",
mip::LogLevel::Trace,
false, mip::CacheStorageType::OnDisk);
std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);
ProtectionProfile::Settings profileSettings(
mMipContext, // mipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<ProtectionProfileObserverImpl>()); // new protection profile
Ardından, promise/future kalıbını kullanarak ProtectionProfile yükleyin.
auto profilePromise = std::make_shared<std::promise<std::shared_ptr<ProtectionProfile>>>();
auto profileFuture = profilePromise->get_future();
ProtectionProfile::LoadAsync(profileSettings, profilePromise);
Profil başarıyla yüklenirse SDK, ProtectionProfileObserverImpl::OnLoadSuccess uygulaması olan mip::ProtectionProfile::Observer::OnLoadSuccess öğesini çağırır. SDK, sonuçta elde edilen nesneyi veya özel durum işaretçisini ve bağlamı işleve parametre olarak geçirir. Bağlam, zaman uyumsuz işlemi işlemek için oluşturulan std::promise öğesine yönelik bir işaretçidir. İşlev, promise'in değerini ProtectionProfile nesnesi (bağlam) olarak ayarlar. Main işlevi kullandığında Future.get(), sonucu yeni bir nesnede depolayabilirsiniz.
//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>(appInfo,
"mip_data",
mip::LogLevel::Trace,
false, mip::CacheStorageType::OnDisk);
std::shared_ptr<mip::MipContext> mMipContext = mip::MipContext::Create(mipConfiguration);
ProtectionProfile::Settings profileSettings(
mMipContext, // mipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<ProfileObserver>()); // new protection profile observer
auto profilePromise = std::make_shared<promise<shared_ptr<ProtectionProfile>>>();
auto profileFuture = profilePromise->get_future();
ProtectionProfile::LoadAsync(profileSettings, profilePromise);
auto profile = profileFuture.get();
}
Kod profili yükler ve adlı profilenesnede depolar.
Sonraki Adımlar
Profili yüklediğinize göre, sonraki adım profile bir motor eklemektir.
- GitHub'da MIP Koruma SDK'sı C++ örneğini keşfedin.