2 Copyright (C) 2013-2016 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/>.
22 #include <libxml++/libxml++.h>
23 #include <boost/foreach.hpp>
24 #include <boost/algorithm/string.hpp>
29 Screen::Screen (cxml::ConstNodePtr node)
30 : name (node->string_child("Name"))
31 , notes (node->optional_string_child("Notes").get_value_or (""))
33 if (node->optional_string_child ("Certificate")) {
34 recipient = dcp::Certificate (node->string_child ("Certificate"));
35 } else if (node->optional_string_child ("Recipient")) {
36 recipient = dcp::Certificate (node->string_child ("Recipient"));
39 BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children ("TrustedDevice")) {
40 if (boost::algorithm::starts_with(i->content(), "-----BEGIN CERTIFICATE-----")) {
41 trusted_devices.push_back (TrustedDevice(dcp::Certificate(i->content())));
43 trusted_devices.push_back (TrustedDevice(i->content()));
49 Screen::as_xml (xmlpp::Element* parent) const
51 parent->add_child("Name")->add_child_text (name);
53 parent->add_child("Recipient")->add_child_text (recipient->certificate (true));
56 parent->add_child("Notes")->add_child_text (notes);
58 BOOST_FOREACH (TrustedDevice i, trusted_devices) {
59 parent->add_child("TrustedDevice")->add_child_text(i.as_string());
64 Screen::trusted_device_thumbprints () const
67 BOOST_FOREACH (TrustedDevice i, trusted_devices) {
68 t.push_back (i.thumbprint());
73 TrustedDevice::TrustedDevice (string thumbprint)
74 : _thumbprint (thumbprint)
79 TrustedDevice::TrustedDevice (dcp::Certificate certificate)
80 : _certificate (certificate)
86 TrustedDevice::as_string () const
89 return _certificate->certificate(true);
96 TrustedDevice::thumbprint () const
99 return _certificate->thumbprint ();