summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-09-19 15:07:03 +0100
committerCarl Hetherington <cth@carlh.net>2013-09-19 15:07:03 +0100
commitf98c4cdec82fc2fbdcc4ca19748d09b0ea0556b4 (patch)
tree82e1fd2170c3e9ca246c464086d96ec809dc128f
parent98fd67b22129cefc6995cae6bc5b958a886e2e0c (diff)
Some boost::filesystem::path cleanups; tweak for changes to libdcp.
-rw-r--r--doc/manual/dcpomatic.xml12
-rw-r--r--src/lib/config.cc18
-rw-r--r--src/lib/config.h13
-rw-r--r--src/lib/film.cc22
-rw-r--r--src/lib/writer.cc11
-rw-r--r--src/wx/config_dialog.cc2
-rw-r--r--src/wx/new_film_dialog.cc4
-rw-r--r--src/wx/new_film_dialog.h2
8 files changed, 52 insertions, 32 deletions
diff --git a/doc/manual/dcpomatic.xml b/doc/manual/dcpomatic.xml
index 7d40324e0..e91863a48 100644
--- a/doc/manual/dcpomatic.xml
+++ b/doc/manual/dcpomatic.xml
@@ -949,6 +949,18 @@ most situations.
</chapter>
+<chapter xml:id="ch-encryption" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
+<title>Encryption</title>
+
+<para>
+It is not required that DCPs be encrypted, but they can be. This
+chapter describes how DCPs are signed and encrypted, and how KDMs
+work. It also discusses how DCP-o-matic can create encrypted DCPs and
+KDMs for them.
+</para>
+
+</chapter>
+
<chapter xml:id="ch-preferences" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
<title>Preferences</title>
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 5b96d108c..7d945c897 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -193,7 +193,7 @@ Config::read_old_metadata ()
}
/** @return Filename to write configuration to */
-string
+boost::filesystem::path
Config::file (bool old) const
{
boost::filesystem::path p;
@@ -205,18 +205,18 @@ Config::file (bool old) const
} else {
p /= "dcpomatic.xml";
}
- return p.string ();
+ return p;
}
-string
-Config::crypt_chain_directory () const
+boost::filesystem::path
+Config::signer_chain_directory () const
{
boost::filesystem::path p;
p /= g_get_user_config_dir ();
p /= "dvdomatic";
p /= "crypt";
boost::filesystem::create_directories (p);
- return p.string ();
+ return p;
}
/** @return Singleton instance */
@@ -245,7 +245,7 @@ Config::write () const
xmlpp::Element* root = doc.create_root_node ("Config");
root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads));
- root->add_child("DefaultDirectory")->add_child_text (_default_directory);
+ root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ());
root->add_child("ServerPort")->add_child_text (lexical_cast<string> (_server_port));
for (vector<ServerDescription>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
@@ -280,11 +280,11 @@ Config::write () const
i->as_xml (root->add_child ("ColourConversion"));
}
- doc.write_to_file_formatted (file (false));
+ doc.write_to_file_formatted (file(false).string ());
}
-string
-Config::default_directory_or (string a) const
+boost::filesystem::path
+Config::default_directory_or (boost::filesystem::path a) const
{
if (_default_directory.empty() || !boost::filesystem::exists (_default_directory)) {
return a;
diff --git a/src/lib/config.h b/src/lib/config.h
index 48eabd54c..8c80f9679 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -27,6 +27,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
+#include <boost/filesystem.hpp>
#include <libdcp/metadata.h>
#include "dci_metadata.h"
#include "colour_conversion.h"
@@ -52,11 +53,11 @@ public:
return _num_local_encoding_threads;
}
- std::string default_directory () const {
+ boost::filesystem::path default_directory () const {
return _default_directory;
}
- std::string default_directory_or (std::string a) const;
+ boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
/** @return port to use for J2K encoding servers */
int server_port () const {
@@ -138,7 +139,7 @@ public:
_num_local_encoding_threads = n;
}
- void set_default_directory (std::string d) {
+ void set_default_directory (boost::filesystem::path d) {
_default_directory = d;
}
@@ -230,21 +231,21 @@ public:
void write () const;
- std::string crypt_chain_directory () const;
+ boost::filesystem::path signer_chain_directory () const;
static Config* instance ();
static void drop ();
private:
Config ();
- std::string file (bool) const;
+ boost::filesystem::path file (bool) const;
void read ();
void read_old_metadata ();
/** number of threads to use for J2K encoding on the local machine */
int _num_local_encoding_threads;
/** default directory to put new films in */
- std::string _default_directory;
+ boost::filesystem::path _default_directory;
/** port to use for J2K encoding servers */
int _server_port;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index e885fe5fd..4f57f202a 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -31,8 +31,9 @@
#include <boost/date_time.hpp>
#include <libxml++/libxml++.h>
#include <libcxml/cxml.h>
-#include <libdcp/crypt_chain.h>
+#include <libdcp/signer_chain.h>
#include <libdcp/cpl.h>
+#include <libdcp/signer.h>
#include "film.h"
#include "job.h"
#include "util.h"
@@ -78,6 +79,7 @@ using boost::ends_with;
using boost::starts_with;
using boost::optional;
using libdcp::Size;
+using libdcp::Signer;
int const Film::state_version = 4;
@@ -897,34 +899,36 @@ Film::make_kdms (
string directory
) const
{
- string const cd = Config::instance()->crypt_chain_directory ();
- if (boost::filesystem::is_empty (cd)) {
- libdcp::make_crypt_chain (cd);
+ boost::filesystem::path const sd = Config::instance()->signer_chain_directory ();
+ if (boost::filesystem::is_empty (sd)) {
+ libdcp::make_signer_chain (sd);
}
libdcp::CertificateChain chain;
{
- boost::filesystem::path p (cd);
+ boost::filesystem::path p (sd);
p /= "ca.self-signed.pem";
chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
}
{
- boost::filesystem::path p (cd);
+ boost::filesystem::path p (sd);
p /= "intermediate.signed.pem";
chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
}
{
- boost::filesystem::path p (cd);
+ boost::filesystem::path p (sd);
p /= "leaf.signed.pem";
chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
}
- boost::filesystem::path signer_key (cd);
+ boost::filesystem::path signer_key (sd);
signer_key /= "leaf.key";
+ shared_ptr<const Signer> signer (new Signer (chain, signer_key));
+
/* Find the DCP to make the KDM for */
string const dir = this->directory ();
list<string> dcps;
@@ -947,7 +951,7 @@ Film::make_kdms (
/* XXX: single CPL only */
shared_ptr<xmlpp::Document> kdm = dcp.cpls().front()->make_kdm (
- chain, signer_key.string(), (*i)->certificate, from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata ()
+ signer, (*i)->certificate, from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata ()
);
boost::filesystem::path out = directory;
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 5f94d5d6b..4f93373f7 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -73,13 +73,14 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
it into the DCP later.
*/
- if (f->three_d ()) {
+ if (_film->three_d ()) {
_picture_asset.reset (
new libdcp::StereoPictureAsset (
_film->internal_video_mxf_dir (),
_film->internal_video_mxf_filename (),
_film->video_frame_rate (),
- _film->container()->size (_film->full_frame ())
+ _film->container()->size (_film->full_frame ()),
+ _film->encrypted ()
)
);
@@ -89,7 +90,8 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_film->internal_video_mxf_dir (),
_film->internal_video_mxf_filename (),
_film->video_frame_rate (),
- _film->container()->size (_film->full_frame ())
+ _film->container()->size (_film->full_frame ()),
+ _film->encrypted ()
)
);
@@ -103,7 +105,8 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
_film->audio_mxf_filename (),
_film->video_frame_rate (),
_film->audio_channels (),
- _film->audio_frame_rate ()
+ _film->audio_frame_rate (),
+ _film->encrypted ()
)
);
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 7f1efa52f..dba83804e 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -179,7 +179,7 @@ ConfigDialog::make_misc_panel ()
_default_still_length->SetValue (config->default_still_length ());
_default_still_length->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_still_length_changed, this));
- _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()))));
+ _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
_default_directory->Bind (wxEVT_COMMAND_DIRPICKER_CHANGED, boost::bind (&ConfigDialog::default_directory_changed, this));
_default_dci_metadata_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::edit_default_dci_metadata_clicked, this));
diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc
index 6a8935232..2612a6afe 100644
--- a/src/wx/new_film_dialog.cc
+++ b/src/wx/new_film_dialog.cc
@@ -29,7 +29,7 @@
using namespace std;
using namespace boost;
-boost::optional<string> NewFilmDialog::_directory;
+boost::optional<boost::filesystem::path> NewFilmDialog::_directory;
NewFilmDialog::NewFilmDialog (wxWindow* parent)
: wxDialog (parent, wxID_ANY, _("New Film"))
@@ -57,7 +57,7 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent)
_directory = Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()));
}
- _folder->SetPath (std_to_wx (_directory.get()));
+ _folder->SetPath (std_to_wx (_directory.get().string()));
table->Add (_folder, 1, wxEXPAND);
wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h
index f8f3aa08d..4176b060d 100644
--- a/src/wx/new_film_dialog.h
+++ b/src/wx/new_film_dialog.h
@@ -38,5 +38,5 @@ private:
#else
wxDirPickerCtrl* _folder;
#endif
- static boost::optional<std::string> _directory;
+ static boost::optional<boost::filesystem::path> _directory;
};