@@ -449,58 +449,3 @@ StreamListSource::next(std::string& name, int64_t& size)
449449 size = _files[_current].size ;
450450 return libcdoc::OK;
451451}
452-
453- static void
454- recode_label (libcdoc::Recipient& rcpt, std::string& label, uint64_t & expiry)
455- {
456- if (!label.starts_with (" data:" )) return ;
457- auto values = libcdoc::Lock::parseLabel (label);
458- if (!values.contains (" v" ) || !values.contains (" type" )) return ;
459- std::string v = values.at (" v" );
460- values.erase (" v" );
461- std::string type = values.at (" type" );
462- values.erase (" type" );
463- std::string expiry_str = values.at (" server_exp" );
464- values.erase (" server_exp" );
465- if (!expiry_str.empty ()) expiry = std::stoll (expiry_str);
466- for (const auto & [key, value] : values) {
467- if (!value.empty ())
468- rcpt.setLabelValue (key, value);
469- }
470- }
471-
472- libcdoc::Recipient
473- makeFromLock (const libcdoc::Lock& lock, const std::string& server_id)
474- {
475- uint64_t expiry_ts = 0 ;
476- std::string label = lock.label ;
477- switch (lock.type ) {
478- case libcdoc::Lock::CDOC1:
479- if (!server_id.empty ()) {
480- libcdoc::Recipient rcpt = libcdoc::Recipient::makeServer (label, lock.getBytes (libcdoc::Lock::CERT), server_id);
481- recode_label (rcpt, label, expiry_ts);
482- return rcpt;
483- } else {
484- libcdoc::Recipient rcpt = libcdoc::Recipient::makeCertificate (label, lock.getBytes (libcdoc::Lock::CERT));
485- recode_label (rcpt, label, expiry_ts);
486- return rcpt;
487- }
488- case libcdoc::Lock::PUBLIC_KEY:
489- case libcdoc::Lock::SERVER: {
490- libcdoc::Recipient::PKType rcpt_type = (lock.pk_type == libcdoc::Lock::RSA) ? libcdoc::Recipient::RSA : libcdoc::Recipient::ECC;
491- if (!server_id.empty ()) {
492- libcdoc::Recipient rcpt = libcdoc::Recipient::makeServer (label, lock.getBytes (libcdoc::Lock::RCPT_KEY), rcpt_type, server_id);
493- recode_label (rcpt, label, expiry_ts);
494- rcpt.expiry_ts = expiry_ts;
495- return rcpt;
496- } else {
497- libcdoc::Recipient rcpt = libcdoc::Recipient::makePublicKey (label, lock.getBytes (libcdoc::Lock::RCPT_KEY), rcpt_type);
498- recode_label (rcpt, label, expiry_ts);
499- rcpt.expiry_ts = expiry_ts;
500- return rcpt;
501- }
502- }
503- default :
504- return {};
505- }
506- }
0 commit comments