Add conversions from char.
[libdcp.git] / src / encrypted_kdm.cc
index 85c1f0d8850b22cd049c1d0e12182e453b10adec..ec8e6835fb3508680fe3943ceb365688d6e71dc5 100644 (file)
     You should have received a copy of the GNU General Public License
     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
 
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
 */
 
 #include "encrypted_kdm.h"
@@ -47,7 +60,7 @@ class Signer
 public:
        Signer () {}
 
-       Signer (shared_ptr<const cxml::Node> node)
+       explicit Signer (shared_ptr<const cxml::Node> node)
                : x509_issuer_name (node->string_child ("X509IssuerName"))
                , x509_serial_number (node->string_child ("X509SerialNumber"))
        {
@@ -69,7 +82,7 @@ class X509Data
 public:
        X509Data () {}
 
-       X509Data (boost::shared_ptr<const cxml::Node> node)
+       explicit X509Data (boost::shared_ptr<const cxml::Node> node)
                : x509_issuer_serial (Signer (node->node_child ("X509IssuerSerial")))
                , x509_certificate (node->string_child ("X509Certificate"))
        {
@@ -91,11 +104,11 @@ class Reference
 public:
        Reference () {}
 
-       Reference (string u)
+       explicit Reference (string u)
                : uri (u)
        {}
 
-       Reference (shared_ptr<const cxml::Node> node)
+       explicit Reference (shared_ptr<const cxml::Node> node)
                : uri (node->string_attribute ("URI"))
                , digest_value (node->string_child ("DigestValue"))
        {
@@ -121,7 +134,7 @@ public:
                , authenticated_private ("#ID_AuthenticatedPrivate")
        {}
 
-       SignedInfo (shared_ptr<const cxml::Node> node)
+       explicit SignedInfo (shared_ptr<const cxml::Node> node)
        {
                list<shared_ptr<cxml::Node> > references = node->node_children ("Reference");
                for (list<shared_ptr<cxml::Node> >::const_iterator i = references.begin(); i != references.end(); ++i) {
@@ -159,7 +172,7 @@ class Signature
 public:
        Signature () {}
 
-       Signature (shared_ptr<const cxml::Node> node)
+       explicit Signature (shared_ptr<const cxml::Node> node)
                : signed_info (node->node_child ("SignedInfo"))
                , signature_value (node->string_child ("SignatureValue"))
        {
@@ -190,7 +203,7 @@ class AuthenticatedPrivate
 public:
        AuthenticatedPrivate () {}
 
-       AuthenticatedPrivate (shared_ptr<const cxml::Node> node)
+       explicit AuthenticatedPrivate (shared_ptr<const cxml::Node> node)
        {
                list<shared_ptr<cxml::Node> > encrypted_key_nodes = node->node_children ("EncryptedKey");
                for (list<shared_ptr<cxml::Node> >::const_iterator i = encrypted_key_nodes.begin(); i != encrypted_key_nodes.end(); ++i) {
@@ -225,7 +238,7 @@ class TypedKeyId
 public:
        TypedKeyId () {}
 
-       TypedKeyId (shared_ptr<const cxml::Node> node)
+       explicit TypedKeyId (shared_ptr<const cxml::Node> node)
                : key_type (node->string_child ("KeyType"))
                , key_id (remove_urn_uuid (node->string_child ("KeyId")))
        {
@@ -257,7 +270,7 @@ class KeyIdList
 public:
        KeyIdList () {}
 
-       KeyIdList (shared_ptr<const cxml::Node> node)
+       explicit KeyIdList (shared_ptr<const cxml::Node> node)
        {
                list<shared_ptr<cxml::Node> > typed_key_id_nodes = node->node_children ("TypedKeyId");
                for (list<shared_ptr<cxml::Node> >::const_iterator i = typed_key_id_nodes.begin(); i != typed_key_id_nodes.end(); ++i) {
@@ -280,7 +293,7 @@ class AuthorizedDeviceInfo
 public:
        AuthorizedDeviceInfo () {}
 
-       AuthorizedDeviceInfo (shared_ptr<const cxml::Node> node)
+       explicit AuthorizedDeviceInfo (shared_ptr<const cxml::Node> node)
                : device_list_identifier (remove_urn_uuid (node->string_child ("DeviceListIdentifier")))
                , device_list_description (node->optional_string_child ("DeviceListDescription"))
        {
@@ -312,7 +325,7 @@ class X509IssuerSerial
 public:
        X509IssuerSerial () {}
 
-       X509IssuerSerial (shared_ptr<const cxml::Node> node)
+       explicit X509IssuerSerial (shared_ptr<const cxml::Node> node)
                : x509_issuer_name (node->string_child ("X509IssuerName"))
                , x509_serial_number (node->string_child ("X509SerialNumber"))
        {
@@ -334,7 +347,7 @@ class Recipient
 public:
        Recipient () {}
 
-       Recipient (shared_ptr<const cxml::Node> node)
+       explicit Recipient (shared_ptr<const cxml::Node> node)
                : x509_issuer_serial (node->node_child ("X509IssuerSerial"))
                , x509_subject_name (node->string_child ("X509SubjectName"))
        {
@@ -356,7 +369,7 @@ class KDMRequiredExtensions
 public:
        KDMRequiredExtensions () {}
 
-       KDMRequiredExtensions (shared_ptr<const cxml::Node> node)
+       explicit KDMRequiredExtensions (shared_ptr<const cxml::Node> node)
                : recipient (node->node_child ("Recipient"))
                , composition_playlist_id (remove_urn_uuid (node->string_child ("CompositionPlaylistId")))
                , content_title_text (node->string_child ("ContentTitleText"))
@@ -403,7 +416,7 @@ class RequiredExtensions
 public:
        RequiredExtensions () {}
 
-       RequiredExtensions (shared_ptr<const cxml::Node> node)
+       explicit RequiredExtensions (shared_ptr<const cxml::Node> node)
                : kdm_required_extensions (node->node_child ("KDMRequiredExtensions"))
        {
 
@@ -427,7 +440,7 @@ public:
                , issue_date (LocalTime().as_string ())
        {}
 
-       AuthenticatedPublic (shared_ptr<const cxml::Node> node)
+       explicit AuthenticatedPublic (shared_ptr<const cxml::Node> node)
                : message_id (remove_urn_uuid (node->string_child ("MessageId")))
                , annotation_text (node->optional_string_child ("AnnotationText"))
                , issue_date (node->string_child ("IssueDate"))
@@ -472,7 +485,7 @@ public:
 
        }
 
-       EncryptedKDMData (shared_ptr<const cxml::Node> node)
+       explicit EncryptedKDMData (shared_ptr<const cxml::Node> node)
                : authenticated_public (node->node_child ("AuthenticatedPublic"))
                , authenticated_private (node->node_child ("AuthenticatedPrivate"))
                , signature (node->node_child ("Signature"))
@@ -564,6 +577,7 @@ EncryptedKDM::EncryptedKDM (
                   reports that this doesn't work with his setup;
                   a working KDM does not include the recipient's
                   thumbprint (recipient.thumbprint()).
+                  Waimea uses only the trusted devices here, too.
                */
                BOOST_FOREACH (Certificate const & i, trusted_devices) {
                        kre.authorized_device_info.certificate_thumbprints.push_back (i.thumbprint ());
@@ -658,6 +672,18 @@ EncryptedKDM::issue_date () const
        return _data->authenticated_public.issue_date;
 }
 
+LocalTime
+EncryptedKDM::not_valid_before () const
+{
+       return _data->authenticated_public.required_extensions.kdm_required_extensions.not_valid_before;
+}
+
+LocalTime
+EncryptedKDM::not_valid_after () const
+{
+       return _data->authenticated_public.required_extensions.kdm_required_extensions.not_valid_after;
+}
+
 bool
 dcp::operator== (EncryptedKDM const & a, EncryptedKDM const & b)
 {