Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
En el SDK de protección de MIP, mip::ProtectionHandler expone las funciones para cifrar y descifrar secuencias y búferes protegidos, realizar comprobaciones de acceso, obtener la licencia de publicación y obtener atributos de la información protegida.
Requisitos
La creación de un ProtectionHandler para trabajar con un archivo específico requiere lo siguiente:
- Una operación
mip::MipContext - Una operación
mip::ProtectionProfile - Un
mip::ProtectionEngineañadido aProtectionProfile - Una clase que herede
mip::ProtectionHandler::Observer - Un
mip::ProtectionDescriptoro licencia de publicación
Creación de un controlador de protección
mip::ProtectionHandler los objetos se construyen para operaciones de protección o consumo . El controlador se crea mediante una de las cuatro funciones, en función del escenario.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
Estas funciones aceptan un mip::ProtectionHandler::PublishingSettings objeto o mip::ProtectionHandler::ConsumptionSettings .
Creación de un controlador de publicación
La creación de un controlador de publicación requiere tres pasos:
- Cree un objeto
mip::ProtectionDescriptor. - Usa el
mip::ProtectionDescriptorpara crear una instancia demip::ProtectionHandler::PublishingSettings. - Llamar a
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync()incorporando el objetoPublishingSettings, el observador y la promesa.
Creación a partir del descriptor
Si se está protegiendo contenido que aún no ha sido protegido, o al aplicar una nueva protección al contenido, lo que implica que se ha descifrado, se debe construir un elemento mip::ProtectionDescriptor. Una vez construido, se usa para crear instancias del mip::ProtectionHandler::PublishingSettings() objeto . El resultado se devuelve a través de 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;
Después de crear correctamente el ProtectionHandler objeto, se pueden realizar operaciones de protección (cifrar o descifrar). La licencia de publicación debe capturarse desde el controlador y almacenarse con el contenido cifrado. La licencia de publicación se puede obtener mediante una llamada a: handler->GetSerializedPublishingLicense();
No se puede descifrar el contenido protegido sin la licencia de publicación correspondiente.
Creación del controlador de consumo
La creación de un controlador de publicación requiere tres pasos:
- Extraiga una licencia de publicación serializada como
std::vector<uint8_t>del contenido protegido. - Utilice la licencia de publicación serializada para crear una instancia de
mip::ProtectionHandler::ConsumptionSettings. - Llamar a
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync()incorporando el objetoConsumptionSettings, el observador y la promesa.
En este ejemplo se supone que la licencia de publicación ya se ha leído de algún origen y se almacena en 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();