Changes to libdcp.
authorCarl Hetherington <cth@carlh.net>
Thu, 30 Jul 2015 01:10:26 +0000 (02:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 30 Jul 2015 01:10:26 +0000 (02:10 +0100)
src/lib/cinema.h
src/lib/config.cc
src/lib/config.h
src/lib/film.cc
src/lib/util.cc
src/lib/writer.cc
src/tools/dcpomatic_kdm.cc
src/wx/config_dialog.cc
src/wx/screen_dialog.h

index fea4f1c149362ebbc944a8dc1bb547ccb9943b0c..4639261c30bebc93e6237e6abe05546763026415 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <libcxml/cxml.h>
-#include <dcp/certificates.h>
+#include <dcp/certificate.h>
 #include <boost/enable_shared_from_this.hpp>
 
 class Cinema;
index e600056ad1f9ed800d7a4569cdd3d098aa60a9f3..b75791a45e96c52992d2bacdb39a8b6db742e045 100644 (file)
@@ -30,7 +30,6 @@
 #include "cross.h"
 #include "raw_convert.h"
 #include <dcp/colour_matrix.h>
-#include <dcp/signer.h>
 #include <dcp/certificate_chain.h>
 #include <libcxml/cxml.h>
 #include <glib.h>
@@ -121,7 +120,7 @@ Config::read ()
 {
        if (!boost::filesystem::exists (file ())) {
                /* Make a new set of signing certificates and key */
-               _signer.reset (new dcp::Signer (openssl_path ()));
+               _signer.reset (new dcp::CertificateChain (openssl_path ()));
                /* And decryption keys */
                make_decryption_keys ();
                return;
@@ -236,16 +235,17 @@ Config::read ()
        cxml::NodePtr signer = f.optional_node_child ("Signer");
        dcp::CertificateChain signer_chain;
        if (signer) {
+               shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
                /* 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 (dcp::Certificate ((*i)->content ()));
+                       c->add (dcp::Certificate ((*i)->content ()));
                }
-
-               _signer.reset (new dcp::Signer (signer_chain, signer->string_child ("PrivateKey")));
+               c->set_key (signer->string_child ("PrivateKey"));
+               _signer = c;
        } else {
                /* Make a new set of signing certificates and key */
-               _signer.reset (new dcp::Signer (openssl_path ()));
+               _signer.reset (new dcp::CertificateChain (openssl_path ()));
        }
 
        if (f.optional_string_child ("DecryptionCertificate")) {
@@ -265,10 +265,9 @@ Config::read ()
 void
 Config::make_decryption_keys ()
 {
-       boost::filesystem::path p = dcp::make_certificate_chain (openssl_path ());
-       _decryption_certificate = dcp::Certificate (dcp::file_to_string (p / "leaf.signed.pem"));
-       _decryption_private_key = dcp::file_to_string (p / "leaf.key");
-       boost::filesystem::remove_all (p);
+       dcp::CertificateChain c (openssl_path ());
+       _decryption_certificate = c.leaf ();
+       _decryption_private_key = c.key().get ();
 }
 
 /** @return Filename to write configuration to */
@@ -380,11 +379,11 @@ Config::write () const
 #endif
 
        xmlpp::Element* signer = root->add_child ("Signer");
-       dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf ();
+       dcp::CertificateChain::List certs = _signer->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("PrivateKey")->add_child_text (_signer->key ());
+       signer->add_child("PrivateKey")->add_child_text (_signer->key().get ());
 
        root->add_child("DecryptionCertificate")->add_child_text (_decryption_certificate.certificate (true));
        root->add_child("DecryptionPrivateKey")->add_child_text (_decryption_private_key);
index b008fe22f8e97ca3ed10caac11a4daa58157b4fd..913c2abc3913fc11444b82ab14bfbbe35d5f74b8 100644 (file)
@@ -27,8 +27,8 @@
 #include "isdcf_metadata.h"
 #include "video_content.h"
 #include <dcp/metadata.h>
-#include <dcp/certificates.h>
-#include <dcp/signer.h>
+#include <dcp/certificate.h>
+#include <dcp/certificate_chain.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <boost/filesystem.hpp>
@@ -199,7 +199,7 @@ public:
                return _kdm_email;
        }
 
-       boost::shared_ptr<const dcp::Signer> signer () const {
+       boost::shared_ptr<const dcp::CertificateChain> signer () const {
                return _signer;
        }
 
@@ -376,7 +376,7 @@ public:
 
        void reset_kdm_email ();
 
-       void set_signer (boost::shared_ptr<const dcp::Signer> s) {
+       void set_signer (boost::shared_ptr<const dcp::CertificateChain> s) {
                maybe_set (_signer, s);
        }
 
@@ -489,7 +489,7 @@ private:
        std::string _kdm_cc;
        std::string _kdm_bcc;
        std::string _kdm_email;
-       boost::shared_ptr<const dcp::Signer> _signer;
+       boost::shared_ptr<const dcp::CertificateChain> _signer;
        dcp::Certificate _decryption_certificate;
        std::string _decryption_private_key;
        /** true to check for updates on startup */
index e935e76bca5e9146940f4af0336c27e42a75c4b1..548c51796f4c10352a8a17aed9c4fa5da8b5206b 100644 (file)
@@ -45,7 +45,7 @@
 #include "md5_digester.h"
 #include <libcxml/cxml.h>
 #include <dcp/cpl.h>
-#include <dcp/signer.h>
+#include <dcp/certificate_chain.h>
 #include <dcp/util.h>
 #include <dcp/local_time.h>
 #include <dcp/decrypted_kdm.h>
@@ -87,7 +87,7 @@ using boost::starts_with;
 using boost::optional;
 using boost::is_any_of;
 using dcp::Size;
-using dcp::Signer;
+using dcp::CertificateChain;
 
 #define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
 #define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
@@ -1063,7 +1063,7 @@ Film::make_kdm (
        ) const
 {
        shared_ptr<const dcp::CPL> cpl (new dcp::CPL (cpl_file));
-       shared_ptr<const dcp::Signer> signer = Config::instance()->signer();
+       shared_ptr<const dcp::CertificateChain> signer = Config::instance()->signer();
        if (!signer->valid ()) {
                throw InvalidSignerError ();
        }
index dad094b6ee750e76d6697dd7663f865572f1b0d3..ede1d4e9b5c16bdee34c0c2ec7fd23db1e1bb7a2 100644 (file)
@@ -36,7 +36,6 @@
 #include "audio_processor.h"
 #include "safe_stringstream.h"
 #include <dcp/util.h>
-#include <dcp/signer.h>
 #include <dcp/picture_asset.h>
 #include <dcp/sound_asset.h>
 #include <dcp/subtitle_asset.h>
index 863b49959d750495ff8fb72688eb72ebfe72b95d..7b2cfa3d215fdf528f19224125dc700db43a8cf0 100644 (file)
@@ -45,7 +45,7 @@
 #include <dcp/reel_subtitle_asset.h>
 #include <dcp/dcp.h>
 #include <dcp/cpl.h>
-#include <dcp/signer.h>
+#include <dcp/certificate_chain.h>
 #include <dcp/interop_subtitle_asset.h>
 #include <dcp/smpte_subtitle_asset.h>
 #include <boost/foreach.hpp>
@@ -597,7 +597,7 @@ Writer::finish ()
        meta.creator = String::compose ("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit);
        meta.set_issue_date_now ();
 
-       shared_ptr<const dcp::Signer> signer;
+       shared_ptr<const dcp::CertificateChain> signer;
        if (_film->is_signed ()) {
                signer = Config::instance()->signer ();
                /* We did check earlier, but check again here to be on the safe side */
index 345b905457d8415ae3b7e7edf78d6e3f054c8a3c..0a43a91f28421f7b2d745882dfcd51a15a538f14 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <getopt.h>
-#include <dcp/certificates.h>
+#include <dcp/certificate.h>
 #include "lib/film.h"
 #include "lib/cinema.h"
 #include "lib/kdm.h"
index 53adcd0a067a3296df8206eba5604c1d2d81c532..fd6bcb08663433e13760313f6118c33567d7d863 100644 (file)
@@ -39,7 +39,7 @@
 #include "lib/cross.h"
 #include "lib/exceptions.h"
 #include <dcp/exceptions.h>
-#include <dcp/signer.h>
+#include <dcp/certificate_chain.h>
 #include <wx/stdpaths.h>
 #include <wx/preferences.h>
 #include <wx/filepicker.h>
@@ -676,7 +676,7 @@ private:
 
        void config_changed ()
        {
-               _signer.reset (new dcp::Signer (*Config::instance()->signer().get ()));
+               _signer.reset (new dcp::CertificateChain (*Config::instance()->signer().get ()));
 
                update_certificate_list ();
                update_signer_private_key ();
@@ -692,7 +692,7 @@ private:
                if (d->ShowModal() == wxID_OK) {
                        try {
                                dcp::Certificate c (dcp::file_to_string (wx_to_std (d->GetPath ())));
-                               _signer->certificates().add (c);
+                               _signer->add (c);
                                Config::instance()->set_signer (_signer);
                                update_certificate_list ();
                        } catch (dcp::MiscError& e) {
@@ -713,7 +713,7 @@ private:
                }
 
                _certificates->DeleteItem (i);
-               _signer->certificates().remove (i);
+               _signer->remove (i);
                Config::instance()->set_signer (_signer);
 
                update_sensitivity ();
@@ -722,7 +722,7 @@ private:
        void update_certificate_list ()
        {
                _certificates->DeleteAllItems ();
-               dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf ();
+               dcp::CertificateChain::List certs = _signer->root_to_leaf ();
                size_t n = 0;
                for (dcp::CertificateChain::List::const_iterator i = certs.begin(); i != certs.end(); ++i) {
                        wxListItem item;
@@ -744,11 +744,11 @@ private:
 
        void remake_certificates ()
        {
-               dcp::CertificateChain chain = Config::instance()->signer()->certificates ();
+               shared_ptr<const dcp::CertificateChain> chain = Config::instance()->signer();
 
                string intermediate_common_name;
-               if (chain.root_to_leaf().size() >= 3) {
-                       dcp::CertificateChain::List all = chain.root_to_leaf ();
+               if (chain->root_to_leaf().size() >= 3) {
+                       dcp::CertificateChain::List all = chain->root_to_leaf ();
                        dcp::CertificateChain::List::iterator i = all.begin ();
                        ++i;
                        intermediate_common_name = i->subject_common_name ();
@@ -756,16 +756,16 @@ private:
 
                MakeSignerChainDialog* d = new MakeSignerChainDialog (
                        _panel,
-                       chain.root().subject_organization_name (),
-                       chain.root().subject_organizational_unit_name (),
-                       chain.root().subject_common_name (),
+                       chain->root().subject_organization_name (),
+                       chain->root().subject_organizational_unit_name (),
+                       chain->root().subject_common_name (),
                        intermediate_common_name,
-                       chain.leaf().subject_common_name ()
+                       chain->leaf().subject_common_name ()
                        );
 
                if (d->ShowModal () == wxID_OK) {
                        _signer.reset (
-                               new dcp::Signer (
+                               new dcp::CertificateChain (
                                        openssl_path (),
                                        d->organisation (),
                                        d->organisational_unit (),
@@ -790,7 +790,7 @@ private:
 
        void update_signer_private_key ()
        {
-               checked_set (_signer_private_key, dcp::private_key_fingerprint (_signer->key ()));
+               checked_set (_signer_private_key, dcp::private_key_fingerprint (_signer->key().get ()));
        }
 
        void load_signer_private_key ()
@@ -894,7 +894,7 @@ private:
        wxStaticText* _decryption_private_key;
        wxButton* _load_decryption_private_key;
        wxButton* _export_decryption_certificate;
-       shared_ptr<dcp::Signer> _signer;
+       shared_ptr<dcp::CertificateChain> _signer;
 };
 
 class TMSPage : public StandardPage
index 69d0fff81b7f7e29da6a11310bfae1245ceef8c6..cf8d3da180dc14ab247911cd69ae1b3117ef69d7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <wx/wx.h>
 #include <boost/shared_ptr.hpp>
-#include <dcp/certificates.h>
+#include <dcp/certificate.h>
 #include "table_dialog.h"
 
 class Progress;