face: Specify signing certificate/identity in setInterestFilter/unsetInterestFilter

Refs: #1509

Change-Id: I359553e5f8eb77ae314873852eba8a10fb5e3a93
diff --git a/src/face.cpp b/src/face.cpp
index 4a5d5b8..d351c0a 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -235,6 +235,42 @@
   return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
 }
 
+const RegisteredPrefixId*
+Face::setInterestFilter(const Name& prefix,
+                        const OnInterest& onInterest,
+                        const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                        const IdentityCertificate& certificate)
+{
+  shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest));
+
+  m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(),
+                                     bind(&RegisteredPrefixTable::push_back,
+                                          &m_registeredPrefixTable, prefixToRegister),
+                                     bind(onSetInterestFilterFailed,
+                                          prefixToRegister->getPrefix(), _1),
+                                     certificate);
+
+  return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
+}
+
+const RegisteredPrefixId*
+Face::setInterestFilter(const Name& prefix,
+                        const OnInterest& onInterest,
+                        const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                        const Name& identity)
+{
+  shared_ptr<RegisteredPrefix> prefixToRegister(new RegisteredPrefix(prefix, onInterest));
+
+  m_fwController->selfRegisterPrefix(prefixToRegister->getPrefix(),
+                                     bind(&RegisteredPrefixTable::push_back,
+                                          &m_registeredPrefixTable, prefixToRegister),
+                                     bind(onSetInterestFilterFailed,
+                                          prefixToRegister->getPrefix(), _1),
+                                     identity);
+
+  return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get());
+}
+
 void
 Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
 {
@@ -242,6 +278,22 @@
 }
 
 void
+Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                          const IdentityCertificate& certificate)
+{
+  m_ioService->post(bind(&Face::asyncUnsetInterestFilterWithCertificate, this,
+                         registeredPrefixId, certificate));
+}
+
+void
+Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                          const Name& identity)
+{
+  m_ioService->post(bind(&Face::asyncUnsetInterestFilterWithIdentity, this,
+                         registeredPrefixId, identity));
+}
+
+void
 Face::asyncUnsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
 {
   RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
@@ -258,6 +310,42 @@
 }
 
 void
