PKIFCacheMediator2.cpp

Go to the documentation of this file.
00001 
00009 #include "PKIFCacheMediator2.h"
00010 #include "PKIFCacheErrors.h"
00011 #include "PKIFCacheException.h"
00012 #include "PKIFLog.h"
00013 #include "PKIFCRLDPRetrieval.h"
00014 #include "ToolkitUtils.h"
00015 #include "ScopeGuard.h"
00016 #include "PKIFCRLNodeEntry.h"
00017 #include "GottaMatch.h"
00018 
00019 
00020 #ifdef _WIN32
00021 #include "PKIFCAPIRepository2.h"
00022 #include "PKIFCAPITrustStore2.h"
00023 #include "CAPITrustRootCRLRepository2.h"
00024 #else
00025 // NSS is needed for the default on non-win32 systems
00026 #include "PKIFNSSRepository.h"
00027 #include "PKIFNSSTrustStore.h"
00028 #include "PKIFNSSCertUpdate.h"
00029 #include "PKIFNSSCRLUpdate.h"
00030 #endif //_WIN32
00031 
00032 
00033 #include "boost/thread/recursive_mutex.hpp"
00034 
00035 #ifdef _WIN32
00036 #ifdef _DEBUG
00037 #include "crtdbg.h"
00038 #endif //_DEBUG
00039 #endif //_WIN32
00040 
00041 using namespace std;
00042 using namespace boost;
00043 
00045 struct CPKIFCacheMediator2Impl
00046 {   
00054     CPKIFCacheMediator2Impl(): m_me() 
00055     {
00056         m_bInitialized = false;
00057         m_addDefaultColleagues = false; //false to align with default value passed to CPKIFCacheMediator2 constructor
00058     };
00059 
00060     boost::recursive_mutex m_me;
00061 
00062     //Declare a bunch of vectors to contain pointers to specific interfaces implemented
00063     //by colleagues associated with this instance.  m_vModules contains all colleagues.  
00064     //Each other vector contains 0 or more pointers to specific interfaces.  This is 
00065     //done to avoid repeatedly performing the same cast operations.
00066     
00068     std::vector<IPKIFColleaguePtr> m_vModules;
00069 
00071     std::vector<IPKIFCRLRepositoryUpdatePtr> m_vCRLRepUptadeModules;
00073     std::vector<IPKIFCRLRepositoryPtr> m_vCRLRepModules;
00075     std::vector<IPKIFCertRepositoryUpdatePtr> m_vCertRepUpdateModules;
00077     std::vector<IPKIFCertRepositoryPtr> m_vCertRepModules;
00079     std::vector<IPKIFCertSearchPtr> m_vCertSearchModules;
00081     std::vector<IPKIFTrustCachePtr> m_vTrustCacheModules;
00083     std::vector<IPKIFSupportsSynonymousCRLSourcesPtr> m_vSynonymousCRLSources;
00085     std::vector<IPKIFSupportsSynonymousCertSourcesPtr> m_vSynonymousCertSources;
00087     std::vector<IPKIFSynonymousSourceStorePtr> m_vSynonymousStore;
00088 
00090     std::vector<IPKIFCRLRepositoryPtr> m_vNoCRLSynSourceSupport;
00092     std::vector<IPKIFCertRepositoryPtr> m_vNoCertSynSourceSupport;
00093 
00095     bool m_addDefaultColleagues;
00096 
00098     bool m_bInitialized;
00099 
00100     //functions to check synonymous stores and to add certs to the stores
00101     void GetCerts(CPKIFCertificateSourceList& certSources, CPKIFCertificateNodeList& certNodeList);
00102     void GetCerts(CPKIFCertificateSourcePtr& certSource, CPKIFCertificateNodeList& certNodeList);
00103     void AddCerts(CPKIFCertificateNodeList& certNodeList);
00104 
00105     void GetCrls(const CPKIFCertificatePtr& cert,CPKIFCrlSourceList& crlSources, CPKIFCRLNodeList& crlNodeList);
00106     void GetCrls(const CPKIFCertificatePtr& cert,CPKIFCrlSourcePtr& crlSource, CPKIFCRLNodeList& crlNodeList);
00107     void AddCrls(CPKIFCRLNodeList& crlNodeList);
00108 };
00116 void CPKIFCacheMediator2Impl::AddCerts(
00118     CPKIFCertificateNodeList& certNodeList)
00119 {
00120     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storePos;
00121     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storeEnd = m_vSynonymousStore.end();
00122     for(storePos = m_vSynonymousStore.begin(); storePos != storeEnd; ++storePos)
00123     {
00124         CPKIFCertificateNodeList::iterator certNodePos;
00125         CPKIFCertificateNodeList::iterator certNodeEnd = certNodeList.end();
00126         for(certNodePos = certNodeList.begin(); certNodePos != certNodeEnd; ++certNodePos)
00127         {
00128             (*storePos)->AddCert(*certNodePos);
00129         }
00130     }
00131 }
00132 
00133 void CPKIFCacheMediator2Impl::AddCrls(
00135     CPKIFCRLNodeList& crlNodeList)
00136 {
00137     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storePos;
00138     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storeEnd = m_vSynonymousStore.end();
00139     for(storePos = m_vSynonymousStore.begin(); storePos != storeEnd; ++storePos)
00140     {
00141         CPKIFCRLNodeList::iterator crlNodePos;
00142         CPKIFCRLNodeList::iterator crlNodeEnd = crlNodeList.end();
00143         for(crlNodePos = crlNodeList.begin(); crlNodePos != crlNodeEnd; ++crlNodePos)
00144         {
00145             (*storePos)->AddCRL(*crlNodePos);
00146         }
00147     }
00148 }
00156 void CPKIFCacheMediator2Impl::GetCerts(
00158     CPKIFCertificateSourcePtr& certSource,
00160     CPKIFCertificateNodeList& certNodeList)
00161 {
00162     CPKIFCertificateSourceList list;
00163     list.push_back(certSource);
00164     GetCerts(list, certNodeList);
00165 }
00166 
00167 void CPKIFCacheMediator2Impl::GetCrls(
00168     const CPKIFCertificatePtr& cert,
00170     CPKIFCrlSourcePtr& crlSource,
00172     CPKIFCRLNodeList& crlNodeList)
00173 {
00174     CPKIFCrlSourceList list;
00175     list.push_back(crlSource);
00176     GetCrls(cert, list, crlNodeList);
00177 }
00178 
00186 void CPKIFCacheMediator2Impl::GetCerts(
00188     CPKIFCertificateSourceList& certSources,
00190     CPKIFCertificateNodeList& certNodeList)
00191 {
00192     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storePos;
00193     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storeEnd = m_vSynonymousStore.end();
00194     for(storePos = m_vSynonymousStore.begin(); storePos != storeEnd; ++storePos)
00195     {
00196         (*storePos)->GetCerts(certSources, certNodeList);
00197     } 
00198 }
00199 
00200 void CPKIFCacheMediator2Impl::GetCrls(
00201     const CPKIFCertificatePtr& cert, 
00203     CPKIFCrlSourceList& crlSources,
00205     CPKIFCRLNodeList& crlNodeList)
00206 {
00207     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storePos;
00208     std::vector<IPKIFSynonymousSourceStorePtr>::iterator storeEnd = m_vSynonymousStore.end();
00209     for(storePos = m_vSynonymousStore.begin(); storePos != storeEnd; ++storePos)
00210     {
00211         (*storePos)->GetCRLs(cert, crlSources, crlNodeList);
00212     } 
00213 }
00214 
00216 
00228 CPKIFCacheMediator2::CPKIFCacheMediator2(
00230     bool addDefaultColleagues) : m_impl (new CPKIFCacheMediator2Impl)
00231 {
00232     m_impl->m_addDefaultColleagues = addDefaultColleagues;
00233     LOG_STRING_DEBUG("CPKIFCacheMediator2::CPKIFCacheMediator2(void)", TOOLKIT_SR_MEDIATOR, 0, this);
00234 }
00235 
00236 
00245 CPKIFCacheMediator2::~CPKIFCacheMediator2(void)
00246 {
00247     LOG_STRING_DEBUG("CPKIFCacheMediator2::~CPKIFCacheMediator2(void)", TOOLKIT_SR_MEDIATOR, 0, this);
00248 
00249     Terminate();
00250 
00251     if(m_impl) delete m_impl;
00252     m_impl = NULL;
00253 }
00254 
00264 void CPKIFCacheMediator2::Terminate()
00265 {
00266     LOG_STRING_DEBUG("CPKIFCacheMediator2::Terminate()", TOOLKIT_SR_MEDIATOR, 0, this);
00267 
00268     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00269     try
00270     {
00271         //inform our children that we are dying
00272         RemoveParentRelationships(m_impl->m_vModules, this);
00273 
00274         RemoveMediatorAssociations();
00275 
00276         //added 7/17/2004
00277         IPKIFMediator::Terminate();
00278 
00279         //empty all of the vectors of pointers to interfaces
00280         m_impl->m_vCRLRepUptadeModules.clear();
00281         m_impl->m_vCRLRepModules.clear();
00282         m_impl->m_vCertRepUpdateModules.clear();
00283         m_impl->m_vCertRepModules.clear();
00284         m_impl->m_vCertSearchModules.clear();
00285         m_impl->m_vTrustCacheModules.clear();
00286         m_impl->m_vSynonymousCRLSources.clear();
00287         m_impl->m_vSynonymousCertSources.clear();
00288         m_impl->m_vSynonymousStore.clear();
00289         m_impl->m_vNoCRLSynSourceSupport.clear();
00290         m_impl->m_vNoCertSynSourceSupport.clear();
00291         
00292         //empty the vector of all colleagues
00293         m_impl->m_vModules.clear(); 
00294     }
00295     catch(CPKIFException& )
00296     {
00297         //EXCEPTION DELETION
00298         //no purpose is served by passing on this exception - log it and forget it
00299         LOG_STRING_ERROR("CPKIFException encountered during CPKIFCacheMediator2 mediator termination", thisComponent, COMMON_TERMINATION_ERROR, this);
00300         //delete e;
00301         _ASSERT(false);
00302     }
00303     catch(...)
00304     {
00305         LOG_STRING_FATAL("Unknown exception encountered during CPKIFCacheMediator2 mediator termination", thisComponent, COMMON_TERMINATION_ERROR, this);
00306         _ASSERT(false);
00307     }
00308 }
00309 
00320 void CPKIFCacheMediator2::Initialize()
00321 {
00322     InitializeMediator(NULL);
00323 }
00324 
00339 void CPKIFCacheMediator2::InitializeMediator(
00341     std::vector<CPKIFException*>* errorInfo)
00342 {
00343     LOG_STRING_DEBUG("CPKIFCacheMediator2::InitializeMediator(std::vector<CPKIFException*>* errorInfo)", TOOLKIT_SR_MEDIATOR, 0, this);
00344 
00345     //CCACSynchronizedObject so(m_impl->m_md);
00346     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00347     LOG_STRING_DEBUG("Initializing CPKIFCacheMediator2 mediator", thisComponent, 0, this);
00348 
00349     //if we've already initialized ourselves, then we should throw an exception
00350     if(m_impl->m_bInitialized)
00351         throw CPKIFCacheException(thisComponent, COMMON_ALREADY_INITIALIZED, "This instance has already been initialized.  Call Terminate prior to re-initializing.");
00352 
00353     if(m_impl->m_addDefaultColleagues)
00354     {
00355 #ifdef _WIN32
00356         // GCC doesn't consider the result of dynamic_pointer_cast to be a reference when
00357         // used in a function call. Even though VC8 is fine with it, it doesn't hurt
00358         // and reduces the likelihood of copy and paste errors breaking the tree later.
00359         IPKIFColleaguePtr cp;
00360         CPKIFCAPIRepository2Ptr x1(new CPKIFCAPIRepository2());
00361         CPKIFCAPITrustStore2Ptr x2(new CPKIFCAPITrustStore2());
00362         CPKIFCAPITrustRootCRLRepository2Ptr x3(new CPKIFCAPITrustRootCRLRepository2());
00363         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFCAPIRepository2>(x1);
00364         AddColleague(cp);
00365         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFCAPITrustStore2>(x2);
00366         AddColleague(cp);
00367         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFCAPITrustRootCRLRepository2>(x3);
00368         AddColleague(cp);
00369 #else
00370         // moving the UNIX code away from the x1..xn naming convention because
00371         // as UNIX gets more colleagues here, there's a naming conflict.
00372         CPKIFNSSRepositoryPtr repo(new CPKIFNSSRepository());
00373         CPKIFNSSTrustStorePtr trust(new CPKIFNSSTrustStore());
00374         CPKIFNSSCertUpdatePtr certup(new CPKIFNSSCertUpdate());
00375         CPKIFNSSCRLUpdatePtr crlup(new CPKIFNSSCRLUpdate());
00376         // GCC doesn't consider the result of dynamic_pointer_cast to be a reference when
00377         // used in a function call.
00378         IPKIFColleaguePtr cp = dynamic_pointer_cast<IPKIFColleague,CPKIFNSSRepository>(repo);
00379         AddColleague(cp);
00380         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFNSSTrustStore>(trust);
00381         AddColleague(cp);
00382         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFNSSCertUpdate>(certup);
00383         AddColleague(cp);
00384         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFNSSCRLUpdate>(crlup);
00385         AddColleague(cp);
00386 #endif
00387         CPKIFCRLDPRetrievalPtr x4(new CPKIFCRLDPRetrieval());
00388         cp = dynamic_pointer_cast<IPKIFColleague,CPKIFCRLDPRetrieval>(x4);
00389         AddColleague(cp);
00390     }
00391     m_impl->m_bInitialized = true;
00392 }
00393 
00421 void CPKIFCacheMediator2::AddColleague(
00423     IPKIFColleaguePtr& module)
00424 {
00425     LOG_STRING_DEBUG("CPKIFCacheMediator2::AddColleague(IPKIFColleague* module, bool transferOwnership)", TOOLKIT_SR_MEDIATOR, 0, this);
00426 
00427     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00428 
00429     if(!module)
00430         return;
00431 
00432     //if the module throws an exception let the caller catch it
00433     module->Initialize();
00434     module->AddParent(this);//added 3/12/2003 CRW
00435 
00436     try
00437     {
00438         m_impl->m_vModules.push_back(module);       
00439         if(dynamic_pointer_cast<IPKIFCRLRepositoryUpdate, IPKIFColleague>(module))
00440             m_impl->m_vCRLRepUptadeModules.push_back(dynamic_pointer_cast<IPKIFCRLRepositoryUpdate, IPKIFColleague>(module));
00441         if(dynamic_pointer_cast<IPKIFCRLRepository, IPKIFColleague>(module))
00442             m_impl->m_vCRLRepModules.push_back(dynamic_pointer_cast<IPKIFCRLRepository, IPKIFColleague>(module));
00443         if(dynamic_pointer_cast<IPKIFCertRepositoryUpdate, IPKIFColleague>(module))
00444             m_impl->m_vCertRepUpdateModules.push_back(dynamic_pointer_cast<IPKIFCertRepositoryUpdate, IPKIFColleague>(module));
00445         if(dynamic_pointer_cast<IPKIFCertRepository, IPKIFColleague>(module))
00446             m_impl->m_vCertRepModules.push_back(dynamic_pointer_cast<IPKIFCertRepository, IPKIFColleague>(module));
00447         if(dynamic_pointer_cast<IPKIFCertSearch, IPKIFColleague>(module))
00448             m_impl->m_vCertSearchModules.push_back(dynamic_pointer_cast<IPKIFCertSearch, IPKIFColleague>(module));
00449         if(dynamic_pointer_cast<IPKIFTrustCache, IPKIFColleague>(module))
00450             m_impl->m_vTrustCacheModules.push_back(dynamic_pointer_cast<IPKIFTrustCache, IPKIFColleague>(module));
00451 
00452         if(dynamic_pointer_cast<IPKIFSupportsSynonymousCRLSources, IPKIFColleague>(module))
00453             m_impl->m_vSynonymousCRLSources.push_back(dynamic_pointer_cast<IPKIFSupportsSynonymousCRLSources, IPKIFColleague>(module));
00454         else if(dynamic_pointer_cast<IPKIFCRLRepository, IPKIFColleague>(module))
00455             m_impl->m_vNoCRLSynSourceSupport.push_back(dynamic_pointer_cast<IPKIFCRLRepository, IPKIFColleague>(module));
00456 
00457         if(dynamic_pointer_cast<IPKIFSupportsSynonymousCertSources, IPKIFColleague>(module))
00458             m_impl->m_vSynonymousCertSources.push_back(dynamic_pointer_cast<IPKIFSupportsSynonymousCertSources, IPKIFColleague>(module));
00459         else if(dynamic_pointer_cast<IPKIFCertRepository, IPKIFColleague>(module))
00460             m_impl->m_vNoCertSynSourceSupport.push_back(dynamic_pointer_cast<IPKIFCertRepository, IPKIFColleague>(module));
00461         
00462         if(dynamic_pointer_cast<IPKIFSynonymousSourceStore, IPKIFColleague>(module))
00463             m_impl->m_vSynonymousStore.push_back(dynamic_pointer_cast<IPKIFSynonymousSourceStore, IPKIFColleague>(module));
00464     }
00465     catch(...)
00466     {
00467         throw;
00468     }
00469 }
00470 
00471 //GENERAL PHILOSOPHY OF FOLLOWING FUNCTIONS
00472 //  This mediator catches all exceptions that emanate from lower-level PKIF objects.  Exception
00473 //contents are recorded in the audit log but the exceptions are NOT throw to the application.  The
00474 //application will remain unaware of the exception.  This allows other colleagues an opportunity to
00475 //satisfy the request.  In the event that an unsatisfied request leaves results in the failure of
00476 //a higher level operation, the application will be notified of the higher level failure, possibly
00477 //by an exception.  If no colleague supports the requested operation an exception is thrown indicating
00478 //that the operation was not handled.
00479 
00498 void CPKIFCacheMediator2::GetCRLs(const CPKIFCertificatePtr& cert, CPKIFCRLNodeList& crlNodeList, PKIInfoSource source)
00499 {
00500     CPKIFPathSettingsPtr ps;
00501     GetCRLs(cert, crlNodeList, source, ps);
00502 }
00503 void CPKIFCacheMediator2::GetCRLs(const CPKIFCertificatePtr& cert, CPKIFCRLNodeList& crlNodeList, PKIInfoSource source, CPKIFPathSettingsPtr& ps)
00504 {
00505     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00506 
00507     vector<IPKIFCRLRepositoryPtr>::iterator pos;
00508     vector<IPKIFCRLRepositoryPtr>::iterator end;
00509 
00510     bool opAttempted = false, opSucceeded = false;
00511     if(!m_impl->m_vSynonymousStore.empty() || !m_impl->m_vSynonymousCRLSources.empty())
00512     {
00513         //if there is a synonymous store, consult it first
00514         opAttempted = true;
00515         opSucceeded = true;
00516 
00517         CPKIFCrlSourceList crlSources;
00518 
00519         //get a list of sources
00520         std::vector<IPKIFSupportsSynonymousCRLSourcesPtr>::iterator sourcePos;
00521         std::vector<IPKIFSupportsSynonymousCRLSourcesPtr>::iterator sourceEnd = m_impl->m_vSynonymousCRLSources.end();
00522         for(sourcePos = m_impl->m_vSynonymousCRLSources.begin(); sourcePos != sourceEnd; ++sourcePos)
00523         {
00524             (*sourcePos)->GetCRLSources(cert, crlSources);
00525         }
00526 
00527         //attempt to retrieve sources.  try store first then retrieve if not in store
00528         //  - this should be async but isn't right now
00529         CPKIFCrlSourceList::iterator sourceListPos;
00530         CPKIFCrlSourceList::iterator sourceListEnd = crlSources.end();
00531         for(sourceListPos = crlSources.begin(); sourceListPos != sourceListEnd; ++sourceListPos)
00532         {
00533             bool bAddToSynStore = false;
00534             CPKIFCRLNodeList tempNodeList;
00535 
00536             m_impl->GetCrls(cert, *sourceListPos, tempNodeList);
00537 
00538             if(tempNodeList.empty() && PAS_PENDING == (*sourceListPos)->GetState() && LOCAL != source)
00539             {
00540                 //nothing was in the syn store and the source is still pending.  try to retrieve from it.
00541                 (*sourceListPos)->GetCrls(tempNodeList);
00542                 bAddToSynStore = true;
00543             }
00544 
00545             if(!tempNodeList.empty())
00546             {
00547                 //either the syn store or the source itself found something, mark it as available
00548                 (*sourceListPos)->SetState(PAS_AVAILABLE);
00549 
00550                 //add anything not already in the outbound node list to the list
00551                 GottaMatch<CPKIFCRLNodeEntryPtr> gm;
00552                 CPKIFCRLNodeList::iterator crlNodePos;
00553                 CPKIFCRLNodeList::iterator crlNodeEnd = tempNodeList.end();
00554                 for(crlNodePos = tempNodeList.begin(); crlNodePos != crlNodeEnd; ++crlNodePos)
00555                 {
00556                     gm.SetRHS(*crlNodePos);
00557                     if(crlNodeList.end() == find_if(crlNodeList.begin(), crlNodeList.end(), gm))
00558                     {
00559                         crlNodeList.push_back(*crlNodePos);
00560                     }
00561                 }
00562 
00563                 //add stuff to the syn store (if not collected from there)
00564                 if(bAddToSynStore)
00565                     m_impl->AddCrls(tempNodeList);
00566             }
00567             else if(LOCAL != source)
00568             {
00569                 //the source is unavailable - record this fact in the store
00570                 CPKIFCRLNodeEntryPtr newNode(new CPKIFCRLNodeEntry);
00571                 newNode->SetState(PAS_UNAVAILABLE);
00572                 vector<string> unavailableSources;
00573                 (*sourceListPos)->GetSources(unavailableSources);
00574                 vector<string>::iterator uapos;
00575                 vector<string>::iterator uaend = unavailableSources.end();
00576                 for(uapos = unavailableSources.begin(); uapos != uaend; ++uapos)
00577                     newNode->AddSource(*uapos);
00578 
00579                 tempNodeList.push_back(newNode);
00580                 m_impl->AddCrls(tempNodeList);
00581             }
00582         }
00583 
00584         //set up the iterators for the remaining stores (if any)
00585         pos = m_impl->m_vNoCRLSynSourceSupport.begin();
00586         end = m_impl->m_vNoCRLSynSourceSupport.end();
00587     }
00588     else
00589     {
00590         //set up the iterators for all stores
00591         pos = m_impl->m_vCRLRepModules.begin();
00592         end = m_impl->m_vCRLRepModules.end();
00593     }
00594 
00595 /*
00596 
00597             PKIArtifactState state = (*crlSourcePos)->GetState();
00598             if(PAS_PENDING == state && LOCAL != source)
00599             {
00600                 (*crlSourcePos)->GetCrls(tmpNodeList);
00601 
00602                 CPKIFCRLNodeList::iterator crlNodePos;
00603                 CPKIFCRLNodeList::iterator crlNodeEnd = tmpNodeList.end();
00604                 for(crlNodePos = tmpNodeList.begin(); crlNodePos != crlNodeEnd; ++crlNodePos)
00605                 {
00606                     if(PAS_PENDING != (*crlNodePos)->GetState())
00607                     {
00608                         if(PAS_AVAILABLE == (*crlNodePos)->GetState())
00609                         {
00610                             //if it's available, add the CRL to local stores
00611                             CPKIFGeneralNamePtr emptyDP;
00612                             AddCRL((*crlNodePos)->GetCRL(), emptyDP);
00613 
00614                             GottaMatch<CPKIFCRLNodeEntryPtr> gm;
00615                             gm.SetRHS(*crlNodePos);
00616                             if(crlNodeList.end() == find_if(crlNodeList.begin(), crlNodeList.end(), gm))
00617                                 crlNodeList.push_back(*crlNodePos);
00618                         }
00619 
00620                         //either way, available or not, update syn store
00621                         std::vector<IPKIFSynonymousSourceStorePtr>::iterator storePos;
00622                         std::vector<IPKIFSynonymousSourceStorePtr>::iterator storeEnd = m_impl->m_vSynonymousStore.end();
00623                         for(storePos = m_impl->m_vSynonymousStore.begin(); storePos != storeEnd; ++storePos)
00624                         {
00625                             (*storePos)->AddCRL(*crlNodePos);
00626                         }
00627                     }
00628                 }
00629             }
00630             else if(PAS_AVAILABLE == state)
00631             {
00632                 CPKIFCRLNodeList tmpNodeList;
00633                 (*crlSourcePos)->GetCrls(tmpNodeList);
00634 
00635                 CPKIFCRLNodeList::iterator crlNodePos;
00636                 CPKIFCRLNodeList::iterator crlNodeEnd = tmpNodeList.end();
00637                 for(crlNodePos = tmpNodeList.begin(); crlNodePos != crlNodeEnd; ++crlNodePos)
00638                 {
00639                     GottaMatch<CPKIFCRLNodeEntryPtr> gm;
00640                     gm.SetRHS(*crlNodePos);
00641                     if(crlNodeList.end() == find_if(crlNodeList.begin(), crlNodeList.end(), gm))
00642                         crlNodeList.push_back(*crlNodePos);
00643                 }
00644             }
00645         }*/
00646 
00647         //then consult any colleagues that do not support synonymous sources
00648         IPKIFCRLRepository* crlRep = NULL;      
00649         for(; pos != end; ++pos)
00650         {
00651             try
00652             {
00653                 opAttempted = true;
00654                 (*pos)->GetCRLs(cert, crlNodeList, source, ps);
00655                 opSucceeded = true;
00656             }
00657             catch(CPKIFException& e)
00658             {
00659                 //EXCEPTION DELETION
00660                 //mediators eat exceptions and throw an "op not handled" exception
00661                 //if no colleagues are able to successfully complete an operation
00662                 std::string reason = "A cache-related exception was thrown.  ";
00663                 reason.append(*e.print());
00664                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
00665             }
00666         }
00667 /*  }
00668     else
00669     {
00670         //if there isn't a synonymous store, try to retrieve CRLs from 
00671         //types of sources indicated by source
00672         vector<IPKIFCRLRepositoryPtr>::iterator pos;
00673         vector<IPKIFCRLRepositoryPtr>::iterator end = m_impl->m_vCRLRepModules.end();
00674         IPKIFCRLRepository* crlRep = NULL;
00675         bool opAttempted = false, opSucceeded = false;
00676         for(pos = m_impl->m_vCRLRepModules.begin(); pos != end; ++pos)
00677         {
00678             try
00679             {
00680                 opAttempted = true;
00681                 (*pos)->GetCRLs(cert, crlNodeList, source, ps);
00682                 opSucceeded = true;
00683             }
00684             catch(CPKIFException& e)
00685             {
00686                 //EXCEPTION DELETION
00687                 //mediators eat exceptions and throw an "op not handled" exception
00688                 //if no colleagues are able to successfully complete an operation
00689                 std::string reason = "A cache-related exception was thrown.  ";
00690                 reason.append(*e.print());
00691                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
00692             }
00693         }
00694 
00695         if(!opAttempted)
00696             throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
00697 
00698         if(!opSucceeded)
00699             throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
00700     }*/
00701 }
00702 
00718 void CPKIFCacheMediator2::GetCRLs(
00720     const CPKIFCertificatePtr& cert,
00722     CPKIFCRLList& crlList,
00724     PKIInfoSource source)
00725 {
00726     CPKIFPathSettingsPtr ps;
00727     GetCRLs(cert, crlList, source, ps);
00728 }
00729 void CPKIFCacheMediator2::GetCRLs(const CPKIFCertificatePtr& cert, CPKIFCRLList& crlList, PKIInfoSource source, CPKIFPathSettingsPtr& ps)
00730 {
00731     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCRLs", TOOLKIT_SR_MEDIATOR, 0, this);
00732 
00733     //This function will iterate over all associated cert cache objects and build up the certList.  This
00734     //function relies solely on the associated objects and does nothing with the source other than pass it on.
00735 
00736     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00737 
00738     vector<IPKIFCRLRepositoryPtr>::iterator pos;
00739     vector<IPKIFCRLRepositoryPtr>::iterator end = m_impl->m_vCRLRepModules.end();
00740     IPKIFCRLRepository* crlRep = NULL;
00741     bool opAttempted = false, opSucceeded = false;
00742     for(pos = m_impl->m_vCRLRepModules.begin(); pos != end; ++pos)
00743     {
00744         try
00745         {
00746             opAttempted = true;
00747             (*pos)->GetCRLs(cert, crlList, source, ps);
00748             opSucceeded = true;
00749         }
00750         catch(CPKIFException& e)
00751         {
00752             //EXCEPTION DELETION
00753             //mediators eat exceptions and throw an "op not handled" exception
00754             //if no colleagues are able to successfully complete an operation
00755             std::string reason = "A cache-related exception was thrown.  ";
00756             reason.append(*e.print());
00757             AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
00758             //delete e;
00759         }
00760     }
00761 
00762     if(!opAttempted)
00763         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
00764 
00765     if(!opSucceeded)
00766         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
00767 }
00768 
00794 void CPKIFCacheMediator2::GetCertificates(
00797     const CPKIFNamePtr& subDN, 
00800     CPKIFCertificateList& certList, 
00802     PKIInfoSource source)
00803 {
00804     CPKIFPathSettingsPtr ps;
00805     GetCertificates(subDN, certList, source, ps);
00806 }
00832 void CPKIFCacheMediator2::GetCertificates(
00835     const CPKIFNamePtr& subDN, 
00838     CPKIFCertificateList& certList, 
00840     PKIInfoSource source,
00842     CPKIFPathSettingsPtr& ps)
00843 {
00844     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCertificates", TOOLKIT_SR_MEDIATOR, 0, this);
00845 
00846     //This function will iterate over all associated cert cache objects and build up the certList.  This
00847     //function relies solely on the associated objects and does nothing with the source other than pass it on.
00848 
00849     //CCACSynchronizedObject so(m_impl->m_md);
00850     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00851 
00852     vector<IPKIFCertRepositoryPtr>::iterator pos;
00853     vector<IPKIFCertRepositoryPtr>::iterator end = m_impl->m_vCertRepModules.end();
00854     IPKIFCertRepository* certRep = NULL;
00855     bool opAttempted = false, opSucceeded = false;
00856     for(pos = m_impl->m_vCertRepModules.begin(); pos != end; ++pos)
00857     {
00858         
00859             try
00860             {
00861                 opAttempted = true;
00862                 (*pos)->GetCertificates(subDN, certList, source, ps);
00863                 opSucceeded = true;
00864             }
00865             catch(CPKIFException& e)
00866             {
00867                 std::string reason = "A cache-related exception was thrown.  ";
00868                 reason.append(*e.print());
00869                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
00870                 //delete e;
00871             }
00872         
00873     }
00874 
00875     if(!opAttempted)
00876         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
00877 
00878     if(!opSucceeded)
00879         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
00880 }
00881 
00907 void CPKIFCacheMediator2::GetCertificates(
00910     const CPKIFNamePtr& subDN, 
00913     CPKIFCertificateNodeList& certList, 
00915     PKIInfoSource source)
00916 {
00917     CPKIFPathSettingsPtr ps;
00918     GetCertificates(subDN, certList, source, ps);
00919 }
00945 void CPKIFCacheMediator2::GetCertificates(
00948     const CPKIFNamePtr& subDN, 
00951     CPKIFCertificateNodeList& certList, 
00953     PKIInfoSource source,
00955     CPKIFPathSettingsPtr& ps)
00956 {
00957     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCertificates", TOOLKIT_SR_MEDIATOR, 0, this);
00958 
00959     //This function will iterate over all associated cert cache objects and build up the certList.  This
00960     //function relies solely on the associated objects and does nothing with the source other than pass it on.
00961 
00962     //CCACSynchronizedObject so(m_impl->m_md);
00963     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
00964 
00965     vector<IPKIFCertRepositoryPtr>::iterator pos;
00966     vector<IPKIFCertRepositoryPtr>::iterator end = m_impl->m_vCertRepModules.end();
00967     IPKIFCertRepository* certRep = NULL;
00968     bool opAttempted = false, opSucceeded = false;
00969     for(pos = m_impl->m_vCertRepModules.begin(); pos != end; ++pos)
00970     {
00971             try
00972             {
00973                 opAttempted = true;
00974                 (*pos)->GetCertificates(subDN, certList, source, ps);
00975                 opSucceeded = true;
00976             }
00977             catch(CPKIFException& e)
00978             {
00979                 //EXCEPTION DELETION
00980                 //mediators eat exceptions and throw an "op not handled" exception
00981                 //if no colleagues are able to successfully complete an operation
00982                 std::string reason = "A cache-related exception was thrown.  ";
00983                 reason.append(*e.print());
00984                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
00985                 //delete e;
00986             }
00987         
00988     }
00989 
00990     if(!opAttempted)
00991         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
00992 
00993     if(!opSucceeded)
00994         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
00995 }
01013 void CPKIFCacheMediator2::GetCertificates(
01015     const CPKIFCertificatePtr& cert, 
01017     CPKIFCertificateList& certList, 
01019     PKIInfoSource source, 
01021     PathBuildingDirection pbd)
01022 {
01023     CPKIFPathSettingsPtr ps;
01024     GetCertificates(cert, certList, source, pbd, ps);
01025 }
01043 void CPKIFCacheMediator2::GetCertificates(
01045     const CPKIFCertificatePtr& cert, 
01047     CPKIFCertificateList& certList, 
01049     PKIInfoSource source, 
01051     PathBuildingDirection pbd,
01053     CPKIFPathSettingsPtr& ps)
01054 {
01055     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCertificates", TOOLKIT_SR_MEDIATOR, 0, this);
01056 
01057     //This function will iterate over all associated cert cache objects and build up the certList.  This
01058     //function relies solely on the associated objects and does nothing with the source other than pass it on.
01059 
01060     //CCACSynchronizedObject so(m_impl->m_md);
01061     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01062 
01063     vector<IPKIFCertRepositoryPtr>::iterator pos;
01064     vector<IPKIFCertRepositoryPtr>::iterator end = m_impl->m_vCertRepModules.end();
01065     IPKIFCertRepository* certRep = NULL;
01066     bool opAttempted = false, opSucceeded = false;
01067     for(pos = m_impl->m_vCertRepModules.begin(); pos != end; ++pos)
01068     {
01069         try
01070         {
01071             opAttempted = true;
01072             (*pos)->GetCertificates(cert, certList, source, pbd, ps);
01073             opSucceeded = true;
01074         }
01075         catch(CPKIFException& e)
01076         {
01077             //EXCEPTION DELETION
01078             //mediators eat exceptions and throw an "op not handled" exception
01079             //if no colleagues are able to successfully complete an operation
01080             std::string reason = "A cache-related exception was thrown.  ";
01081             reason.append(*e.print());
01082             AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01083             //delete e;
01084         }
01085     }
01086 
01087     if(!opAttempted)
01088         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01089 
01090     if(!opSucceeded)
01091         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01092 }
01110 void CPKIFCacheMediator2::GetCertificates(
01112     const CPKIFCertificatePtr& cert, 
01114     CPKIFCertificateNodeList& certNodeList, 
01116     PKIInfoSource source, 
01118     PathBuildingDirection pbd)
01119 {
01120     CPKIFPathSettingsPtr ps;
01121     GetCertificates(cert, certNodeList, source, pbd, ps);
01122 }
01140 void CPKIFCacheMediator2::GetCertificates(
01142     const CPKIFCertificatePtr& cert, 
01144     CPKIFCertificateNodeList& certNodeList, 
01146     PKIInfoSource source, 
01148     PathBuildingDirection pbd,
01150     CPKIFPathSettingsPtr& ps)
01151 {
01152     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCertificates", TOOLKIT_SR_MEDIATOR, 0, this);
01153 
01154     //This function will iterate over all associated cert cache objects and build up the certList.  This
01155     //function relies solely on the associated objects and does nothing with the source other than pass it on.
01156 
01157     //CCACSynchronizedObject so(m_impl->m_md);
01158     boost::recursive_mutex::scoped_lock lock(m_impl->m_me); 
01159 
01160     vector<IPKIFCertRepositoryPtr>::iterator pos;
01161     vector<IPKIFCertRepositoryPtr>::iterator end;
01162 
01163     bool opAttempted = false, opSucceeded = false;
01164 
01165     if(!m_impl->m_vSynonymousStore.empty() || !m_impl->m_vSynonymousCertSources.empty()) 
01166     {
01167         //if there is a synonymous store, consult it first
01168         opAttempted = true;
01169         opSucceeded = true;
01170 
01171         CPKIFCertificateSourceList certSources;
01172 
01173         //get a list of sources
01174         std::vector<IPKIFSupportsSynonymousCertSourcesPtr>::iterator sourcePos;
01175         std::vector<IPKIFSupportsSynonymousCertSourcesPtr>::iterator sourceEnd = m_impl->m_vSynonymousCertSources.end();
01176         for(sourcePos = m_impl->m_vSynonymousCertSources.begin(); sourcePos != sourceEnd; ++sourcePos)
01177         {
01178             (*sourcePos)->GetCertificateSources(cert, certSources, pbd);
01179         }
01180 
01181         //attempt to retrieve sources.  try store first then retrieve if not in store
01182         //  - this should be async but isn't right now
01183         CPKIFCertificateSourceList::iterator sourceListPos;
01184         CPKIFCertificateSourceList::iterator sourceListEnd = certSources.end();
01185         for(sourceListPos = certSources.begin(); sourceListPos != sourceListEnd; ++sourceListPos)
01186         {
01187             bool bAddToSynStore = false;
01188             CPKIFCertificateNodeList tempNodeList;
01189 
01190             //this function on the impl will try all of the syn stores
01191             m_impl->GetCerts(*sourceListPos, tempNodeList);
01192 
01193             if(tempNodeList.empty() && PAS_PENDING == (*sourceListPos)->GetState() && LOCAL != source)
01194             {
01195                 //nothing was in the syn store and the source is still pending.  try to retrieve from it.
01196                 (*sourceListPos)->GetCertificates(tempNodeList, pbd);
01197                 bAddToSynStore = true;
01198             }
01199     
01200             if(!tempNodeList.empty())
01201             {
01202                 //either the syn store or the source itself found something, mark it as available
01203                 (*sourceListPos)->SetState(PAS_AVAILABLE);
01204 
01205                 //add anything not already in the outbound node list to the list
01206                 GottaMatch<CPKIFCertificateNodeEntryPtr> gm;
01207                 CPKIFCertificateNodeList::iterator certNodePos;
01208                 CPKIFCertificateNodeList::iterator certNodeEnd = tempNodeList.end();
01209                 for(certNodePos = tempNodeList.begin(); certNodePos != certNodeEnd; ++certNodePos)
01210                 {
01211                     gm.SetRHS(*certNodePos);
01212                     if(certNodeList.end() == find_if(certNodeList.begin(), certNodeList.end(), gm))
01213                     {
01214                         certNodeList.push_back(*certNodePos);
01215                     }
01216                 }
01217 
01218                 //add stuff to the syn store (if not collected from there)
01219                 if(bAddToSynStore)
01220                     m_impl->AddCerts(tempNodeList);
01221             }
01222             else if(LOCAL != source)
01223             {
01224                 //the source is unavailable - record this fact in the store
01225                 CPKIFCertificateNodeEntryPtr newNode(new CPKIFCertificateNodeEntry);
01226                 newNode->SetState(PAS_UNAVAILABLE);
01227                 vector<string> unavailableSources;
01228                 (*sourceListPos)->GetSources(unavailableSources);
01229                 vector<string>::iterator uapos;
01230                 vector<string>::iterator uaend = unavailableSources.end();
01231                 for(uapos = unavailableSources.begin(); uapos != uaend; ++uapos)
01232                     newNode->AddSource(*uapos);
01233 
01234                 tempNodeList.push_back(newNode);
01235                 m_impl->AddCerts(tempNodeList);
01236             }
01237         }
01238 
01239         //set up the iterators for the remaining stores (if any)
01240         pos = m_impl->m_vNoCertSynSourceSupport.begin();
01241         end = m_impl->m_vNoCertSynSourceSupport.end();
01242     }
01243     else
01244     {
01245         //set up the iterators for all stores
01246         pos = m_impl->m_vCertRepModules.begin();
01247         end = m_impl->m_vCertRepModules.end();
01248     }
01249 
01250     IPKIFCertRepository* certRep = NULL;
01251     for(; pos != end; ++pos)
01252     {
01253         try
01254         {
01255             opAttempted = true;
01256             (*pos)->GetCertificates(cert, certNodeList, source, pbd, ps);
01257             opSucceeded = true;
01258         }
01259         catch(CPKIFException& e)
01260         {
01261             //EXCEPTION DELETION
01262             //mediators eat exceptions and throw an "op not handled" exception
01263             //if no colleagues are able to successfully complete an operation
01264             std::string reason = "A cache-related exception was thrown.  ";
01265             reason.append(*e.print());
01266             AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01267             //delete e;
01268         }
01269     }
01270 
01271     if(!opAttempted)
01272         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01273 
01274     if(!opSucceeded)
01275         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01276 }
01277 
01293 bool CPKIFCacheMediator2::GetTrustRoots(
01295     const CPKIFNamePtr& subDN, 
01297     IPKIFTrustAnchorList& rootList)
01298 {
01299     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetTrustRoots", TOOLKIT_SR_MEDIATOR, 0, this);
01300 
01301     //This function will iterate over all associated trust root cache objects and build up the rootList.
01302     //true is returned if the list is grown and false is returned if the list is not grown.
01303 
01304     //CCACSynchronizedObject so(m_impl->m_md);
01305     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01306 
01307     vector<IPKIFTrustCachePtr>::iterator pos;
01308     vector<IPKIFTrustCachePtr>::iterator end = m_impl->m_vTrustCacheModules.end();
01309     IPKIFTrustCache* trustCache = NULL;
01310     const size_t origSize = rootList.size();
01311     bool opAttempted = false, opSucceeded = false;
01312     for(pos = m_impl->m_vTrustCacheModules.begin(); pos != end; ++pos)
01313     {
01314 
01315             try
01316             {
01317                 opAttempted = true;
01318                 (*pos)->GetTrustRoots(subDN, rootList);
01319                 opSucceeded = true;
01320             }
01321             catch(CPKIFException& e)
01322             {
01323                 //EXCEPTION DELETION
01324                 //mediators eat exceptions and throw an "op not handled" exception
01325                 //if no colleagues are able to successfully complete an operation
01326                 std::string reason = "A cache-related exception was thrown.  ";
01327                 reason.append(*e.print());
01328                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01329                 //delete e;
01330             }
01331         
01332     }
01333 
01334     if(!opAttempted)
01335         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01336 
01337     if(!opSucceeded)
01338         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01339 
01340     return origSize != rootList.size();
01341 }
01342 
01357 void CPKIFCacheMediator2::AddCRL(
01359     const CPKIFCRLPtr& crl,
01361     const CPKIFGeneralNamePtr& dp)
01362 {
01363     LOG_STRING_DEBUG("CPKIFCacheMediator2::AddCRL", TOOLKIT_SR_MEDIATOR, 0, this);
01364 
01365     //This function will add the crl to all associated cert update objects that will act 
01366     //on the specified name type.  Currently no error is throw if nothing actually
01367     //handles the crl.
01368 
01369     //CCACSynchronizedObject so(m_impl->m_md);
01370     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01371 
01372     vector<IPKIFCRLRepositoryUpdatePtr>::iterator pos;
01373     vector<IPKIFCRLRepositoryUpdatePtr>::iterator end = m_impl->m_vCRLRepUptadeModules.end();
01374     IPKIFCRLRepositoryUpdate* crlRep = NULL;
01375     bool opAttempted = false, opSucceeded = false;
01376     for(pos = m_impl->m_vCRLRepUptadeModules.begin(); pos != end; ++pos)
01377     {
01378 
01379             try
01380             {
01381                 opAttempted = true;
01382                 (*pos)->AddCRL(crl, dp);
01383                 opSucceeded = true;
01384             }
01385             catch(CPKIFException& e)
01386             {
01387                 //EXCEPTION DELETION
01388                 //mediators eat exceptions and throw an "op not handled" exception
01389                 //if no colleagues are able to successfully complete an operation
01390                 std::string reason = "A cache-related exception was thrown.  ";
01391                 reason.append(*e.print());
01392                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01393                 //delete e;
01394             }
01395         
01396     }
01397 
01398 
01399     if(!opAttempted)
01400         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01401 
01402     if(!opSucceeded)
01403         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01404 }
01405 
01421 void CPKIFCacheMediator2::AddCertificate(
01423     CertType certType, 
01425     const CPKIFCertificatePtr& cert)
01426 {
01427     LOG_STRING_DEBUG("CPKIFCacheMediator2::AddCertificate(CertType certType, const CPKIFCertificatePtr& cert)", TOOLKIT_SR_MEDIATOR, 0, this);
01428 
01429     //This function will add the cert to all associated cert update objects that will act 
01430     //on the specified type of certificate.  Currently no error is throw if nothing actually
01431     //handles the cert. 
01432 
01433     //CCACSynchronizedObject so(m_impl->m_md);
01434     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01435 
01436     vector<IPKIFCertRepositoryUpdatePtr>::iterator pos;
01437     vector<IPKIFCertRepositoryUpdatePtr>::iterator end = m_impl->m_vCertRepUpdateModules.end();
01438     IPKIFCertRepositoryUpdate* certRep = NULL;
01439     bool opAttempted = false, opSucceeded = false;
01440     for(pos = m_impl->m_vCertRepUpdateModules.begin(); pos != end; ++pos)
01441     {
01442             try
01443             {
01444                 opAttempted = true;
01445                 (*pos)->AddCertificate(certType, cert);
01446                 opSucceeded = true;
01447             }
01448             catch(CPKIFException& e)
01449             {
01450                 //EXCEPTION DELETION
01451                 //mediators eat exceptions and throw an "op not handled" exception
01452                 //if no colleagues are able to successfully complete an operation
01453                 std::string reason = "A cache-related exception was thrown.  ";
01454                 reason.append(*e.print());
01455                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01456                 //delete e;
01457             }
01458         
01459     }
01460 
01461     if(!opAttempted)
01462         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01463 
01464     if(!opSucceeded)
01465         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01466 }
01467 
01483 void CPKIFCacheMediator2::AddCertificate(
01485     CertType certType, 
01487     const CPKIFCertificateNodeEntryPtr& cert)
01488 {
01489     LOG_STRING_DEBUG("CPKIFCacheMediator2::AddCertificate(CertType certType, const CPKIFCertificateNodeEntryPtr& cert)", TOOLKIT_SR_MEDIATOR, 0, this);
01490 
01491     //This function will add the cert to all associated cert update objects that will act 
01492     //on the specified type of certificate.  Currently no error is throw if nothing actually
01493     //handles the cert. 
01494 
01495     //CCACSynchronizedObject so(m_impl->m_md);
01496     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01497 
01498     vector<IPKIFCertRepositoryUpdatePtr>::iterator pos;
01499     vector<IPKIFCertRepositoryUpdatePtr>::iterator end = m_impl->m_vCertRepUpdateModules.end();
01500     IPKIFCertRepositoryUpdate* certRep = NULL;
01501     bool opAttempted = false, opSucceeded = false;
01502     for(pos = m_impl->m_vCertRepUpdateModules.begin(); pos != end; ++pos)
01503     {
01504 
01505             try
01506             {
01507                 opAttempted = true;
01508                 (*pos)->AddCertificate(certType, cert);
01509                 opSucceeded = true;
01510             }
01511             catch(CPKIFException& e)
01512             {
01513                 //EXCEPTION DELETION
01514                 //mediators eat exceptions and throw an "op not handled" exception
01515                 //if no colleagues are able to successfully complete an operation
01516                 std::string reason = "A cache-related exception was thrown.  ";
01517                 reason.append(*e.print());
01518                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01519                 //delete e;
01520             }
01521         
01522     }
01523 
01524     if(!opAttempted)
01525         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01526 
01527     if(!opSucceeded)
01528         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01529 }
01530 
01531 void CPKIFCacheMediator2::FindKeys(IPKIFSearchCriteria* searchCriteria, IPKIFNameAndKeyList& keyList, PKIInfoSource source)
01532 {
01533     LOG_STRING_DEBUG("CPKIFCacheMediator2::FindKeys", TOOLKIT_SR_MEDIATOR, 0, this);
01534 
01535     //This function will iterate over all associated cert cache objects and build up the certList.  This
01536     //function relies solely on the associated objects and does nothing with the source other than pass it on.
01537 
01538     //CCACSynchronizedObject so(m_impl->m_md);
01539     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01540 
01541     vector<IPKIFCertSearchPtr>::iterator pos;
01542     vector<IPKIFCertSearchPtr>::iterator end = m_impl->m_vCertSearchModules.end();
01543     IPKIFCertSearch* certRep = NULL;
01544     bool opAttempted = false, opSucceeded = false;
01545     for(pos = m_impl->m_vCertSearchModules.begin(); pos != end; ++pos)
01546     {
01547         try
01548         {
01549             opAttempted = true;
01550             (*pos)->FindKeys(searchCriteria, keyList, source);
01551             opSucceeded = true;
01552         }
01553         catch(CPKIFException& e)
01554         {
01555             //EXCEPTION DELETION
01556             //mediators eat exceptions and throw an  "op not handled" exception
01557             //if no colleagues are able to successfully complete an operation
01558             std::string reason = "A cache-related exception was thrown.  ";
01559             reason.append(*e.print());
01560             AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01561             //delete e;
01562         }
01563     }
01564 
01565     if(!opAttempted)
01566         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01567 
01568     if(!opSucceeded)
01569         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01570 }
01571 
01582 void CPKIFCacheMediator2::FindCertificates(
01584     IPKIFSearchCriteria* searchCriteria,
01586     CPKIFCertificateList& certList,
01588     PKIInfoSource source)
01589 {
01590     LOG_STRING_DEBUG("CPKIFCacheMediator2::FindCertificates", TOOLKIT_SR_MEDIATOR, 0, this);
01591 
01592     //This function will iterate over all associated cert cache objects and build up the certList.  This
01593     //function relies solely on the associated objects and does nothing with the source other than pass it on.
01594 
01595     //CCACSynchronizedObject so(m_impl->m_md);
01596     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01597 
01598     vector<IPKIFCertSearchPtr>::iterator pos;
01599     vector<IPKIFCertSearchPtr>::iterator end = m_impl->m_vCertSearchModules.end();
01600     IPKIFCertSearch* certRep = NULL;
01601     bool opAttempted = false, opSucceeded = false;
01602     for(pos = m_impl->m_vCertSearchModules.begin(); pos != end; ++pos)
01603     {
01604             try
01605             {
01606                 opAttempted = true;
01607                 (*pos)->FindCertificates(searchCriteria, certList, source);
01608                 opSucceeded = true;
01609             }
01610             catch(CPKIFException& e)
01611             {
01612                 //EXCEPTION DELETION
01613                 //mediators eat exceptions and throw an  "op not handled" exception
01614                 //if no colleagues are able to successfully complete an operation
01615                 std::string reason = "A cache-related exception was thrown.  ";
01616                 reason.append(*e.print());
01617                 AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01618                 //delete e;
01619             }
01620         
01621     }
01622 
01623     if(!opAttempted)
01624         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01625 
01626     if(!opSucceeded)
01627         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01628 }
01636 void CPKIFCacheMediator2::GetColleagues(
01638     std::vector<IPKIFColleaguePtr>& v) const
01639 {
01640     copy(m_impl->m_vModules.begin(),m_impl->m_vModules.end(), back_inserter(v));
01641 }
01650 void CPKIFCacheMediator2::GetCertificateSources(
01652     const CPKIFCertificatePtr& cert,
01654     CPKIFCertificateSourceList& certs, 
01656     PathBuildingDirection pbd)
01657 {
01658     LOG_STRING_DEBUG("CPKIFCacheMediator2::GetCertificateSources", TOOLKIT_SR_MEDIATOR, 0, this);
01659 
01660     //This function will iterate over all associated cert cache objects and build up the certList.  This
01661     //function relies solely on the associated objects and does nothing with the source other than pass it on.
01662 
01663     //CCACSynchronizedObject so(m_impl->m_md);
01664     boost::recursive_mutex::scoped_lock lock(m_impl->m_me);
01665 
01666     vector<IPKIFSupportsSynonymousCertSourcesPtr>::iterator pos;
01667     vector<IPKIFSupportsSynonymousCertSourcesPtr>::iterator end = m_impl->m_vSynonymousCertSources.end();
01668     IPKIFCertSearch* certRep = NULL;
01669     bool opAttempted = false, opSucceeded = false;
01670     for(pos = m_impl->m_vSynonymousCertSources.begin(); pos != end; ++pos)
01671     {
01672         try
01673         {
01674             opAttempted = true;
01675             (*pos)->GetCertificateSources(cert, certs, pbd);
01676             opSucceeded = true;
01677         }
01678         catch(CPKIFException& e)
01679         {
01680             //EXCEPTION DELETION
01681             //mediators eat exceptions and throw an  "op not handled" exception
01682             //if no colleagues are able to successfully complete an operation
01683             std::string reason = "A cache-related exception was thrown.  ";
01684             reason.append(*e.print());
01685             AuditString(EVENTLOG_WARNING_TYPE, CAT_PKIF_CACHE, PKIF_UNEXPECTED_EXCEPTION, reason.c_str(), thisComponent, COMMON_UNKNOWN_ERROR, this);
01686             //delete e;
01687         }
01688     }
01689 
01690     if(!opAttempted)
01691         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_HANDLED);
01692 
01693     if(!opSucceeded)
01694         throw CPKIFCacheException(thisComponent, COMMON_OPERATION_NOT_SUCCESSFUL);
01695 }

Generated on Mon Nov 15 11:15:53 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6