security: Make the KeyChain constructor take an IdentityManager.
diff --git a/ndn-cpp/security/key-chain.cpp b/ndn-cpp/security/key-chain.cpp
index fdfc998..8025b68 100644
--- a/ndn-cpp/security/key-chain.cpp
+++ b/ndn-cpp/security/key-chain.cpp
@@ -31,8 +31,8 @@
};
#endif
-KeyChain::KeyChain(const ptr_lib::shared_ptr<IdentityStorage>& identityStorage, const ptr_lib::shared_ptr<PrivateKeyStorage>& privateKeyStorage)
-: identityManager_(identityStorage, privateKeyStorage), face_(0), maxSteps_(100)
+KeyChain::KeyChain(const shared_ptr<IdentityManager>& identityManager)
+: identityManager_(identityManager), face_(0), maxSteps_(100)
{
}
@@ -105,7 +105,7 @@
if (certificateNameIn.getComponentCount() == 0) {
#if 0
- inferredCertificateName = identityManager_.getDefaultCertificateNameForIdentity(policyManager_->inferSigningIdentity(data.getName ()));
+ inferredCertificateName = identityManager_->getDefaultCertificateNameForIdentity(policyManager_->inferSigningIdentity(data.getName ()));
#else
inferredCertificateName = Name();
#endif
@@ -122,7 +122,7 @@
throw SecurityException("Signing Cert name does not comply with signing policy");
#endif
- identityManager_.signByCertificate(data, *certificateName, wireFormat);
+ identityManager_->signByCertificate(data, *certificateName, wireFormat);
}
void
diff --git a/ndn-cpp/security/key-chain.hpp b/ndn-cpp/security/key-chain.hpp
index d0357ef..ecddf67 100644
--- a/ndn-cpp/security/key-chain.hpp
+++ b/ndn-cpp/security/key-chain.hpp
@@ -31,7 +31,7 @@
*/
class KeyChain {
public:
- KeyChain(const ptr_lib::shared_ptr<IdentityStorage>& identityStorage, const ptr_lib::shared_ptr<PrivateKeyStorage>& privateKeyStorage);
+ KeyChain(const ptr_lib::shared_ptr<IdentityManager>& identityManager);
/**
* Get the default certificate name for the specified identity, which will be used when signing is performed based on identity.
@@ -41,7 +41,7 @@
Name
getDefaultCertificateNameForIdentity(const Name& identityName)
{
- return identityManager_.getDefaultCertificateNameForIdentity(identityName);
+ return identityManager_->getDefaultCertificateNameForIdentity(identityName);
}
/**
@@ -88,7 +88,7 @@
setFace(Face* face) { face_ = face; }
private:
- IdentityManager identityManager_;
+ ptr_lib::shared_ptr<IdentityManager> identityManager_;
Face* face_;
const int maxSteps_;
};
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 5e09399..452afbe 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -239,7 +239,7 @@
shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(identityStorage, privateKeyStorage);
+ KeyChain keyChain(shared_ptr<IdentityManager>(new IdentityManager(identityStorage, privateKeyStorage)));
// Initialize the storage.
Name keyName("/testname/DSK-123");
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index 72dec4b..749c7c1 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -108,7 +108,7 @@
shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(identityStorage, privateKeyStorage);
+ KeyChain keyChain(shared_ptr<IdentityManager>(new IdentityManager(identityStorage, privateKeyStorage)));
keyChain.setFace(&face);
// Initialize the storage.