+Face::asyncUnsetInterestFilterWithCertificate(const RegisteredPrefixId* registeredPrefixId,
+                                              const IdentityCertificate& certificate)
+{
+  RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
+                                                   m_registeredPrefixTable.end(),
+                                                   MatchRegisteredPrefixId(registeredPrefixId));
+  if (i != m_registeredPrefixTable.end())
+    {
+      m_fwController->selfDeregisterPrefix((*i)->getPrefix(),
+                                           bind(&Face::finalizeUnsetInterestFilter, this, i),
+                                           Controller::FailCallback(),
+                                           certificate);
+    }
+
+  // there cannot be two registered prefixes with the same id
+}
+
+void
+Face::asyncUnsetInterestFilterWithIdentity(const RegisteredPrefixId* registeredPrefixId,
+                                           const Name& identity)
+{
+  RegisteredPrefixTable::iterator i = std::find_if(m_registeredPrefixTable.begin(),
+                                                   m_registeredPrefixTable.end(),
+                                                   MatchRegisteredPrefixId(registeredPrefixId));
+  if (i != m_registeredPrefixTable.end())
+    {
+      m_fwController->selfDeregisterPrefix((*i)->getPrefix(),
+                                           bind(&Face::finalizeUnsetInterestFilter, this, i),
+                                           Controller::FailCallback(),
+                                           identity);
+    }
+
+  // there cannot be two registered prefixes with the same id
+}
+
+void
 Face::finalizeUnsetInterestFilter(RegisteredPrefixTable::iterator item)
 {
   m_registeredPrefixTable.erase(item);
diff --git a/src/face.hpp b/src/face.hpp
index 185927b..48f253e 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -211,8 +211,6 @@
    *                         onRegisterFailed(prefix) where prefix is the prefix given to
    *                         registerPrefix.
    *
-   * @param flags      The flags for finer control of which interests are forward to the
-   *                   application.
    * @return The registered prefix ID which can be used with removeRegisteredPrefix.
    */
   const RegisteredPrefixId*
@@ -221,6 +219,52 @@
                     const OnSetInterestFilterFailed& onSetInterestFilterFailed);
 
   /**
+   * @brief Register prefix with the connected NDN hub and call onInterest when a matching
+   *        interest is received.
+   *
+   * @param prefix     A reference to a Name for the prefix to register
+   * @param onInterest A function object to call when a matching interest is received
+   *
+   * @param onRegisterFailed A function object to call if failed to retrieve the connected
+   *                         hub’s ID or failed to register the prefix.  This calls
+   *                         onRegisterFailed(prefix) where prefix is the prefix given to
+   *                         registerPrefix.
+   *
+   * @param certificate A certificate under which the prefix registration command interest
+   *                    is signed.
+   *
+   * @return The registered prefix ID which can be used with removeRegisteredPrefix.
+   */
+  const RegisteredPrefixId*
+  setInterestFilter(const Name& prefix,
+                    const OnInterest& onInterest,
+                    const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                    const IdentityCertificate& certificate);
+
+  /**
+   * @brief Register prefix with the connected NDN hub and call onInterest when a matching
+   *        interest is received.
+   *
+   * @param prefix     A reference to a Name for the prefix to register
+   * @param onInterest A function object to call when a matching interest is received
+   *
+   * @param onRegisterFailed A function object to call if failed to retrieve the connected
+   *                         hub’s ID or failed to register the prefix.  This calls
+   *                         onRegisterFailed(prefix) where prefix is the prefix given to
+   *                         registerPrefix.
+   *
+   * @param identity A signing identity. A command interest is signed under the default
+   *                 certificate of this identity.
+   *
+   * @return The registered prefix ID which can be used with removeRegisteredPrefix.
+   */
+  const RegisteredPrefixId*
+  setInterestFilter(const Name& prefix,
+                    const OnInterest& onInterest,
+                    const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                    const Name& identity);
+
+  /**
    * @brief Remove the registered prefix entry with the registeredPrefixId from the
    *        pending interest table.
    *
@@ -233,6 +277,14 @@
   void
   unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
 
+  void
+  unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                      const IdentityCertificate& certificate);
+
+  void
+  unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
+                      const Name& identity);
+
    /**
    * @brief Publish data packet
    *
@@ -334,6 +386,14 @@
   asyncUnsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
 
   void
+  asyncUnsetInterestFilterWithCertificate(const RegisteredPrefixId* registeredPrefixId,
+                                          const IdentityCertificate& certificate);
+
+  void
+  asyncUnsetInterestFilterWithIdentity(const RegisteredPrefixId* registeredPrefixId,
+                                       const Name& identity);
+
+  void
   finalizeUnsetInterestFilter(RegisteredPrefixTable::iterator item);
 
   void
diff --git a/src/management/controller.hpp b/src/management/controller.hpp
index 8ae508e..5c32b3b 100644
--- a/src/management/controller.hpp
+++ b/src/management/controller.hpp
@@ -22,6 +22,7 @@
 
 class Name;
 class Face;
+class IdentityCertificate;
 
 class Controller
 {
@@ -40,9 +41,33 @@
                      const FailCallback&    onFail) = 0;
 
   virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const IdentityCertificate& certificate) = 0;
+
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const Name& identity) = 0;
+
+  virtual void
   selfDeregisterPrefix(const Name& prefixToRegister,
                        const SuccessCallback& onSuccess,
                        const FailCallback&    onFail) = 0;
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const IdentityCertificate& certificate) = 0;
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const Name& identity) = 0;
 };
 
 } // namespace ndn
diff --git a/src/management/ndnd-controller.cpp b/src/management/ndnd-controller.cpp
index c8e97f0..6e917b0 100644
--- a/src/management/ndnd-controller.cpp
+++ b/src/management/ndnd-controller.cpp
@@ -14,6 +14,7 @@
 #include "ndnd-controller.hpp"
 
 #include "../face.hpp"
+#include "../security/identity-certificate.hpp"
 #include "../security/signature-sha256-with-rsa.hpp"
 #include "../util/random.hpp"
 
@@ -51,7 +52,6 @@
                       onFail);
 }
 
-
 void
 Controller::selfDeregisterPrefix(const Name& prefixToRegister,
                                  const SuccessCallback& onSuccess,
diff --git a/src/management/ndnd-controller.hpp b/src/management/ndnd-controller.hpp
index 5d57886..f6de05f 100644
--- a/src/management/ndnd-controller.hpp
+++ b/src/management/ndnd-controller.hpp
@@ -43,10 +43,46 @@
                      const FailCallback&    onFail);
 
   virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const IdentityCertificate& certificate)
+  {
+    selfRegisterPrefix(prefixToRegister, onSuccess, onFail);
+  }
+
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const Name& identity)
+  {
+    selfRegisterPrefix(prefixToRegister, onSuccess, onFail);
+  }
+
+  virtual void
   selfDeregisterPrefix(const Name& prefixToRegister,
                        const SuccessCallback& onSuccess,
                        const FailCallback&    onFail);
 
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const IdentityCertificate& certificate)
+  {
+    selfDeregisterPrefix(prefixToRegister, onSuccess, onFail);
+  }
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const Name& identity)
+  {
+    selfDeregisterPrefix(prefixToRegister, onSuccess, onFail);
+  }
+
 protected:
   void
   startFaceAction(const FaceInstance& entry,
diff --git a/src/management/nfd-control-command.hpp b/src/management/nfd-control-command.hpp
index a78179d..bde5725 100644
--- a/src/management/nfd-control-command.hpp
+++ b/src/management/nfd-control-command.hpp
@@ -25,6 +25,10 @@
 class ControlCommand : noncopyable
 {
 public:
+  /** \brief a callback on signing command interest
+   */
+  typedef function<void(Interest&)> Sign;
+
   /** \brief represents an error in ControlParameters
    */
   class ArgumentError : public std::invalid_argument
