Considerable re-work of KDM class to express the difference between encrypted and...
[libdcp.git] / src / decrypted_kdm.h
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "key.h"
21 #include "local_time.h"
22 #include "decrypted_kdm_key.h"
23 #include <boost/filesystem.hpp>
24
25 namespace dcp {
26
27 class DecryptedKDMKey;
28 class EncryptedKDM;
29 class Signer;
30 class Certificate;
31 class CPL;
32
33 class DecryptedKDM
34 {
35 public:
36         /** @param kdm Encrypted KDM.
37          *  @param private_key Private key file name.
38          */
39         DecryptedKDM (EncryptedKDM const & kdm, boost::filesystem::path private_key);
40
41         DecryptedKDM (
42                 boost::shared_ptr<const CPL> cpl,
43                 LocalTime not_valid_before,
44                 LocalTime not_valid_after,
45                 std::string annotation_text,
46                 std::string content_title_text,
47                 std::string issue_date
48                 );
49
50         void add_key (std::string type, std::string id, Key key);
51         EncryptedKDM encrypt (boost::shared_ptr<const Signer>, boost::shared_ptr<const Certificate>) const;
52
53         std::list<DecryptedKDMKey> keys () const {
54                 return _keys;
55         }
56
57 private:
58         LocalTime _not_valid_before;
59         LocalTime _not_valid_after;
60         std::string _annotation_text;
61         std::string _content_title_text;
62         std::string _issue_date;
63         std::list<DecryptedKDMKey> _keys;
64 };
65
66 }