Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
V sadě MIP Protection SDK mip::ProtectionHandler zpřístupňuje funkce pro šifrování a dešifrování chráněných datových proudů a vyrovnávacích pamětí, provádění kontrol přístupu, získání licence pro publikování a získávání atributů z chráněných informací.
Požadavky
Vytvoření ProtectionHandler pro práci s konkrétním souborem vyžaduje:
- A
mip::MipContext - A
mip::ProtectionProfile - Přidání
mip::ProtectionEnginedoProtectionProfile - Třída, která dědí
mip::ProtectionHandler::Observer. - Licence
mip::ProtectionDescriptornebo licence k publikování
Vytvořte obslužnou rutinu ochrany
mip::ProtectionHandler objekty se vytvářejí pro operace ochrany nebo spotřeby . Obslužná rutina se vytvoří pomocí jedné ze čtyř funkcí v závislosti na scénáři.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
Tyto funkce přijímají objekt mip::ProtectionHandler::PublishingSettings nebo objekt mip::ProtectionHandler::ConsumptionSettings .
Vytvořte obslužnou rutinu publikování
Vytvoření obslužné rutiny publikování vyžaduje tři kroky:
- Vytvořte objekt
mip::ProtectionDescriptor. - Použijte
mip::ProtectionDescriptork vytvoření instancemip::ProtectionHandler::PublishingSettings. - Zavolejte
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync()a předejte objektPublishingSettings, pozorovatele a promis.
Vytvoření z popisovače
Pokud chráníte obsah, který ještě není chráněný, nebo při aplikaci nové ochrany na obsah, což naznačuje, že byl dešifrován, je nutné sestavit mip::ProtectionDescriptor. Po vytvoření se použije k vytvoření instance objektu mip::ProtectionHandler::PublishingSettings() . Výsledek se vrátí přes 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;
Po úspěšném vytvoření objektu ProtectionHandler je možné provádět operace ochrany (šifrování/dešifrování).
Licence pro publikování musí být načtena z obslužné rutiny a uložena se šifrovaným obsahem. Licence pro publikování lze získat voláním funkce: handler->GetSerializedPublishingLicense();
Chráněný obsah bez odpovídající licence publikování nelze dešifrovat.
Vytvořte obslužnou rutinu zpracování.
Vytvoření obslužné rutiny pro spotřebu vyžaduje tři kroky:
- Extrahujte serializovanou licenci publikování jako
std::vector<uint8_t>z chráněného obsahu. - K vytvoření instance
mip::ProtectionHandler::ConsumptionSettingspoužijte serializovanou publikační licenci. - Zavolejte
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync()a předejte objektConsumptionSettings, pozorovatele a promisu.
Tento příklad předpokládá, že licence publikování již byla načtena z nějakého zdroje a uložena v 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();