Project

General

Profile

Task #3292

Updated by Qiuhan Ding about 5 years ago

`TrustAnchorContainer` is a member of validator::KeyManager, which manages pre-trusted keys. 

 There are two types of pre trusted keys: `static` which once loaded will stay in the container forever, and `dynamic` which will be refreshed every certain period. 
 Keys The dynamic keys can be reloaded from a file path. When the path points to a file, a key will be loaded from the file; when the path points to a directory, all the keys under the directory will be loaded.  

 TrustAnchors can be searched by key name and interest, name, it can also be searched by group. Each group of dynamic keys are assigned an ID. For example, if all dynamic keys under a directory could be grouped together and share the same ID. 

     class TrustAnchorContainer 
     { 
     public: 
       TrustAnchorContainer(); 

       ~TrustAnchorContainer(); 

       // @brief Insert trust anchor from data packet. 
       void 
       insert(const shared_ptr<Data> idCert, const std::string& id = ""); 

       //@brief Insert trust anchor from path. 
       void 
       insert(bool isDir, bool shouldRefresh, const std::string& certfilePath, 
              const std::string& id = "", 
              const time::nanoseconds& refreshPeriod = 
                  time::duration_cast<time::nanoseconds>(time::seconds(0))); 

       // @brief Get certificate given key name 
       const shared_ptr<Data> 
       find(const Name& keyName); 

       // @brief     Get certificate given interest 
       const shared_ptr<Data> 
       find(const Interest& interest); 

       // @brief Get certificates under id 
       const std::list<shared_ptr<Data>> 
       findById(const std::string& id); 

     private: 
       // @brief Refresh anchors, triggered by find 
       void 
       refreshAnchors(); 

     private: 
       AnchorList m_anchors; // List of anchors indexed by name 
       AnchorIndex m_anchorIndice; // Anchor index, indexed on id and expire time 
     }; 

 Code comes soon 


Back