@@ -49,14 +53,14 @@
    */
   Interest
   makeCommandInterest(const ControlParameters& parameters,
-                      CommandInterestGenerator& commandInterestGenerator) const
+                      const Sign& sign) const
   {
     this->validateRequest(parameters);
 
     Name name = m_prefix;
     name.append(parameters.wireEncode());
     Interest commandInterest(name);
-    commandInterestGenerator.generate(commandInterest);
+    sign(commandInterest);
     return commandInterest;
   }
 
diff --git a/src/management/nfd-controller.cpp b/src/management/nfd-controller.cpp
index c0c7729..661b08a 100644
--- a/src/management/nfd-controller.cpp
+++ b/src/management/nfd-controller.cpp
@@ -12,6 +12,7 @@
 
 #include "nfd-controller.hpp"
 #include "nfd-control-response.hpp"
+#include "../security/identity-certificate.hpp"
 
 namespace ndn {
 namespace nfd {
@@ -75,7 +76,8 @@
 void
 Controller::selfRegisterPrefix(const Name& prefixToRegister,
                                const SuccessCallback& onSuccess,
-                               const FailCallback& onFail)
+                               const FailCallback& onFail,
+                               const Sign& sign)
 {
   const uint32_t selfFaceId = 0;
 
@@ -85,13 +87,15 @@
 
   this->start<FibAddNextHopCommand>(parameters,
                                     bind(onSuccess),
-                                    bind(onFail, _2));
+                                    bind(onFail, _2),
+                                    sign);
 }
 
 void
 Controller::selfDeregisterPrefix(const Name& prefixToDeRegister,
                                  const SuccessCallback& onSuccess,
-                                 const FailCallback& onFail)
+                                 const FailCallback& onFail,
+                                 const Sign& sign)
 {
   const uint32_t selfFaceId = 0;
 
@@ -101,7 +105,8 @@
 
   this->start<FibRemoveNextHopCommand>(parameters,
                                        bind(onSuccess),
-                                       bind(onFail, _2));
+                                       bind(onFail, _2),
+                                       sign);
 }
 
 } // namespace nfd
diff --git a/src/management/nfd-controller.hpp b/src/management/nfd-controller.hpp
index f9ca999..583be71 100644
--- a/src/management/nfd-controller.hpp
+++ b/src/management/nfd-controller.hpp
@@ -17,6 +17,7 @@
 #include "nfd-control-command.hpp"
 #include "../face.hpp"
 
