Screen::Screen (cxml::ConstNodePtr node)
{
name = node->string_child ("Name");
- certificate = shared_ptr<dcp::Certificate> (new dcp::Certificate (node->string_child ("Certificate")));
+ if (node->optional_string_child ("Certificate")) {
+ certificate = dcp::Certificate (node->string_child ("Certificate"));
+ }
}
void
Screen::as_xml (xmlpp::Element* parent) const
{
parent->add_child("Name")->add_child_text (name);
- parent->add_child("Certificate")->add_child_text (certificate->certificate (true));
+ if (certificate) {
+ parent->add_child("Certificate")->add_child_text (certificate->certificate (true));
+ }
}
class Screen
{
public:
- Screen (std::string const & n, boost::shared_ptr<dcp::Certificate> cert)
+ Screen (std::string const & n, boost::optional<dcp::Certificate> cert)
: name (n)
, certificate (cert)
{}
boost::shared_ptr<Cinema> cinema;
std::string name;
- boost::shared_ptr<dcp::Certificate> certificate;
+ boost::optional<dcp::Certificate> certificate;
};
/** @class Cinema
/* Read the signing certificates and private key in from the config file */
list<cxml::NodePtr> certificates = signer->node_children ("Certificate");
for (list<cxml::NodePtr>::const_iterator i = certificates.begin(); i != certificates.end(); ++i) {
- signer_chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate ((*i)->content ())));
+ signer_chain.add (dcp::Certificate ((*i)->content ()));
}
_signer.reset (new dcp::Signer (signer_chain, signer->string_child ("PrivateKey")));
xmlpp::Element* signer = root->add_child ("Signer");
dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf ();
for (dcp::CertificateChain::List::const_iterator i = certs.begin(); i != certs.end(); ++i) {
- signer->add_child("Certificate")->add_child_text ((*i)->certificate (true));
+ signer->add_child("Certificate")->add_child_text (i->certificate (true));
}
signer->add_child("PrivateKey")->add_child_text (_signer->key ());
dcp::EncryptedKDM
Film::make_kdm (
- shared_ptr<dcp::Certificate> target,
+ dcp::Certificate target,
boost::filesystem::path cpl_file,
dcp::LocalTime from,
dcp::LocalTime until,
list<dcp::EncryptedKDM> kdms;
for (list<shared_ptr<Screen> >::iterator i = screens.begin(); i != screens.end(); ++i) {
- kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation));
+ if ((*i)->certificate) {
+ kdms.push_back (make_kdm ((*i)->certificate.get(), dcp, from, until, formulation));
+ }
}
return kdms;
dcp::EncryptedKDM
make_kdm (
- boost::shared_ptr<dcp::Certificate> target,
+ dcp::Certificate target,
boost::filesystem::path cpl_file,
dcp::LocalTime from,
dcp::LocalTime until,
error ("you must specify --output");
}
- shared_ptr<dcp::Certificate> certificate (new dcp::Certificate (dcp::file_to_string (certificate_file)));
+ dcp::Certificate certificate (dcp::file_to_string (certificate_file));
dcp::EncryptedKDM kdm = film->make_kdm (certificate, cpl, valid_from.get(), valid_to.get(), formulation);
kdm.as_xml (output);
if (verbose) {
if (d->ShowModal() == wxID_OK) {
try {
- shared_ptr<dcp::Certificate> c (new dcp::Certificate (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+ dcp::Certificate c (dcp::file_to_string (wx_to_std (d->GetPath ())));
_signer->certificates().add (c);
Config::instance()->set_signer (_signer);
update_certificate_list ();
wxListItem item;
item.SetId (n);
_certificates->InsertItem (item);
- _certificates->SetItem (n, 1, std_to_wx ((*i)->thumbprint ()));
+ _certificates->SetItem (n, 1, std_to_wx (i->thumbprint ()));
if (n == 0) {
_certificates->SetItem (n, 0, _("Root"));
using std::string;
using std::cout;
-using boost::shared_ptr;
+using boost::optional;
-ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ptr<dcp::Certificate> certificate)
+ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optional<dcp::Certificate> certificate)
: TableDialog (parent, std_to_wx (title), 2, true)
, _certificate (certificate)
{
return wx_to_std (_name->GetValue());
}
-shared_ptr<dcp::Certificate>
+optional<dcp::Certificate>
ScreenDialog::certificate () const
{
return _certificate;
ScreenDialog::load_certificate (boost::filesystem::path file)
{
try {
- _certificate.reset (new dcp::Certificate (dcp::file_to_string (file)));
+ _certificate = dcp::Certificate (dcp::file_to_string (file));
_certificate_text->SetValue (_certificate->certificate ());
} catch (dcp::MiscError& e) {
error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), e.what()));
ScreenDialog::setup_sensitivity ()
{
wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
- ok->Enable (_certificate.get ());
+ ok->Enable (_certificate);
_download_certificate->Enable (
_manufacturer->GetStringSelection() == _("Doremi") ||
class ScreenDialog : public TableDialog
{
public:
- ScreenDialog (wxWindow *, std::string, std::string name = "", boost::shared_ptr<dcp::Certificate> c = boost::shared_ptr<dcp::Certificate> ());
+ ScreenDialog (wxWindow *, std::string, std::string name = "", boost::optional<dcp::Certificate> c = boost::optional<dcp::Certificate> ());
std::string name () const;
- boost::shared_ptr<dcp::Certificate> certificate () const;
+ boost::optional<dcp::Certificate> certificate () const;
private:
void select_certificate ();
wxButton* _download_certificate;
wxTextCtrl* _certificate_text;
- boost::shared_ptr<dcp::Certificate> _certificate;
+ boost::optional<dcp::Certificate> _certificate;
};