Directory Structuring
diff --git a/src/security/nlsr_km.cpp b/src/security/nlsr_km.cpp
new file mode 100644
index 0000000..69052eb
--- /dev/null
+++ b/src/security/nlsr_km.cpp
@@ -0,0 +1,84 @@
+#include <ndn-cpp-dev/security/identity-certificate.hpp>
+#include <ndn-cpp-dev/encoding/block.hpp>
+#include "nlsr_sm.hpp"
+#include "nlsr_km.hpp"
+
+namespace nlsr
+{
+ void
+ KeyManager::initKeyManager(ConfParameter &cp)
+ {
+ string processIdentityName(cp.getRootKeyPrefix());
+ processIdentityName += "/";
+ processIdentityName += cp.getSiteName();
+ processIdentityName += "/";
+ processIdentityName += "R.Start";
+ processIdentityName += "/";
+ processIdentityName += cp.getRouterName();
+ processIdentityName += "/";
+ processIdentityName += "nlsr";
+ cout<<"Proces Identity Name: "<<processIdentityName<<endl;
+ ndn::Name identityName(processIdentityName);
+ routerIdentity=identityName;
+ ndn::KeyChain::deleteIdentity(routerIdentity);
+ routerCertName = ndn::KeyChain::createIdentity(routerIdentity);
+ cout<<"Certificate Name: "<<routerCertName.toUri()<<endl;
+ routerKeyName=
+ ndn::IdentityCertificate::certificateNameToPublicKeyName(routerCertName);
+ cout<<"Key Name: "<<routerKeyName.toUri()<<endl;
+ initCertSeqFromFile(cp.getSeqFileDir());
+ }
+
+ ndn::Name
+ KeyManager::getRouterCertName()
+ {
+ return routerCertName;
+ }
+
+ uint32_t
+ KeyManager::getCertSeqNo()
+ {
+ return certSeqNo;
+ }
+
+ void
+ KeyManager::setCerSeqNo(uint32_t csn)
+ {
+ certSeqNo=csn;
+ }
+
+ void
+ KeyManager::initCertSeqFromFile(string certSeqFileDir)
+ {
+ certSeqFileNameWithPath=certSeqFileDir;
+ if( certSeqFileNameWithPath.empty() )
+ {
+ SequencingManager sm;
+ certSeqFileNameWithPath=sm.getUserHomeDirectory();
+ }
+ certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
+ cout<<"Key Seq File Name: "<< certSeqFileNameWithPath<<endl;
+ std::ifstream inputFile(certSeqFileNameWithPath.c_str(),ios::binary);
+ if ( inputFile.good() )
+ {
+ inputFile>>certSeqNo;
+ certSeqNo++;
+ }
+ else
+ {
+ certSeqNo=1;
+ }
+ writeCertSeqToFile();
+ }
+
+ void
+ KeyManager::writeCertSeqToFile()
+ {
+ std::ofstream outputFile(certSeqFileNameWithPath.c_str(),ios::binary);
+ outputFile<<certSeqNo;
+ outputFile.close();
+ }
+}
+
+
+