Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Dalam SDK Perlindungan MIP, mip::ProtectionHandler mengekspos fungsi untuk mengenkripsi dan mendekripsi aliran dan buffer yang dilindungi, melakukan pemeriksaan akses, mendapatkan lisensi penerbitan, dan mendapatkan atribut dari informasi yang dilindungi.
Persyaratan
Membuat ProtectionHandler untuk bekerja dengan file tertentu memerlukan:
- Sebuah
mip::MipContext - Sebuah
mip::ProtectionProfile - Ditambahkan
mip::ProtectionEnginekeProtectionProfile - Kelas yang mewarisi
mip::ProtectionHandler::Observer. - Lisensi
mip::ProtectionDescriptoratau penerbitan
Membuat pengelola perlindungan
mip::ProtectionHandler objek dibangun untuk operasi perlindungan atau konsumsi . Handler dibuat menggunakan salah satu dari empat fungsi, tergantung pada skenarionya.
mip::ProtectionEngine->CreateProtectionHandlerForConsumptionAsync()mip::ProtectionEngine->CreateProtectionHandlerForConsumption()mip::ProtectionEngine->CreateProtectionHandlerForPublishingAsync()mip::ProtectionEngine->CreateProtectionHandlerForPublishing()
Fungsi-fungsi ini menerima objek mip::ProtectionHandler::PublishingSettings atau mip::ProtectionHandler::ConsumptionSettings .
Membuat handler penerbitan
Membuat handler penerbitan memerlukan tiga langkah:
- Buat objek
mip::ProtectionDescriptor. - Gunakan
mip::ProtectionDescriptoruntuk menginisialisasimip::ProtectionHandler::PublishingSettings. - Panggil
mip::ProtectionEngine::CreateProtectionHandlerForPublishingAsync()dengan memasukkan objekPublishingSettings, pengamat, dan janji.
Membuat dari deskriptor
Jika melindungi konten yang belum dilindungi, atau saat menerapkan perlindungan baru ke konten, yang menyiratkan bahwa konten telah didekripsi, mip::ProtectionDescriptor harus dibuat. Setelah dibangun, ini digunakan untuk menginstansiasi objek mip::ProtectionHandler::PublishingSettings(). Hasilnya dikembalikan melalui 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;
Setelah Anda berhasil membuat ProtectionHandler objek, operasi perlindungan (enkripsi/dekripsi) dapat dilakukan.
Lisensi penerbitan harus diambil dari handler dan disimpan dengan konten terenkripsi. Lisensi penerbitan dapat diambil dengan memanggil: handler->GetSerializedPublishingLicense();
Konten terproteksi tanpa lisensi penerbitan yang sesuai tidak dapat didekripsi.
Membuat pengelola konsumsi
Membuat handler konsumsi memerlukan tiga langkah:
- Ekstrak lisensi penerbitan berseri seperti
std::vector<uint8_t>dari konten yang dilindungi. - Gunakan lisensi penerbitan berseri untuk menginstansiasi
mip::ProtectionHandler::ConsumptionSettings. - Panggil
mip::ProtectionEngine::CreateProtectionHandlerForConsumptionAsync()dengan memasukkan objekConsumptionSettings, pengamat, dan janji.
Contoh ini mengasumsikan bahwa lisensi penerbitan telah dibaca dari beberapa sumber dan disimpan di 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();