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 şunlar gerekir:

  • Bir mip::MipContext
  • Bir mip::ProtectionProfile
  • mip::ProtectionEngine ProtectionProfile öğesine eklendi
  • Devralan bir sınıf mip::ProtectionHandler::Observer
  • Bir mip::ProtectionDescriptor veya yayımlama lisansı

Koruma işleyicisi oluşturma

mip::ProtectionHandler nesneleri 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 eder.

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. mip::ProtectionDescriptor kullanarak mip::ProtectionHandler::PublishingSettings örneğini oluşturun.
  3. mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync() nesnesini, gözlemciyi ve promise'i geçerek PublishingSettings çağrısını yapın.

Tanımlayıcıdan oluşturma

Henüz korunmamış içeriği korumak veya şifresi çözülen içeriğe yeni koruma uygulamak için bir mip::ProtectionDescriptoroluşturur. mip::ProtectionHandler::PublishingSettings() nesnesinin örneğini oluşturmak için bunu kullanın. SDK, sonucu mip::ProtectionHandler::Observer aracılığıyla döndürü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<mip::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 şifreleme ve şifre çözme için koruma işlemleri gerçekleştirebilirsiniz. İşleyiciden yayımlama lisansını getirin ve şifrelenmiş içerikle depolayın. Yayımlama lisansını almak için handler->GetSerializedPublishingLicense(); çağrısını yapın.

İlgili yayımlama lisansı olmadan korumalı içeriğin şifresini çözemezsiniz .

Tüketim işleyicisini oluşturma

Tüketim işleyicisi oluşturmak için üç adım gerekir:

  1. Korumalı içerikten std::vector<uint8_t> formatında serileştirilmiş bir yayımlama lisansı ayıklayın.
  2. mip::ProtectionHandler::ConsumptionSettings örneklenmesini sağlamak için serileştirilmiş yayımlama lisansını kullanın.
  3. mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync() nesnesini, gözlemciyi ve promise'i geçerek ConsumptionSettings çağrısını 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<mip::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();

Sonraki Adımlar