bug+codestyle: Fix compile bugs and adjust code style
Change-Id: I008bb538441c099fa25b8b967fbf23ffce13a220
diff --git a/src/endorse-certificate.cpp b/src/endorse-certificate.cpp
index faa0972..8fc8dec 100644
--- a/src/endorse-certificate.cpp
+++ b/src/endorse-certificate.cpp
@@ -8,33 +8,41 @@
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
*/
-#include "endorse-certificate.h"
+#include "endorse-certificate.hpp"
#include "endorse-extension.pb.h"
#include <boost/iostreams/stream.hpp>
+#include <ndn-cxx/encoding/buffer-stream.hpp>
-using namespace ndn;
+namespace chronos {
-namespace chronos{
+using std::vector;
+using std::string;
+
+using ndn::PublicKey;
+using ndn::IdentityCertificate;
+using ndn::CertificateSubjectDescription;
+using ndn::CertificateExtension;
+using ndn::OID;
+using ndn::OBufferStream;
const OID EndorseCertificate::PROFILE_EXT_OID("1.3.6.1.5.32.2.1");
const OID EndorseCertificate::ENDORSE_EXT_OID("1.3.6.1.5.32.2.2");
-const std::vector<std::string> EndorseCertificate::DEFAULT_ENDORSE_LIST = std::vector<std::string>();
+const vector<string> EndorseCertificate::DEFAULT_ENDORSE_LIST;
Chronos::EndorseExtensionMsg&
-operator << (Chronos::EndorseExtensionMsg& endorseExtension, const std::vector<std::string>& endorseList)
+operator<<(Chronos::EndorseExtensionMsg& endorseExtension, const vector<string>& endorseList)
{
- std::vector<std::string>::const_iterator it = endorseList.begin();
- for(; it != endorseList.end(); it++)
+ for (vector<string>::const_iterator it = endorseList.begin(); it != endorseList.end(); it++)
endorseExtension.add_endorseentry()->set_name(*it);
return endorseExtension;
}
Chronos::EndorseExtensionMsg&
-operator >> (Chronos::EndorseExtensionMsg& endorseExtension, std::vector<std::string>& endorseList)
+operator>>(Chronos::EndorseExtensionMsg& endorseExtension, vector<string>& endorseList)
{
- for(int i = 0; i < endorseExtension.endorseentry_size(); i ++)
+ for (int i = 0; i < endorseExtension.endorseentry_size(); i ++)
endorseList.push_back(endorseExtension.endorseentry(i).name());
return endorseExtension;
@@ -42,7 +50,7 @@
EndorseCertificate::EndorseCertificate(const IdentityCertificate& kskCertificate,
const Profile& profile,
- const std::vector<std::string>& endorseList)
+ const vector<string>& endorseList)
: Certificate()
, m_profile(profile)
, m_endorseList(endorseList)
@@ -56,7 +64,7 @@
setNotBefore(kskCertificate.getNotBefore());
setNotAfter(kskCertificate.getNotAfter());
- addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
+ addSubjectDescription(CertificateSubjectDescription(OID("2.5.4.41"), m_keyName.toUri()));
setPublicKeyInfo(kskCertificate.getPublicKeyInfo());
OBufferStream profileStream;
@@ -74,7 +82,7 @@
EndorseCertificate::EndorseCertificate(const EndorseCertificate& endorseCertificate,
const Name& signer,
- const std::vector<std::string>& endorseList)
+ const vector<string>& endorseList)
: Certificate()
, m_keyName(endorseCertificate.m_keyName)
, m_signer(signer)
@@ -87,7 +95,7 @@
setNotBefore(endorseCertificate.getNotBefore());
setNotAfter(endorseCertificate.getNotAfter());
- addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
+ addSubjectDescription(CertificateSubjectDescription(OID("2.5.4.41"), m_keyName.toUri()));
setPublicKeyInfo(endorseCertificate.getPublicKeyInfo());
OBufferStream profileStream;
@@ -109,7 +117,7 @@
const time::system_clock::TimePoint& notAfter,
const Name& signer,
const Profile& profile,
- const std::vector<std::string>& endorseList)
+ const vector<string>& endorseList)
: Certificate()
, m_keyName(keyName)
, m_signer(signer)
@@ -122,7 +130,7 @@
setNotBefore(notBefore);
setNotAfter(notAfter);
- addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
+ addSubjectDescription(CertificateSubjectDescription(OID("2.5.4.41"), m_keyName.toUri()));
setPublicKeyInfo(key);
OBufferStream profileStream;
@@ -144,39 +152,37 @@
, m_signer(endorseCertificate.m_signer)
, m_profile(endorseCertificate.m_profile)
, m_endorseList(endorseCertificate.m_endorseList)
-{}
+{
+}
EndorseCertificate::EndorseCertificate(const Data& data)
: Certificate(data)
{
const Name& dataName = data.getName();
- if(dataName.size() < 3 || dataName.get(-3).toEscapedString() != "PROFILE-CERT")
+ if(dataName.size() < 3 || dataName.get(-3).toUri() != "PROFILE-CERT")
throw Error("No PROFILE-CERT component in data name!");
m_keyName = dataName.getPrefix(-3);
m_signer.wireDecode(dataName.get(-2).blockFromValue());
- ExtensionList::iterator it = m_extensionList.begin();
- for(; it != m_extensionList.end(); it++)
- {
- if(PROFILE_EXT_OID == it->getOid())
- {
- boost::iostreams::stream<boost::iostreams::array_source> is
- (reinterpret_cast<const char*>(it->getValue().buf()), it->getValue().size());
- m_profile.decode(is);
- }
- if(ENDORSE_EXT_OID == it->getOid())
- {
- Chronos::EndorseExtensionMsg endorseExtension;
- boost::iostreams::stream<boost::iostreams::array_source> is
- (reinterpret_cast<const char*>(it->getValue().buf()), it->getValue().size());
- endorseExtension.ParseFromIstream(&is);
-
- endorseExtension >> m_endorseList;
- }
+ for (ExtensionList::iterator it = m_extensionList.begin() ; it != m_extensionList.end(); it++) {
+ if (PROFILE_EXT_OID == it->getOid()) {
+ boost::iostreams::stream<boost::iostreams::array_source> is
+ (reinterpret_cast<const char*>(it->getValue().buf()), it->getValue().size());
+ m_profile.decode(is);
}
+ if (ENDORSE_EXT_OID == it->getOid()) {
+ Chronos::EndorseExtensionMsg endorseExtension;
+
+ boost::iostreams::stream<boost::iostreams::array_source> is
+ (reinterpret_cast<const char*>(it->getValue().buf()), it->getValue().size());
+ endorseExtension.ParseFromIstream(&is);
+
+ endorseExtension >> m_endorseList;
+ }
+ }
}
-}//chronos
+} // namespace chronos