+
 namespace ndn {
 namespace nfd {
 
@@ -33,6 +34,10 @@
    */
   typedef function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
 
+  /** \brief a callback on signing command interest
+   */
+  typedef function<void(Interest&)> Sign;
+
   explicit
   Controller(Face& face);
 
@@ -43,18 +48,136 @@
   start(const ControlParameters& parameters,
         const CommandSucceedCallback& onSuccess,
         const CommandFailCallback& onFailure,
-        time::milliseconds timeout = getDefaultCommandTimeout());
+        const time::milliseconds& timeout = getDefaultCommandTimeout())
+  {
+    start<Command>(parameters, onSuccess, onFailure,
+                   bind(&CommandInterestGenerator::generate,
+                        &m_commandInterestGenerator, _1,
+                        boost::cref(Name())),
+                   timeout);
+  }
+
+  template<typename Command>
+  void
+  start(const ControlParameters& parameters,
+        const CommandSucceedCallback& onSuccess,
+        const CommandFailCallback& onFailure,
+        const IdentityCertificate& certificate,
+        const time::milliseconds& timeout = getDefaultCommandTimeout())
+  {
+    start<Command>(parameters, onSuccess, onFailure,
+                   bind(&CommandInterestGenerator::generate,
+                        &m_commandInterestGenerator, _1,
+                        boost::cref(certificate.getName())),
+                   timeout);
+  }
+
+  template<typename Command>
+  void
+  start(const ControlParameters& parameters,
+        const CommandSucceedCallback& onSuccess,
+        const CommandFailCallback& onFailure,
+        const Name& identity,
+        const time::milliseconds& timeout = getDefaultCommandTimeout())
+  {
+    start<Command>(parameters, onSuccess, onFailure,
+                   bind(&CommandInterestGenerator::generateWithIdentity,
+                        &m_commandInterestGenerator, _1,
+                        boost::cref(identity)),
+                   timeout);
+  }
 
 public: // selfreg using FIB Management commands
   virtual void
   selfRegisterPrefix(const Name& prefixToRegister,
                      const SuccessCallback& onSuccess,
-                     const FailCallback&    onFail);
+                     const FailCallback&    onFail)
+  {
+    this->selfRegisterPrefix(prefixToRegister, onSuccess, onFail,
+                             bind(&CommandInterestGenerator::generate,
+                                  &m_commandInterestGenerator, _1,
+                                  boost::cref(Name())));
+  }
+
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const IdentityCertificate& certificate)
+  {
+    this->selfRegisterPrefix(prefixToRegister, onSuccess, onFail,
+                             bind(&CommandInterestGenerator::generate,
+                                  &m_commandInterestGenerator, _1,
+                                  boost::cref(certificate.getName())));
+  }
+
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const Name& identity)
+  {
+    this->selfRegisterPrefix(prefixToRegister, onSuccess, onFail,
+                             bind(&CommandInterestGenerator::generateWithIdentity,
+                                  &m_commandInterestGenerator, _1,
+                                  boost::cref(identity)));
+  }
 
   virtual void
   selfDeregisterPrefix(const Name& prefixToDeRegister,
                        const SuccessCallback& onSuccess,
-                       const FailCallback&    onFail);
+                       const FailCallback&    onFail)
+  {
+    this->selfDeregisterPrefix(prefixToDeRegister, onSuccess, onFail,
+                               bind(&CommandInterestGenerator::generate,
+                                    &m_commandInterestGenerator, _1,
+                                    boost::cref(Name())));
+  }
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToDeRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const IdentityCertificate& certificate)
+  {
+    this->selfDeregisterPrefix(prefixToDeRegister, onSuccess, onFail,
+                               bind(&CommandInterestGenerator::generate,
+                                    &m_commandInterestGenerator, _1,
+                                    boost::cref(certificate.getName())));
+  }
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToDeRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const Name& identity)
+  {
+    this->selfDeregisterPrefix(prefixToDeRegister, onSuccess, onFail,
+                               bind(&CommandInterestGenerator::generateWithIdentity,
+                                    &m_commandInterestGenerator, _1,
+                                    boost::cref(identity)));
+  }
+
+protected:
+  template<typename Command>
+  void
+  start(const ControlParameters& parameters,
+        const CommandSucceedCallback& onSuccess,
+        const CommandFailCallback& onFailure,
+        const Sign& sign,
+        const time::milliseconds& timeout = getDefaultCommandTimeout());
+
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const Sign& sign);
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToDeRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const Sign& sign);
 
 private:
   void
