Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
No SDK de Proteção MIP, o mip::ProtectionHandler expõe as funções para criptografar e descriptografar fluxos e buffers protegidos, executar verificações de acesso, obter a licença de publicação e obter atributos das informações protegidas.
Requisitos
Criar um ProtectionHandler para trabalhar com um arquivo específico requer:
- Um
mip::MipContext - Um
mip::ProtectionProfile - Um
mip::ProtectionEngineadicionado aoProtectionProfile - Uma classe que herde
mip::ProtectionHandler::Observer - Uma
mip::ProtectionDescriptorou licença de publicação
Criar um manipulador de proteção
mip::ProtectionHandler os objetos são construídos para operações de proteção ou consumo . O manipulador é criado usando uma das quatro funções, dependendo do cenário.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
Essas funções aceitam um mip::ProtectionHandler::PublishingSettings ou mip::ProtectionHandler::ConsumptionSettings objeto.
Criar um manipulador de publicação
A criação de um manipulador de publicação requer três etapas:
- Crie um objeto
mip::ProtectionDescriptor. - Use o
mip::ProtectionDescriptorpara criar uma instância paramip::ProtectionHandler::PublishingSettings. - Chame
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync()passando no objetoPublishingSettings, no observador e na promessa.
Criar no descritor
Para proteger o conteúdo que ainda não está protegido ou aplicar uma nova proteção ao conteúdo descriptografado, construa um mip::ProtectionDescriptor. Use-o para instanciar o mip::ProtectionHandler::PublishingSettings() objeto. O SDK retorna o resultado por meio do 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;
Depois de criar o ProtectionHandler objeto com êxito, você pode executar operações de proteção para criptografia e descriptografia. Busque a licença de publicação do manipulador e armazene-a com o conteúdo criptografado. Para buscar a licença de publicação, chame handler->GetSerializedPublishingLicense();.
Sem a licença de publicação correspondente, você não pode descriptografar o conteúdo protegido.
Criar o manipulador de consumo
A criação de um manipulador de consumo requer três etapas:
- Extraia do conteúdo protegido uma licença de publicação serializada como
std::vector<uint8_t>. - Use a licença de publicação serializada para instanciar
mip::ProtectionHandler::ConsumptionSettings. - Chame
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync()passando no objetoConsumptionSettings, no observador e na promessa.
Este exemplo pressupõe que a licença de publicação já foi lida de alguma origem e armazenada em 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();
Próximas Etapas
- Para obter um exemplo, consulte o exemplo do SDK do MIP Protection C++ em GitHub.