IPKIFCertRepository.cpp

Go to the documentation of this file.
00001 
00010 #include "IPKIFCertRepository.h"
00011 #include "Name.h"
00012 #include "Certificate.h"
00013 #include "PKIFCertificateNodeEntry.h"
00014 #include "ToolkitUtils.h"
00015 #include "components.h"
00016 #include "GottaMatch.h"
00017 #include "PKIFPathSettings.h"
00018 
00019 using namespace std;
00020 
00028 IPKIFCertRepository::IPKIFCertRepository()
00029 {
00030 }
00031 
00042 void IPKIFCertRepository::GetCertificates(
00044     const CPKIFNamePtr& subDN,
00046     CPKIFCertificateNodeList& certNodeList,
00048     PKIInfoSource source)
00049 {
00050     LOG_STRING_DEBUG("IPKIFCertRepository::GetCertificates(const CPKIFNamePtr& subDN, CPKIFCertificateNodeList& certNodeList, PKIInfoSource source)", TOOLKIT_SR_MISC, 0, this);
00051 
00052     //declare a simple cert list
00053     CPKIFCertificateList certList;
00054 
00055     //invoke the non-node oriented GetCerts call (must be implemented by derived class)
00056     GetCertificates(subDN, certList, source);
00057 
00058     PKIInfoSource sourceType = GetSourceType();
00059 
00060     //iterate over the cert list that was populated (or not) by the above call and create 
00061     //node objects wrapping each cert.  stuff the node objects in the certNodeList object
00062     //passed to this function.
00063     CPKIFCertificateList::iterator pos;
00064     CPKIFCertificateList::iterator end = certList.end();
00065     for(pos = certList.begin(); pos != end; ++pos)
00066     {
00067         //throw bad_alloc; nothing to clean up in this function
00068         CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00069         tmpNodeEntry->SetCert(*pos);
00070         tmpNodeEntry->SetSource(sourceType);
00071 
00072         //screen out duplicates (should this be done here?)
00073         GottaMatch<CPKIFCertificateNodeEntryPtr> gm;
00074         gm.SetRHS(tmpNodeEntry);
00075         CPKIFCertificateNodeList::iterator foundNode = find_if(certNodeList.begin(), certNodeList.end(), gm);
00076         if(certNodeList.end() == foundNode)
00077             certNodeList.push_back(tmpNodeEntry);
00078         else
00079         {
00080             if((*foundNode)->GetSource() > sourceType)
00081                 (*foundNode)->SetSource(sourceType);
00082         }
00083     }
00084 }
00092 void IPKIFCertRepository::GetCertificates(
00094     const CPKIFCertificatePtr& cert, 
00096     CPKIFCertificateList& certList, 
00098     PKIInfoSource source, 
00100     PathBuildingDirection pbd)
00101 {
00102     if(pbd == PBD_FORWARD)
00103     {
00104         //for instances that don't implement this interface, turn it into an old forward-only call
00105         GetCertificates(cert->Issuer(), certList, source);
00106     }
00107     else
00108     {
00109         //don't throw, simply return without contributing any certificates
00110     }
00111 }
00119 void IPKIFCertRepository::GetCertificates(
00121     const CPKIFCertificatePtr& cert, 
00123     CPKIFCertificateNodeList& certNodeList, 
00125     PKIInfoSource source, 
00127     PathBuildingDirection pbd)
00128 
00129 {
00130     LOG_STRING_DEBUG("IPKIFCertRepository::GetCertificates(const CPKIFNamePtr& subDN, CPKIFCertificateNodeList& certNodeList, PKIInfoSource source)", TOOLKIT_SR_MISC, 0, this);
00131 
00132     //declare a simple cert list
00133     CPKIFCertificateList certList;
00134 
00135     //invoke the non-node oriented GetCerts call (must be implemented by derived class)
00136     GetCertificates(cert, certList, source, pbd);
00137 
00138     PKIInfoSource sourceType = GetSourceType();
00139 
00140     //iterate over the cert list that was populated (or not) by the above call and create 
00141     //node objects wrapping each cert.  stuff the node objects in the certNodeList object
00142     //passed to this function.
00143     CPKIFCertificateList::iterator pos;
00144     CPKIFCertificateList::iterator end = certList.end();
00145     for(pos = certList.begin(); pos != end; ++pos)
00146     {
00147         //throw bad_alloc; nothing to clean up in this function
00148         CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00149         tmpNodeEntry->SetCert(*pos);
00150         tmpNodeEntry->SetSource(sourceType);
00151 
00152         //screen out duplicates (should this be done here?)
00153         GottaMatch<CPKIFCertificateNodeEntryPtr> gm;
00154         gm.SetRHS(tmpNodeEntry);
00155         CPKIFCertificateNodeList::iterator foundNode = find_if(certNodeList.begin(), certNodeList.end(), gm);
00156         if(certNodeList.end() == foundNode)
00157             certNodeList.push_back(tmpNodeEntry);
00158         else
00159         {
00160             if((*foundNode)->GetSource() > sourceType)
00161                 (*foundNode)->SetSource(sourceType);
00162         }
00163     }
00164 }
00175 void IPKIFCertRepository::GetCertificates(
00177     const CPKIFNamePtr& subDN,
00179     CPKIFCertificateList& certList,
00181     PKIInfoSource source,
00183     CPKIFPathSettingsPtr& ps)
00184 {
00185     GetCertificates(subDN, certList, source);
00186 }
00195 void IPKIFCertRepository::GetCertificates(
00197     const CPKIFCertificatePtr& cert,
00199     CPKIFCertificateList& certList,
00201     PKIInfoSource source,
00203     PathBuildingDirection pbd,
00205     CPKIFPathSettingsPtr& ps)
00206 {
00207     GetCertificates(cert, certList, source, pbd);
00208 }
00217 void IPKIFCertRepository::GetCertificates(
00219     const CPKIFCertificatePtr& cert,
00221     CPKIFCertificateNodeList& certNodeList,
00223     PKIInfoSource source,
00225     PathBuildingDirection pbd,
00227     CPKIFPathSettingsPtr& ps)
00228 {
00229     //declare a simple cert list
00230     CPKIFCertificateList certList;
00231 
00232     //invoke the non-node oriented GetCerts call (must be implemented by derived class)
00233     GetCertificates(cert, certList, source, pbd, ps);
00234 
00235     PKIInfoSource sourceType = GetSourceType();
00236 
00237     //iterate over the cert list that was populated (or not) by the above call and create 
00238     //node objects wrapping each cert.  stuff the node objects in the certNodeList object
00239     //passed to this function.
00240     CPKIFCertificateList::iterator pos;
00241     CPKIFCertificateList::iterator end = certList.end();
00242     for(pos = certList.begin(); pos != end; ++pos)
00243     {
00244         //throw bad_alloc; nothing to clean up in this function
00245         CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00246         tmpNodeEntry->SetCert(*pos);
00247         tmpNodeEntry->SetSource(sourceType);
00248 
00249         //screen out duplicates (should this be done here?)
00250         GottaMatch<CPKIFCertificateNodeEntryPtr> gm;
00251         gm.SetRHS(tmpNodeEntry);
00252 
00253         CPKIFCertificateNodeList::iterator foundNode = find_if(certNodeList.begin(), certNodeList.end(), gm);
00254         if(certNodeList.end() == foundNode)
00255             certNodeList.push_back(tmpNodeEntry);
00256         else
00257         {
00258             if((*foundNode)->GetSource() > sourceType)
00259                 (*foundNode)->SetSource(sourceType);
00260         }
00261     }
00262 }
00273 void IPKIFCertRepository::GetCertificates(
00275     const CPKIFNamePtr& subDN,
00277     CPKIFCertificateNodeList& certNodeList,
00279     PKIInfoSource source,
00281     CPKIFPathSettingsPtr& ps)
00282 {
00283     //declare a simple cert list
00284     CPKIFCertificateList certList;
00285 
00286     //invoke the non-node oriented GetCerts call (must be implemented by derived class)
00287     GetCertificates(subDN, certList, source, ps);
00288 
00289     PKIInfoSource sourceType = GetSourceType();
00290 
00291     //iterate over the cert list that was populated (or not) by the above call and create 
00292     //node objects wrapping each cert.  stuff the node objects in the certNodeList object
00293     //passed to this function.
00294     CPKIFCertificateList::iterator pos;
00295     CPKIFCertificateList::iterator end = certList.end();
00296     for(pos = certList.begin(); pos != end; ++pos)
00297     {
00298         //throw bad_alloc; nothing to clean up in this function
00299         CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00300         tmpNodeEntry->SetCert(*pos);
00301         tmpNodeEntry->SetSource(sourceType);
00302 
00303         //screen out duplicates (should this be done here?)
00304         GottaMatch<CPKIFCertificateNodeEntryPtr> gm;
00305         gm.SetRHS(tmpNodeEntry);
00306 
00307         CPKIFCertificateNodeList::iterator foundNode = find_if(certNodeList.begin(), certNodeList.end(), gm);
00308         if(certNodeList.end() == foundNode)
00309             certNodeList.push_back(tmpNodeEntry);
00310         else
00311         {
00312             if((*foundNode)->GetSource() > sourceType)
00313                 (*foundNode)->SetSource(sourceType);
00314         }
00315     }
00316 }

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