Use an enum class for Marker.
[libdcp.git] / src / certificate_chain.h
index 3a925373365509fbdb59030fa8d90b9a6bde8d58..c74bc6e24b45967b9c0458c8ba5f8e72cfc9366c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -47,6 +47,15 @@ namespace xmlpp {
        class Node;
 }
 
+struct certificates_validation1;
+struct certificates_validation2;
+struct certificates_validation3;
+struct certificates_validation4;
+struct certificates_validation5;
+struct certificates_validation6;
+struct certificates_validation7;
+struct certificates_validation8;
+
 namespace dcp {
 
 /** @class CertificateChain
@@ -74,6 +83,8 @@ public:
                std::string leaf_common_name = "CS.smpte-430-2.LEAF.NOT_FOR_PRODUCTION"
                );
 
+       explicit CertificateChain (std::string);
+
        void add (Certificate c);
        void remove (Certificate c);
        void remove (int);
@@ -81,16 +92,18 @@ public:
        Certificate root () const;
        Certificate leaf () const;
 
-       typedef std::list<Certificate> List;
+       typedef std::vector<Certificate> List;
 
        List leaf_to_root () const;
        List root_to_leaf () const;
+       List unordered () const;
 
-       bool valid () const;
-       bool attempt_reorder ();
+       bool valid (std::string* reason = 0) const;
+       bool chain_valid () const;
+       bool private_key_valid () const;
 
        void sign (xmlpp::Element* parent, Standard standard) const;
-       void add_signature_value (xmlpp::Node* parent, std::string ns) const;
+       void add_signature_value (xmlpp::Element* parent, std::string ns, bool add_indentation) const;
 
        boost::optional<std::string> key () const {
                return _key;
@@ -100,9 +113,21 @@ public:
                _key = k;
        }
 
-private:
-       friend class ::certificates;
+       std::string chain () const;
 
+private:
+       friend struct ::certificates_validation1;
+       friend struct ::certificates_validation2;
+       friend struct ::certificates_validation3;
+       friend struct ::certificates_validation4;
+       friend struct ::certificates_validation5;
+       friend struct ::certificates_validation6;
+       friend struct ::certificates_validation7;
+       friend struct ::certificates_validation8;
+
+       bool chain_valid (List const & chain) const;
+
+       /** Our certificates, not in any particular order */
        List _certificates;
        /** Leaf certificate's private key, if known */
        boost::optional<std::string> _key;