security: renaming PolicyManager classess to SecPolicy___ and re-organize security file layout
Change-Id: Ibca0333129a3d4465ff294c4d97d59808ae253f4
diff --git a/include/ndn-cpp/security/certificate/certificate-extension.hpp b/include/ndn-cpp/security/certificate-extension.hpp
similarity index 94%
rename from include/ndn-cpp/security/certificate/certificate-extension.hpp
rename to include/ndn-cpp/security/certificate-extension.hpp
index c212216..61f7dd2 100644
--- a/include/ndn-cpp/security/certificate/certificate-extension.hpp
+++ b/include/ndn-cpp/security/certificate-extension.hpp
@@ -9,9 +9,9 @@
#ifndef NDN_CERTIFICATE_EXTENSION_HPP
#define NDN_CERTIFICATE_EXTENSION_HPP
-#include "../../common.hpp"
-#include "../../encoding/buffer.hpp"
-#include "../../encoding/oid.hpp"
+#include "../common.hpp"
+#include "../encoding/buffer.hpp"
+#include "../encoding/oid.hpp"
namespace CryptoPP { class BufferedTransformation; }
diff --git a/include/ndn-cpp/security/certificate/certificate-subject-description.hpp b/include/ndn-cpp/security/certificate-subject-description.hpp
similarity index 95%
rename from include/ndn-cpp/security/certificate/certificate-subject-description.hpp
rename to include/ndn-cpp/security/certificate-subject-description.hpp
index 5717920..fc26d37 100644
--- a/include/ndn-cpp/security/certificate/certificate-subject-description.hpp
+++ b/include/ndn-cpp/security/certificate-subject-description.hpp
@@ -9,8 +9,8 @@
#ifndef NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
#define NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
-#include "../../common.hpp"
-#include "../../encoding/oid.hpp"
+#include "../common.hpp"
+#include "../encoding/oid.hpp"
namespace CryptoPP { class BufferedTransformation; }
diff --git a/include/ndn-cpp/security/certificate/certificate.hpp b/include/ndn-cpp/security/certificate.hpp
similarity index 98%
rename from include/ndn-cpp/security/certificate/certificate.hpp
rename to include/ndn-cpp/security/certificate.hpp
index c2fd95a..9871733 100644
--- a/include/ndn-cpp/security/certificate/certificate.hpp
+++ b/include/ndn-cpp/security/certificate.hpp
@@ -9,8 +9,8 @@
#ifndef NDN_CERTIFICATE_HPP
#define NDN_CERTIFICATE_HPP
-#include "../../data.hpp"
-#include "../../common.hpp"
+#include "../data.hpp"
+#include "../common.hpp"
#include "certificate-subject-description.hpp"
#include "certificate-extension.hpp"
diff --git a/include/ndn-cpp/security/encryption/encryption-manager.hpp b/include/ndn-cpp/security/encryption-manager.hpp
similarity index 100%
rename from include/ndn-cpp/security/encryption/encryption-manager.hpp
rename to include/ndn-cpp/security/encryption-manager.hpp
diff --git a/include/ndn-cpp/security/certificate/identity-certificate.hpp b/include/ndn-cpp/security/identity-certificate.hpp
similarity index 100%
rename from include/ndn-cpp/security/certificate/identity-certificate.hpp
rename to include/ndn-cpp/security/identity-certificate.hpp
diff --git a/include/ndn-cpp/security/key-chain.hpp b/include/ndn-cpp/security/key-chain.hpp
index 9eb0b13..8e1e81c 100644
--- a/include/ndn-cpp/security/key-chain.hpp
+++ b/include/ndn-cpp/security/key-chain.hpp
@@ -9,14 +9,14 @@
#ifndef NDN_KEY_CHAIN_HPP
#define NDN_KEY_CHAIN_HPP
-#include "certificate/identity-certificate.hpp"
-#include "certificate/public-key.hpp"
-#include "signature/signature-sha256-with-rsa.hpp"
+#include "identity-certificate.hpp"
+#include "public-key.hpp"
+#include "signature-sha256-with-rsa.hpp"
-#include "identity/sec-public-info-sqlite3.hpp"
-#include "identity/sec-public-info-memory.hpp"
-#include "identity/sec-tpm-osx.hpp"
-#include "identity/sec-tpm-memory.hpp"
+#include "sec-public-info-sqlite3.hpp"
+#include "sec-public-info-memory.hpp"
+#include "sec-tpm-osx.hpp"
+#include "sec-tpm-memory.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/certificate/public-key.hpp b/include/ndn-cpp/security/public-key.hpp
similarity index 94%
rename from include/ndn-cpp/security/certificate/public-key.hpp
rename to include/ndn-cpp/security/public-key.hpp
index ed0687a..5a70e38 100644
--- a/include/ndn-cpp/security/certificate/public-key.hpp
+++ b/include/ndn-cpp/security/public-key.hpp
@@ -10,9 +10,9 @@
#define NDN_PUBLIC_KEY_HPP
#include <stdexcept>
-#include "../../encoding/oid.hpp"
-#include "../../encoding/buffer.hpp"
-#include "../security-common.hpp"
+#include "../encoding/oid.hpp"
+#include "../encoding/buffer.hpp"
+#include "security-common.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/policy/no-verify-policy-manager.hpp b/include/ndn-cpp/security/sec-policy-no-verify.hpp
similarity index 90%
rename from include/ndn-cpp/security/policy/no-verify-policy-manager.hpp
rename to include/ndn-cpp/security/sec-policy-no-verify.hpp
index 1ee9f75..1d2927e 100644
--- a/include/ndn-cpp/security/policy/no-verify-policy-manager.hpp
+++ b/include/ndn-cpp/security/sec-policy-no-verify.hpp
@@ -6,20 +6,20 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_NO_VERIFY_POLICY_MANAGER_HPP
-#define NDN_NO_VERIFY_POLICY_MANAGER_HPP
+#ifndef NDN_SEC_POLICY_NO_VERIFY_HPP
+#define NDN_SEC_POLICY_NO_VERIFY_HPP
-#include "policy-manager.hpp"
+#include "sec-policy.hpp"
namespace ndn {
-class NoVerifyPolicyManager : public PolicyManager {
+class SecPolicyNoVerify : public SecPolicy {
public:
/**
* The virtual destructor.
*/
virtual
- ~NoVerifyPolicyManager();
+ ~SecPolicyNoVerify();
/**
* Override to always skip verification and trust as valid.
diff --git a/include/ndn-cpp/security/policy/self-verify-policy-manager.hpp b/include/ndn-cpp/security/sec-policy-self-verify.hpp
similarity index 79%
rename from include/ndn-cpp/security/policy/self-verify-policy-manager.hpp
rename to include/ndn-cpp/security/sec-policy-self-verify.hpp
index 14da3c1..111b61a 100644
--- a/include/ndn-cpp/security/policy/self-verify-policy-manager.hpp
+++ b/include/ndn-cpp/security/sec-policy-self-verify.hpp
@@ -5,31 +5,28 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SELF_VERIFY_POLICY_MANAGER_HPP
-#define NDN_SELF_VERIFY_POLICY_MANAGER_HPP
+#ifndef NDN_SEC_POLICY_SELF_VERIFY_HPP
+#define NDN_SEC_POLICY_SELF_VERIFY_HPP
-#include "policy-manager.hpp"
+#include "sec-policy.hpp"
namespace ndn {
-class IdentityManager;
-
/**
- * A SelfVerifyPolicyManager implements a PolicyManager to use the public key DER in the data packet's KeyLocator (if available)
+ * A SecPolicySelfVerify implements a PolicyManager to use the public key DER in the data packet's KeyLocator (if available)
* or look in the IdentityStorage for the public key with the name in the KeyLocator (if available) and use
* it to verify the data packet, without searching a certificate chain. If the public key can't be found, the
* verification fails.
*/
-class SelfVerifyPolicyManager : public PolicyManager {
+class SecPolicySelfVerify : public SecPolicy {
public:
/**
- * Create a new SelfVerifyPolicyManager which will look up the public key in the given identityManager.
+ * Create a new SecPolicySelfVerify which will look up the public key in the given identityManager.
* @param identityManager (optional) The IdentityManager for looking up the public key. This points to an object must which remain
- * valid during the life of this SelfVerifyPolicyManager. If omitted, then don't look for a public key with the name
+ * valid during the life of this SecPolicySelfVerify. If omitted, then don't look for a public key with the name
* in the KeyLocator and rely on the KeyLocator having the full public key DER.
*/
- SelfVerifyPolicyManager(IdentityStorage* identityStorage = 0)
- : identityStorage_(identityStorage)
+ SecPolicySelfVerify()
{
}
@@ -37,7 +34,7 @@
* The virtual destructor.
*/
virtual
- ~SelfVerifyPolicyManager();
+ ~SecPolicySelfVerify();
/**
* Never skip verification.
@@ -87,8 +84,6 @@
virtual Name
inferSigningIdentity(const Name& dataName);
-private:
- IdentityStorage* identityStorage_;
};
}
diff --git a/include/ndn-cpp/security/policy/policy-manager.hpp b/include/ndn-cpp/security/sec-policy.hpp
similarity index 87%
rename from include/ndn-cpp/security/policy/policy-manager.hpp
rename to include/ndn-cpp/security/sec-policy.hpp
index 400360d..e3879bb 100644
--- a/include/ndn-cpp/security/policy/policy-manager.hpp
+++ b/include/ndn-cpp/security/sec-policy.hpp
@@ -6,21 +6,19 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_POLICY_MANAGER_HPP
-#define NDN_POLICY_MANAGER_HPP
+#ifndef NDN_SEC_POLICY_HPP
+#define NDN_SEC_POLICY_HPP
-#include "../../data.hpp"
+#include "../data.hpp"
#include "validation-request.hpp"
namespace ndn {
-
-class ValidationRequest;
/**
- * A PolicyManager is an abstract base class to represent the policy for verifying data packets.
+ * A SecPolicy is an abstract base class to represent the policy for verifying data packets.
* You must create an object of a subclass.
*/
-class PolicyManager {
+class SecPolicy {
public:
struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
@@ -28,7 +26,7 @@
* The virtual destructor.
*/
virtual
- ~PolicyManager() {}
+ ~SecPolicy() {}
/**
* Check if the received data packet can escape from verification and be trusted as valid.
@@ -39,7 +37,7 @@
skipVerifyAndTrust(const Data& data) = 0;
/**
- * Check if this PolicyManager has a verification rule for the received data.
+ * Check if this SecPolicy has a verification rule for the received data.
* @param data The received data packet.
* @return true if the data must be verified, otherwise false.
*/
diff --git a/include/ndn-cpp/security/identity/sec-public-info-memory.hpp b/include/ndn-cpp/security/sec-public-info-memory.hpp
similarity index 100%
rename from include/ndn-cpp/security/identity/sec-public-info-memory.hpp
rename to include/ndn-cpp/security/sec-public-info-memory.hpp
diff --git a/include/ndn-cpp/security/identity/sec-public-info-sqlite3.hpp b/include/ndn-cpp/security/sec-public-info-sqlite3.hpp
similarity index 99%
rename from include/ndn-cpp/security/identity/sec-public-info-sqlite3.hpp
rename to include/ndn-cpp/security/sec-public-info-sqlite3.hpp
index 99dac54..89ffe6e 100644
--- a/include/ndn-cpp/security/identity/sec-public-info-sqlite3.hpp
+++ b/include/ndn-cpp/security/sec-public-info-sqlite3.hpp
@@ -14,7 +14,7 @@
#ifdef NDN_CPP_HAVE_SQLITE3
#include <sqlite3.h>
-#include "../../common.hpp"
+#include "../common.hpp"
#include "sec-public-info.hpp"
namespace ndn
diff --git a/include/ndn-cpp/security/identity/sec-public-info.hpp b/include/ndn-cpp/security/sec-public-info.hpp
similarity index 98%
rename from include/ndn-cpp/security/identity/sec-public-info.hpp
rename to include/ndn-cpp/security/sec-public-info.hpp
index 961cf95..7cd7230 100644
--- a/include/ndn-cpp/security/identity/sec-public-info.hpp
+++ b/include/ndn-cpp/security/sec-public-info.hpp
@@ -9,10 +9,10 @@
#ifndef NDN_SEC_PUBLIC_INFO_HPP
#define NDN_SEC_PUBLIC_INFO_HPP
-#include "../../name.hpp"
-#include "../security-common.hpp"
-#include "../certificate/public-key.hpp"
-#include "../certificate/identity-certificate.hpp"
+#include "../name.hpp"
+#include "security-common.hpp"
+#include "public-key.hpp"
+#include "identity-certificate.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/identity/sec-tpm-memory.hpp b/include/ndn-cpp/security/sec-tpm-memory.hpp
similarity index 100%
rename from include/ndn-cpp/security/identity/sec-tpm-memory.hpp
rename to include/ndn-cpp/security/sec-tpm-memory.hpp
diff --git a/include/ndn-cpp/security/identity/sec-tpm-osx.hpp b/include/ndn-cpp/security/sec-tpm-osx.hpp
similarity index 98%
rename from include/ndn-cpp/security/identity/sec-tpm-osx.hpp
rename to include/ndn-cpp/security/sec-tpm-osx.hpp
index 0b90fd0..71efa13 100644
--- a/include/ndn-cpp/security/identity/sec-tpm-osx.hpp
+++ b/include/ndn-cpp/security/sec-tpm-osx.hpp
@@ -12,7 +12,7 @@
#include <ndn-cpp/ndn-cpp-config.h>
#if NDN_CPP_HAVE_OSX_SECURITY
-#include "../../common.hpp"
+#include "../common.hpp"
#include "sec-tpm.hpp"
namespace ndn
diff --git a/include/ndn-cpp/security/identity/sec-tpm.hpp b/include/ndn-cpp/security/sec-tpm.hpp
similarity index 95%
rename from include/ndn-cpp/security/identity/sec-tpm.hpp
rename to include/ndn-cpp/security/sec-tpm.hpp
index 9452f9f..d7a8e04 100644
--- a/include/ndn-cpp/security/identity/sec-tpm.hpp
+++ b/include/ndn-cpp/security/sec-tpm.hpp
@@ -10,10 +10,10 @@
#define NDN_SEC_TPM_HPP
#include <string>
-#include "../security-common.hpp"
-#include "../../name.hpp"
-#include "../../data.hpp"
-#include "../certificate/public-key.hpp"
+#include "security-common.hpp"
+#include "../name.hpp"
+#include "../data.hpp"
+#include "public-key.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/signature/sha256-with-rsa-handler.hpp b/include/ndn-cpp/security/sha256-with-rsa-handler.hpp
similarity index 100%
rename from include/ndn-cpp/security/signature/sha256-with-rsa-handler.hpp
rename to include/ndn-cpp/security/sha256-with-rsa-handler.hpp
diff --git a/include/ndn-cpp/security/signature/signature-sha256-with-rsa.hpp b/include/ndn-cpp/security/signature-sha256-with-rsa.hpp
similarity index 97%
rename from include/ndn-cpp/security/signature/signature-sha256-with-rsa.hpp
rename to include/ndn-cpp/security/signature-sha256-with-rsa.hpp
index a24e94b..8eb26b1 100644
--- a/include/ndn-cpp/security/signature/signature-sha256-with-rsa.hpp
+++ b/include/ndn-cpp/security/signature-sha256-with-rsa.hpp
@@ -8,7 +8,7 @@
#ifndef NDN_SIGNATURE_SHA256_WITH_RSA_HPP
#define NDN_SIGNATURE_SHA256_WITH_RSA_HPP
-#include "../../data.hpp"
+#include "../data.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/policy/validation-request.hpp b/include/ndn-cpp/security/validation-request.hpp
similarity index 97%
rename from include/ndn-cpp/security/policy/validation-request.hpp
rename to include/ndn-cpp/security/validation-request.hpp
index 69a1079..7471065 100644
--- a/include/ndn-cpp/security/policy/validation-request.hpp
+++ b/include/ndn-cpp/security/validation-request.hpp
@@ -9,7 +9,7 @@
#ifndef NDN_VALIDATION_REQUEST_HPP
#define NDN_VALIDATION_REQUEST_HPP
-#include "../../interest.hpp"
+#include "../interest.hpp"
namespace ndn {
diff --git a/include/ndn-cpp/security/verifier.hpp b/include/ndn-cpp/security/verifier.hpp
index 537e74d..764dcd4 100644
--- a/include/ndn-cpp/security/verifier.hpp
+++ b/include/ndn-cpp/security/verifier.hpp
@@ -11,13 +11,12 @@
#include "../data.hpp"
#include "../face.hpp"
-#include "policy/validation-request.hpp"
-#include "certificate/public-key.hpp"
-#include "signature/signature-sha256-with-rsa.hpp"
+#include "sec-policy.hpp"
+#include "validation-request.hpp"
+#include "public-key.hpp"
+#include "signature-sha256-with-rsa.hpp"
namespace ndn {
-
-class PolicyManager;
/**
* Verifier is one of the main classes of the security librar .
@@ -28,7 +27,7 @@
public:
struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
- Verifier(const ptr_lib::shared_ptr<PolicyManager> &policyManager = DefaultPolicyManager);
+ Verifier(const ptr_lib::shared_ptr<SecPolicy> &policy = DefaultPolicy);
/**
* @brief Set the Face which will be used to fetch required certificates.
@@ -40,16 +39,16 @@
setFace(const ptr_lib::shared_ptr<Face> &face) { face_ = face; }
/**
- * @brief Get the policyManager.
- * @return The PolicyManager.
+ * @brief Get the policy.
+ * @return The Policy.
*/
- inline PolicyManager&
+ inline SecPolicy&
policies()
{
- if (!policyManager_)
- throw Error("PolicyManager is not assigned to the KeyChain");
+ if (!policy_)
+ throw Error("policy is not assigned to the KeyChain");
- return *policyManager_;
+ return *policy_;
}
@@ -81,7 +80,7 @@
verifySignature(const Buffer &data, const SignatureSha256WithRsa &sig, const PublicKey &publicKey);
public:
- static const ptr_lib::shared_ptr<PolicyManager> DefaultPolicyManager;
+ static const ptr_lib::shared_ptr<SecPolicy> DefaultPolicy;
private:
void
@@ -94,7 +93,7 @@
const ptr_lib::shared_ptr<Data> &data, ptr_lib::shared_ptr<ValidationRequest> nextStep);
private:
- ptr_lib::shared_ptr<PolicyManager> policyManager_;
+ ptr_lib::shared_ptr<SecPolicy> policy_;
ptr_lib::shared_ptr<Face> face_;
};