api-changes: Use ndn-cpp-dev
Change-Id: I4540e601106598d51601e59e5fe9524a9080a572
diff --git a/src/validator-panel.h b/src/validator-panel.h
new file mode 100644
index 0000000..2bcc226
--- /dev/null
+++ b/src/validator-panel.h
@@ -0,0 +1,75 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ * Yingdi Yu
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Yingdi Yu <yingdi@cs.ucla.edu>
+ */
+
+#ifndef CHRONOS_VALIDATOR_PANEL_H
+#define CHRONOS_VALIDATOR_PANEL_H
+
+#include <ndn-cpp-dev/security/validator.hpp>
+#include <ndn-cpp-dev/security/sec-rule-relative.hpp>
+#include <ndn-cpp-dev/security/certificate-cache.hpp>
+#include <map>
+
+#include "endorse-certificate.h"
+
+namespace chronos{
+
+class ValidatorPanel : public ndn::Validator
+{
+public:
+
+ static const ndn::shared_ptr<ndn::CertificateCache> DEFAULT_CERT_CACHE;
+
+ ValidatorPanel(int stepLimit = 10,
+ const ndn::shared_ptr<ndn::CertificateCache> certificateCache = DEFAULT_CERT_CACHE);
+
+ ~ValidatorPanel()
+ {}
+
+ inline void
+ addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
+
+ inline void
+ removeTrustAnchor(const ndn::Name& keyName);
+
+protected:
+ virtual void
+ checkPolicy (const ndn::Data& data,
+ int stepCount,
+ const ndn::OnDataValidated& onValidated,
+ const ndn::OnDataValidationFailed& onValidationFailed,
+ std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps);
+
+ virtual void
+ checkPolicy (const ndn::Interest& interest,
+ int stepCount,
+ const ndn::OnInterestValidated& onValidated,
+ const ndn::OnInterestValidationFailed& onValidationFailed,
+ std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps)
+ { onValidationFailed(interest.shared_from_this()); }
+
+private:
+ int m_stepLimit;
+ ndn::shared_ptr<ndn::CertificateCache> m_certificateCache;
+ ndn::shared_ptr<ndn::SecRuleRelative> m_endorseeRule;
+ std::map<ndn::Name, ndn::PublicKey> m_trustAnchors;
+
+};
+
+void
+ValidatorPanel::addTrustAnchor(const EndorseCertificate& cert)
+{ m_trustAnchors[cert.getPublicKeyName()] = cert.getPublicKeyInfo(); }
+
+void
+ValidatorPanel::removeTrustAnchor(const ndn::Name& keyName)
+{ m_trustAnchors.erase(keyName); }
+
+}//chronos
+
+#endif