@@ -81,13 +204,15 @@
 Controller::start(const ControlParameters& parameters,
                   const CommandSucceedCallback& onSuccess,
                   const CommandFailCallback&    onFailure,
-                  time::milliseconds timeout)
+                  const Sign& sign,
+                  const time::milliseconds& timeout)
 {
   BOOST_ASSERT(timeout > time::milliseconds::zero());
 
   shared_ptr<ControlCommand> command = make_shared<Command>();
 
-  Interest commandInterest = command->makeCommandInterest(parameters, m_commandInterestGenerator);
+  Interest commandInterest = command->makeCommandInterest(parameters, sign);
+
   commandInterest.setInterestLifetime(timeout);
 
   // http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668.aspx
diff --git a/src/management/nrd-controller.cpp b/src/management/nrd-controller.cpp
index 558f056..b023277 100644
--- a/src/management/nrd-controller.cpp
+++ b/src/management/nrd-controller.cpp
@@ -13,6 +13,8 @@
 #include "nrd-controller.hpp"
 #include "nrd-prefix-reg-options.hpp"
 #include "nfd-control-response.hpp" // used in deprecated function only
+#include "../security/identity-certificate.hpp"
+
 
 namespace ndn {
 namespace nrd {
@@ -29,27 +31,31 @@
 void
 Controller::selfRegisterPrefix(const Name& prefixToRegister,
                                const SuccessCallback& onSuccess,
-                               const FailCallback&    onFail)
+                               const FailCallback&    onFail,
+                               const Sign& sign)
 {
   ControlParameters parameters;
   parameters.setName(prefixToRegister);
 
   this->start<RibRegisterCommand>(parameters,
                                   bind(onSuccess),
-                                  bind(onFail, _2));
+                                  bind(onFail, _2),
+                                  sign);
 }
 
 void
 Controller::selfDeregisterPrefix(const Name& prefixToRegister,
                                  const SuccessCallback& onSuccess,
-                                 const FailCallback&    onFail)
+                                 const FailCallback&    onFail,
+                                 const Sign& sign)
 {
   ControlParameters parameters;
   parameters.setName(prefixToRegister);
 
   this->start<RibUnregisterCommand>(parameters,
                                     bind(onSuccess),
-                                    bind(onFail, _2));
+                                    bind(onFail, _2),
+                                    sign);
 }
 
 void
diff --git a/src/management/nrd-controller.hpp b/src/management/nrd-controller.hpp
index 2e94de6..1aba57f 100644
--- a/src/management/nrd-controller.hpp
+++ b/src/management/nrd-controller.hpp
@@ -24,23 +24,16 @@
 class Controller : public nfd::Controller
 {
 public:
+  /** \brief a callback on signing command interest
+   */
+  typedef function<void(Interest&)> Sign;
+
   /// \deprecated
   typedef function<void(const PrefixRegOptions&)> CommandSucceedCallback;
 
   explicit
   Controller(Face& face);
 
-public: // selfreg using RIB Management commands
-  virtual void
-  selfRegisterPrefix(const Name& prefixToRegister,
-                     const SuccessCallback& onSuccess,
-                     const FailCallback&    onFail);
-
-  virtual void
-  selfDeregisterPrefix(const Name& prefixToRegister,
-                       const SuccessCallback& onSuccess,
-                       const FailCallback&    onFail);
-
 public:
   /// \deprecated .start<RibRegisterCommand>
   void
@@ -74,6 +67,19 @@
                const CommandSucceedCallback& onSuccess,
                const FailCallback& onFailure);
 
+  // selfreg using RIB Management commands
+  virtual void
+  selfRegisterPrefix(const Name& prefixToRegister,
+                     const SuccessCallback& onSuccess,
+                     const FailCallback&    onFail,
+                     const Sign& sign);
+
+  virtual void
+  selfDeregisterPrefix(const Name& prefixToDeRegister,
+                       const SuccessCallback& onSuccess,
+                       const FailCallback&    onFail,
+                       const Sign& sign);
+
 private:
   /// \deprecated
   void
diff --git a/src/util/command-interest-generator.hpp b/src/util/command-interest-generator.hpp
index 3698187..0f0f8c7 100644
--- a/src/util/command-interest-generator.hpp
+++ b/src/util/command-interest-generator.hpp
@@ -54,10 +54,10 @@
 
 inline void
 CommandInterestGenerator::generate(Interest& interest,
-				   const Name& certificateName /*= Name()*/)
+                                   const Name& certificateName /*= Name()*/)
 {
   time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
-  while(timestamp <= m_lastTimestamp)
+  while (timestamp <= m_lastTimestamp)
     {
       timestamp += time::milliseconds(1);
     }
@@ -80,7 +80,7 @@
 CommandInterestGenerator::generateWithIdentity(Interest& interest, const Name& identity)
 {
   time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
-  while(timestamp <= m_lastTimestamp)
+  while (timestamp <= m_lastTimestamp)
     {
       timestamp += time::milliseconds(1);
     }