Project

General

Profile

Task #3290

Updated by Yingdi Yu about 9 years ago

One module of the new Validator framework is `KeyManager` which manages trust anchors, verified keys, unverified keys, and key retrieval. 
 This issue designs KeyManager abstraction. 

     class KeyManager  
     { 
     public: 
       KeyManager(); 
      
       void 
       retrieve(const KeyRequest& req)  
       { 
         auto anchorIt = m_anchors.find(req.getInterest()); 
         if (anchorIt != m_anchors.end()) { 
           return req.validationSuccessCallback(anchorIt->getData()); 
         } 

         auto keyIt = m_verfiedKeyCache.find(req.getInterest()); 
         if (keyIt != m_verfiedKeyCache.end()) { 
           return req.validationSuccessCallback(keyIt->getData()); 
         } 

         auto uKeyIt = m_unverfiedKeyCache.find(req.getInterest()); 
         if (uKeyIt != m_unverfiedKeyCache.end()) { 
           return req.retrivalSuccessCallback(uKeyIt->getData()); 
         } 
        
         if (m_face != nullptr) 
           fetchKeyFromNetwork(req); 
       } 
      
       void  
       fetchKeyFromNetwork(const KeyRequest& req) 
       { 
         preProcess(const_cast<KeyRequest&> req); 
         m_face->expressInterest(req.getInterest(). res.retrivalSuccessCallback, res.retrivalTimeoutCallback); 
       } 

       void 
       loadAnchor(...); 
      
       void 
       loadVerifiedKey(...); 
    
       void 
       loadUnverifiedKey(...); 

     private: 
       virtual 
       preProcess(KeyRequest& req) = 0; 
      
     
      
      
      
      
     private: 
       Face* m_face; 
       TrustAnchorContainer m_anchors;             // trust anchors 
       CertificateCache       m_verfiedKeyCache;     // cache of verified keys. 
       DataCache              m_unverfiedKeyCache; // cache of unverified keys. 
     };

Back