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::PolicyProfile
oluşturacağız. nesnesini oluşturmak mip::PolicyProfile
için ve mip::MipContext
gerekirmip::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
: ProfilObserver
uygulamasının paylaşılan işaretçisi (,ProtectionProfile
veFileProfile
iç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ı 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::OnLoadSuccess
uygulamamıza mip::Profile::Observer::OnLoadSuccess
bildirilir. Bu durumda elde edilen nesne, bağlamın yanı sıra, mip::Profile
gö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ı profile
nesnede depoladık.
Sonraki Adımlar
Profil eklendiğine göre, bir sonraki adım profile bir altyapı eklemektir.