More licence fixups.
[libdcp.git] / src / encrypted_kdm.h
1 /*
2     Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp 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.
10
11     libdcp 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.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 /** @file  src/encrypted_kdm.h
21  *  @brief EncryptedKDM class.
22  */
23
24 #ifndef LIBDCP_ENCRYPTED_KDM_H
25 #define LIBDCP_ENCRYPTED_KDM_H
26
27 #include "local_time.h"
28 #include "types.h"
29 #include <boost/filesystem.hpp>
30 #include <boost/optional.hpp>
31 #include <boost/date_time/local_time/local_time.hpp>
32
33 namespace cxml {
34         class Node;
35 }
36
37 namespace dcp {
38
39 namespace data {
40         class EncryptedKDMData;
41 }
42
43 class CertificateChain;
44 class Certificate;
45
46 /** @class EncryptedKDM
47  *  @brief An encrypted KDM.
48  *
49  *  This is a KDM whose keys are encrypted using the target projector's private key.
50  *  An EncryptedKDM object can be initialised from a KDM XML file, or created from
51  *  a DecryptedKDM (using DecryptedKDM::encrypt).
52  */
53 class EncryptedKDM
54 {
55 public:
56         EncryptedKDM (std::string);
57         EncryptedKDM (EncryptedKDM const & kdm);
58         EncryptedKDM & operator= (EncryptedKDM const &);
59         ~EncryptedKDM ();
60
61         /** Write this KDM as XML to a file.
62          *  @param file File to write to.
63          */
64         void as_xml (boost::filesystem::path file) const;
65
66         /** @return This KDM as XML */
67         std::string as_xml () const;
68
69         /** @return The base64-encoded and encrypted keys that this KDM delivers.
70          *  Note that the returned `keys' contain more than just the asset decryption
71          *  keys (also key id, CPL id etc.)
72          */
73         std::list<std::string> keys () const;
74
75         boost::optional<std::string> annotation_text () const;
76         std::string content_title_text () const;
77         std::string issue_date () const;
78         std::string cpl_id () const;
79
80 private:
81
82         friend class DecryptedKDM;
83
84         /** Construct an EncryptedKDM from a set of details */
85         EncryptedKDM (
86                 boost::shared_ptr<const CertificateChain> signer,
87                 Certificate recipient,
88                 std::vector<Certificate> trusted_devices,
89                 std::string device_list_description,
90                 std::string cpl_id,
91                 std::string cpl_content_title_text,
92                 boost::optional<std::string> annotation_text,
93                 LocalTime not_valid_before,
94                 LocalTime not_valid_after,
95                 Formulation formulation,
96                 std::list<std::pair<std::string, std::string> > key_ids,
97                 std::list<std::string> keys
98                 );
99
100         data::EncryptedKDMData* _data;
101 };
102
103 extern bool operator== (EncryptedKDM const & a, EncryptedKDM const & b);
104
105 }
106
107 #endif