security: Change to use IdentityCertificate instead of Certificate where needed.
diff --git a/include/ndn-cpp/security/identity/basic-identity-storage.hpp b/include/ndn-cpp/security/identity/basic-identity-storage.hpp
index 2e0db30..ee1a886 100644
--- a/include/ndn-cpp/security/identity/basic-identity-storage.hpp
+++ b/include/ndn-cpp/security/identity/basic-identity-storage.hpp
@@ -123,14 +123,14 @@
* @param certificate The certificate to be added.
*/
void
- addAnyCertificate (const Certificate& certificate);
+ addAnyCertificate (const IdentityCertificate& certificate);
/**
* Add a certificate to the identity storage.
- * @param certificate The certificate to be added.
+ * @param certificate The certificate to be added. This makes a copy of the certificate.
*/
virtual void
- addCertificate(const Certificate& certificate);
+ addCertificate(const IdentityCertificate& certificate);
/**
* Get a certificate from the identity storage.
diff --git a/include/ndn-cpp/security/identity/identity-manager.hpp b/include/ndn-cpp/security/identity/identity-manager.hpp
index 2dd9b6e..d461062 100644
--- a/include/ndn-cpp/security/identity/identity-manager.hpp
+++ b/include/ndn-cpp/security/identity/identity-manager.hpp
@@ -7,13 +7,16 @@
*/
#ifndef NDN_IDENTITY_MANAGER_HPP
-#define NDN_IDENTITY_MANAGER_HPP
+#define NDN_IDENTITY_MANAGER_HPP
-#include "../certificate/certificate.hpp"
+#include "../certificate/identity-certificate.hpp"
#include "identity-storage.hpp"
#include "../certificate/public-key.hpp"
#include "private-key-storage.hpp"
+// TODO: Implement Time values.
+class Time;
+
namespace ndn {
/**
@@ -98,11 +101,35 @@
}
/**
+ * Create an identity certificate for a public key managed by this IdentityManager.
+ * @param keyName The name of public key to be signed.
+ * @param signerCertificateName The name of signing certificate.
+ * @param notBefore The notBefore value in the validity field of the generated certificate.
+ * @param notAfter The notAfter vallue in validity field of the generated certificate.
+ * @return The name of generated identity certificate.
+ */
+ Name
+ createIdentityCertificate(const Name& keyName, const Name& signerCertificateName, const Time& notBefore, const Time& notAfter);
+
+ /**
+ * Create an identity certificate for a public key supplied by the caller.
+ * @param keyName The name of public key to be signed.
+ * @param publickey The public key to be signed.
+ * @param signerCertificateName The name of signing certificate.
+ * @param notBefore The notBefore value in the validity field of the generated certificate.
+ * @param notAfter The notAfter vallue in validity field of the generated certificate.
+ * @return The generated identity certificate.
+ */
+ ptr_lib::shared_ptr<IdentityCertificate>
+ createIdentityCertificate
+ (const Name& keyName, const PublicKey& publickey, const Name& signerCertificateName, const Time& notBefore, const Time& notAfter);
+
+ /**
* Add a certificate into the public key identity storage.
- * @param certificate The certificate to to added.
+ * @param certificate The certificate to to added. This makes a copy of the certificate.
*/
void
- addCertificate(const Certificate& certificate)
+ addCertificate(const IdentityCertificate& certificate)
{
identityStorage_->addCertificate(certificate);
}
@@ -116,27 +143,27 @@
/**
* Add a certificate into the public key identity storage and set the certificate as the default for its corresponding identity.
- * @param certificate The certificate to be added.
+ * @param certificate The certificate to be added. This makes a copy of the certificate.
*/
void
- addCertificateAsIdentityDefault(const Certificate& certificate);
+ addCertificateAsIdentityDefault(const IdentityCertificate& certificate);
/**
* Add a certificate into the public key identity storage and set the certificate as the default of its corresponding key.
- * certificate the certificate to be added
+ * @param certificate The certificate to be added. This makes a copy of the certificate.
*/
void
- addCertificateAsDefault(const Certificate& certificate);
+ addCertificateAsDefault(const IdentityCertificate& certificate);
/**
* Get a certificate with the specified name.
* @param certificateName The name of the requested certificate.
* @return the requested certificate which is valid.
*/
- ptr_lib::shared_ptr<Certificate>
+ ptr_lib::shared_ptr<IdentityCertificate>
getCertificate(const Name& certificateName)
{
- return identityStorage_->getCertificate(certificateName, false);
+ return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, false));
}
/**
@@ -144,10 +171,10 @@
* @param certificateName The name of the requested certificate.
* @return the requested certificate.
*/
- ptr_lib::shared_ptr<Certificate>
+ ptr_lib::shared_ptr<IdentityCertificate>
getAnyCertificate(const Name& certificateName)
{
- return identityStorage_->getCertificate(certificateName, true);
+ return ptr_lib::make_shared<IdentityCertificate>(*identityStorage_->getCertificate(certificateName, true));
}
/**
@@ -172,16 +199,15 @@
return identityStorage_->getDefaultCertificateNameForIdentity(getDefaultIdentity());
}
-#if 0
/**
- * sign blob based on certificate name
- * @param blob the blob to be signed
- * @param certificateName the signing certificate name
- * @return the generated signature
+ * Sign the byte array data based on the certificate name.
+ * @param data The data to be signed.
+ * @param dataLength the length of data.
+ * @param certificateName The signing certificate name.
+ * @return The generated signature.
*/
- Ptr<Signature>
- signByCertificate(const Blob& blob, const Name& certificateName);
-#endif
+ ptr_lib::shared_ptr<Signature>
+ signByCertificate(const uint8_t* data, size_t dataLength, const Name& certificateName);
/**
* Sign data packet based on the certificate name.
@@ -211,7 +237,7 @@
* @param keyName The name of the public key.
* @return The generated certificate.
*/
- ptr_lib::shared_ptr<Certificate>
+ ptr_lib::shared_ptr<IdentityCertificate>
selfSign(const Name& keyName);
ptr_lib::shared_ptr<IdentityStorage> identityStorage_;
diff --git a/include/ndn-cpp/security/identity/identity-storage.hpp b/include/ndn-cpp/security/identity/identity-storage.hpp
index db6ab0e..d514dc8 100644
--- a/include/ndn-cpp/security/identity/identity-storage.hpp
+++ b/include/ndn-cpp/security/identity/identity-storage.hpp
@@ -15,6 +15,7 @@
namespace ndn {
class Certificate;
+class IdentityCertificate;
class Data;
/**
@@ -117,10 +118,10 @@
/**
* Add a certificate to the identity storage.
- * @param certificate The certificate to be added.
+ * @param certificate The certificate to be added. This makes a copy of the certificate.
*/
virtual void
- addCertificate(const Certificate& certificate) = 0;
+ addCertificate(const IdentityCertificate& certificate) = 0;
/**
* Get a certificate from the identity storage.
diff --git a/include/ndn-cpp/security/identity/memory-identity-storage.hpp b/include/ndn-cpp/security/identity/memory-identity-storage.hpp
index ba0ea5a..cf8f318 100644
--- a/include/ndn-cpp/security/identity/memory-identity-storage.hpp
+++ b/include/ndn-cpp/security/identity/memory-identity-storage.hpp
@@ -113,10 +113,10 @@
/**
* Add a certificate to the identity storage.
- * @param certificate The certificate to be added.
+ * @param certificate The certificate to be added. This makes a copy of the certificate.
*/
virtual void
- addCertificate(const Certificate& certificate);
+ addCertificate(const IdentityCertificate& certificate);
/**
* Get a certificate from the identity storage.