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.
Profil, MIP SDK'sı içindeki tüm işlemlerin kök sınıfıdır. Herhangi bir Dosya SDK'sı işlevini kullanmadan önce bir FileProfileoluşturun. Profile eklenen profil veya diğer nesneler, bundan sonraki tüm işlemleri gerçekleştirir.
Bir profil örneği oluşturmadan önce aşağıdaki kod önkoşullarını karşılayın:
-
MipContext:
MipContextoluşturun ve bunumip::FileProfilenesnesi tarafından erişilebilen bir nesnede depolayın. -
Onay temsilcisi:
ConsentDelegateImpluygularmip::ConsentDelegate. - Uygulama kaydı: Uygulamayı Microsoft Entra ID kaydedin ve istemci kimliğini uygulama veya yapılandırma dosyalarına sabit kodlayın.
-
Dosya profili gözlemcisi:
mip::FileProfile::Observerdevralan bir sınıf uygulayın.
Profil yükleme
ConsentDelegateImpl ve ProfileObserver öğelerini tanımladıktan sonra mip::FileProfile örneğini oluşturabilirsiniz.
mip::FileProfile nesnesinin oluşturulması, FileProfile ile ilgili tüm ayar bilgilerini depolayan mip::FileProfile::Settings ve mip::MipContext gerektirir.
FileProfile::Settings parametreleri
FileProfile::Settings Oluşturucu aşağıdaki beş parametreyi kabul eder:
-
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 şifreli olarak diskte. -
std::shared_ptr<mip::ConsentDelegate>: sınıfmip::ConsentDelegate'nin paylaşılan işaretçisi. -
std::shared_ptr<mip::FileProfile::Observer> observer: ProfilObserveruygulamasının paylaşılan işaretçisi (,PolicyProfileveProtectionProfileiçindeFileProfile).
Aşağıdaki örneklerde, durum depolaması profileSettings veya yalnızca bellek içi depolama için yerel depolama kullanarak nesnenin nasıl oluşturulacağı gösterilmektedir.
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);
FileProfile::Settings profileSettings(
mMipContext, // mipContext object
mip::CacheStorageType::InMemory, // use in memory storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<FileProfileObserverImpl>()); // new protection profile observer
Disk üzerindeki depolama yolundan profil ayarlarını okuma/yazma
Aşağıdaki kod parçacığı, ./mip_app_data öğesine tüm uygulama durumu verilerini FileProfile içinde depolamasını söyler.
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);
FileProfile::Settings profileSettings(
mMipContext, // mipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<FileProfileObserverImpl>()); // new protection profile observer
Profili yükleme
Önceki yaklaşımlardan herhangi birini kullandıktan sonra, FileProfile öğesini yüklemek için promise/future düzenini kullanın.
auto profilePromise = std::make_shared<std::promise<std::shared_ptr<FileProfile>>>();
auto profileFuture = profilePromise->get_future();
FileProfile::LoadAsync(profileSettings, profilePromise);
Uygulama bir profili başarıyla yüklerse, ProfileObserver::OnLoadSuccess, mip::FileProfile::Observer::OnLoadSuccess uygulaması çağrılı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. Bu işlev, promise’ın değerini ilk parametre olarak geçirilen FileProfile nesnesi olarak ayarlar. Main işlevi kullandığında Future.get(), sonucu yeni bir nesnede 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);
FileProfile::Settings profileSettings(
mMipContext, // MipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<ConsentDelegateImpl>(), // new consent delegate
std::make_shared<FileProfileObserverImpl>()); // new file profile observer
auto profilePromise = std::make_shared<promise<shared_ptr<FileProfile>>>();
auto profileFuture = profilePromise->get_future();
FileProfile::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.