MIP Protection SDK mip::ProtectionHandler 에서 보호된 스트림 및 버퍼를 암호화 및 암호 해독하고, 액세스 검사를 수행하고, 게시 라이선스를 획득하고, 보호된 정보에서 특성을 가져오는 함수를 노출합니다.
요구 사항
특정 파일과 작업하기 위해서는 ProtectionHandler이 필요합니다.
-
mip::MipContext -
mip::ProtectionProfile -
mip::ProtectionEngine가ProtectionProfile에 추가됨 - 상속되는 클래스입니다.
mip::ProtectionHandler::Observer -
mip::ProtectionDescriptor또는 게시 라이선스
보호 처리기 만들기
mip::ProtectionHandler 개체는 보호 또는 소비 작업을 위해 생성됩니다. 처리기는 시나리오에 따라 네 가지 함수 중 하나를 사용하여 생성됩니다.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
이러한 함수들은 mip::ProtectionHandler::PublishingSettings 또는 mip::ProtectionHandler::ConsumptionSettings 개체를 허용합니다.
게시 처리기 만들기
게시 처리기를 만들려면 다음 세 단계가 필요합니다.
-
mip::ProtectionDescriptor개체를 만듭니다. -
mip::ProtectionDescriptor를 사용하여mip::ProtectionHandler::PublishingSettings을 인스턴스화합니다. -
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync()을 호출하면서PublishingSettings개체, 옵서버 및 프로미스를 전달합니다.
설명으로부터 생성
아직 보호되지 않은 콘텐츠를 보호하거나 복호화된 콘텐츠에 새 보호를 적용해야 하는 경우에는 mip::ProtectionDescriptor을(를) 생성해야 합니다. 생성되면 mip::ProtectionHandler::PublishingSettings() 개체를 인스턴스화하는 데 사용됩니다. 결과는 mip::ProtectionHandler::Observer를 통해 반환됩니다.
// 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;
개체를 ProtectionHandler 성공적으로 만든 후 보호 작업(암호화/암호 해독)을 수행할 수 있습니다.
게시 라이선스는 처리기에서 가져와 암호화된 콘텐츠와 함께 저장해야 합니다. 게시 라이선스는 다음을 호출하여 가져올 수 있습니다. handler->GetSerializedPublishingLicense();
해당 게시 라이선스가 없는 보호된 콘텐츠는 암호 해독할 수 없습니다.
소비 처리기 만들기
소비 처리기를 만들려면 다음 세 단계가 필요합니다.
- 보호된 콘텐츠에서 직렬화된 게시 라이선스
std::vector<uint8_t>를 추출합니다. - 직렬화된 게시 라이선스를 사용하여
mip::ProtectionHandler::ConsumptionSettings를 인스턴스화합니다. - 호출할 때
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync()개체, 관찰자, 그리고 프라미스를 전달하여ConsumptionSettings을 수행합니다.
이 예제에서는 게시 라이선스가 이미 일부 원본에서 읽고 저장되어 있다고 std::vector<uint8_t> serializedPublishingLicense가정합니다.
//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();