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
Untuk melindungi konten yang belum dilindungi, atau menerapkan perlindungan baru ke konten yang didekripsi, buat mip::ProtectionDescriptor. Gunakan untuk membuat instance objek mip::ProtectionHandler::PublishingSettings(). SDK mengembalikan hasil 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 berhasil membuat ProtectionHandler objek, Anda dapat melakukan operasi perlindungan untuk enkripsi dan dekripsi. Ambil lisensi penerbitan dari handler dan simpan dengan konten terenkripsi. Untuk mengambil lisensi penerbitan, panggil handler->GetSerializedPublishingLicense();.
Tanpa lisensi penerbitan yang sesuai, Anda tidak dapat mendekripsi konten yang dilindungi.
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();
Langkah berikutnya
- Untuk sampel, lihat sampel MIP Protection SDK C++ di GitHub.