Aracılığıyla paylaş


Microsoft Information Protection SDK - Koruma işleyicisi kavramları

MIP Koruması SDK'sında, mip::ProtectionHandler korumalı akışları ve arabellekleri şifreleme ve şifrelerini çözme, erişim denetimleri gerçekleştirme, yayımlama lisansını alma ve korunan bilgilerden öznitelikleri alma işlevlerini kullanıma sunar.

Gereksinimler

Belirli bir ProtectionHandler dosyayla çalışmak için oluşturmak için şunlar gerekir:

  • mip::MipContext
  • mip::ProtectionProfile
  • öğesine mip::ProtectionEngine eklendi ProtectionProfile
  • devralan mip::ProtectionHandler::Observerbir sınıf.
  • A mip::ProtectionDescriptor veya yayımlama lisansı

Koruma işleyicisi oluşturma

mip::ProtectionHandlernesneleri koruma veya tüketim işlemleri için oluşturulur. İşleyici, senaryoya bağlı olarak dört işlevden biri kullanılarak oluşturulur.

  • mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()
  • mip::ProtectionEngine->CreateProtectionHandlerForConsumption()
  • mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()
  • mip::ProtectionEngine->CreateProtectionHandlerForPublishing()

Bu işlevler bir mip::ProtectionHandler::PublishingSettings veya mip::ProtectionHandler::ConsumptionSettings nesnesini kabul edin.

Yayımlama işleyicisi oluşturma

Yayımlama işleyicisi oluşturmak için üç adım gerekir:

  1. Bir mip::ProtectionDescriptor nesne oluşturun.
  2. örneğini mip::ProtectionHandler::PublishingSettingsbaşlatmak için öğesini mip::ProtectionDescriptor kullanın.
  3. Nesne, gözlemci ve promise'i PublishingSettings geçirme çağrısı mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync() yapın.

Tanımlayıcıdan oluşturma

Henüz korunmamış içeriği koruyorsanız veya içeriğe yeni koruma uygulandığında, bu da şifresinin çözüldüğünü gösterirse, bir mip::ProtectionDescriptor oluşturulmalıdır. Oluşturulan nesnenin örneğini mip::ProtectionHandler::PublishingSettings() oluşturmak için kullanılır. Sonuç, aracılığıyla mip::ProtectionHandler::Observerdöndürülür.

// Create the protection descriptor, passing in a templateId. 
auto descriptorBuilder = mip::ProtectionDescriptorBuilder::CreateFromTemplate(protectionOptions.templateId);
std::shared_ptr<mip::ProtectionDescriptor> descriptor = descriptorBuilder->Build();

// Define the handler promise, future, and observer.
auto handlerPromise = std::make_shared<std::promise<std::shared_ptr<ProtectionHandler>>>();
auto handlerFuture = handlerPromise->get_future();
auto handlerObserver = std::make_shared<ProtectionHandlerObserverImpl>();

// Create the PublishingSettings object using the previously-created descriptor as input.
mip::ProtectionHandler::PublishingSettings publishingSettings = mip::ProtectionHandler::PublishingSettings(descriptor);

// Create/get the publishing handler from the publishing settings, observer, and promise.
mEngine->CreateProtectionHandlerForPublishingAsync(publishingSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();
return handler;

Nesneyi başarıyla oluşturduktan ProtectionHandler sonra koruma işlemleri (şifreleme/şifre çözme) gerçekleştirilebilir. Yayımlama lisansı işleyiciden getirilmeli ve şifrelenmiş içerikle depolanmalıdır. Yayımlama lisansı şu çağrılarak getirilebilir: handler->GetSerializedPublishingLicense();

İlgili yayımlama lisansı olmayan korumalı içeriğin şifresi çözülemez.

Tüketim işleyicisini oluşturma

Yayımlama işleyicisi oluşturmak için üç adım gerekir:

  1. Korumalı içerikten olduğu gibi std::vector<uint8_t> serileştirilmiş bir yayımlama lisansı ayıklayın.
  2. örneği mip::ProtectionHandler::ConsumptionSettingsiçin serileştirilmiş yayımlama lisansını kullanın.
  3. Nesne, gözlemci ve promise'i ConsumptionSettings geçirme çağrısı mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync() yapın.

Bu örnekte, yayımlama lisansının bir kaynaktan zaten okunduğu ve içinde std::vector<uint8_t> serializedPublishingLicensedepolandığı varsayılır.

//TODO: Implement GetPublishingLicense()
//Snip implies that function reads PL from source file, database, stream, etc.
std::vector<uint8_t> serializedPublishingLicense = GetPublishingLicense(filePath);

// Define the handler promise, future, and observer.
auto handlerPromise = std::make_shared<std::promise<std::shared_ptr<ProtectionHandler>>>();
auto handlerFuture = handlerPromise->get_future();
shared_ptr<ProtectionHandlerObserverImpl> handlerObserver = std::make_shared<ProtectionHandlerObserverImpl>();

// Create the consumption settings object from the publishing license.
mip::ProtectionHandler::ConsumptionSettings consumptionSettings = mip::ProtectionHandler::ConsumptionSettings(serializedPublishingLicense);

// Create/get the publishing handler from the publishing settings, observer, and promise.
mEngine->CreateProtectionHandlerForConsumptionAsync(consumptionSettings, handlerObserver, handlerPromise);
auto handler = handlerFuture.get();