2 Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
23 #include "cinema_list.h"
27 #include "kdm_with_metadata.h"
29 #include <libxml++/libxml++.h>
30 #include <boost/algorithm/string.hpp>
31 #include <boost/date_time/posix_time/posix_time.hpp>
35 using std::make_shared;
36 using std::shared_ptr;
39 using boost::optional;
40 using namespace dcpomatic;
44 Screen::trusted_device_thumbprints () const
47 for (auto i: trusted_devices) {
48 t.push_back (i.thumbprint());
56 std::function<dcp::DecryptedKDM (dcp::LocalTime, dcp::LocalTime)> make_kdm,
60 dcp::LocalTime valid_from,
61 dcp::LocalTime valid_to,
62 dcp::Formulation formulation,
63 bool disable_forensic_marking_picture,
64 optional<int> disable_forensic_marking_audio,
65 vector<KDMCertificatePeriod>& period_checks
68 if (!screen.recipient) {
72 period_checks.push_back(check_kdm_and_certificate_validity_periods(cinema.name, screen.name, screen.recipient.get(), valid_from, valid_to));
74 auto signer = Config::instance()->signer_chain();
75 if (!signer->valid()) {
76 throw InvalidSignerError();
79 auto kdm = make_kdm(valid_from, valid_to).encrypt(
80 signer, screen.recipient.get(), screen.trusted_device_thumbprints(), formulation, disable_forensic_marking_picture, disable_forensic_marking_audio
83 dcp::NameFormat::Map name_values;
84 name_values['c'] = cinema.name;
85 name_values['s'] = screen.name;
86 name_values['f'] = kdm.content_title_text();
87 name_values['b'] = valid_from.date() + " " + valid_from.time_of_day(true, false);
88 name_values['e'] = valid_to.date() + " " + valid_to.time_of_day(true, false);
89 name_values['i'] = kdm.cpl_id();
91 return make_shared<KDMWithMetadata>(name_values, cinema_id, cinema.emails, kdm);