Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
In MIP Protection SDK mip::ProtectionHandler espone le funzioni per crittografare e decrittografare flussi e buffer protetti, eseguire controlli di accesso, ottenere la licenza di pubblicazione e ottenere attributi dalle informazioni protette.
Requisiti
La creazione di un ProtectionHandler per lavorare con un file specifico richiede:
- Un
mip::MipContext - Un
mip::ProtectionProfile - Oggetto
mip::ProtectionEngineaggiunto all'oggettoProtectionProfile - Classe che eredita
mip::ProtectionHandler::Observer - Una licenza
mip::ProtectionDescriptoro di pubblicazione
Creare un gestore di protezione
mip::ProtectionHandler gli oggetti vengono costruiti per operazioni di protezione o consumo . Il gestore viene creato usando una delle quattro funzioni, a seconda dello scenario.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
Queste funzioni accettano un mip::ProtectionHandler::PublishingSettings oggetto o mip::ProtectionHandler::ConsumptionSettings .
Creare un gestore di pubblicazione
La creazione di un gestore di pubblicazione richiede tre passaggi:
- Creare un oggetto
mip::ProtectionDescriptor. - Utilizzare
mip::ProtectionDescriptorper istanziaremip::ProtectionHandler::PublishingSettings. - Chiamare
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync(), passando l'oggettoPublishingSettings, l'osservatore e la promessa.
Crea da descrittore
Per proteggere il contenuto che non è ancora protetto o per applicare una nuova protezione al contenuto decrittografato, costruire un oggetto mip::ProtectionDescriptor. Usalo per creare un'istanza dell'oggetto mip::ProtectionHandler::PublishingSettings(). L'SDK restituisce il risultato tramite .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<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;
Dopo aver creato correttamente l'oggetto ProtectionHandler , è possibile eseguire operazioni di protezione per la crittografia e la decrittografia. Recuperare la licenza di pubblicazione dal gestore e archiviarla con il contenuto crittografato. Per recuperare la licenza di pubblicazione, chiamare handler->GetSerializedPublishingLicense();.
Senza la licenza di pubblicazione corrispondente, non è possibile decrittografare il contenuto protetto.
Creare il gestore di consumo
La creazione di un gestore di consumo richiede tre passaggi:
- Estrarre una licenza di pubblicazione serializzata come
std::vector<uint8_t>dal contenuto protetto. - Usare la licenza di pubblicazione serializzata per creare un'istanza di
mip::ProtectionHandler::ConsumptionSettings. - Chiamare
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync(), passando l'oggettoConsumptionSettings, l'osservatore e la promessa.
In questo esempio si presuppone che la licenza di pubblicazione sia già stata letta da un'origine e archiviata in 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<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();
Passaggi successivi
- Per un esempio, vedere l'esempio C++ di MIP Protection SDK in GitHub.