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
00053 CPKIFCertificateList certList;
00054
00055
00056 GetCertificates(subDN, certList, source);
00057
00058 PKIInfoSource sourceType = GetSourceType();
00059
00060
00061
00062
00063 CPKIFCertificateList::iterator pos;
00064 CPKIFCertificateList::iterator end = certList.end();
00065 for(pos = certList.begin(); pos != end; ++pos)
00066 {
00067
00068 CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00069 tmpNodeEntry->SetCert(*pos);
00070 tmpNodeEntry->SetSource(sourceType);
00071
00072
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
00105 GetCertificates(cert->Issuer(), certList, source);
00106 }
00107 else
00108 {
00109
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
00133 CPKIFCertificateList certList;
00134
00135
00136 GetCertificates(cert, certList, source, pbd);
00137
00138 PKIInfoSource sourceType = GetSourceType();
00139
00140
00141
00142
00143 CPKIFCertificateList::iterator pos;
00144 CPKIFCertificateList::iterator end = certList.end();
00145 for(pos = certList.begin(); pos != end; ++pos)
00146 {
00147
00148 CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00149 tmpNodeEntry->SetCert(*pos);
00150 tmpNodeEntry->SetSource(sourceType);
00151
00152
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
00230 CPKIFCertificateList certList;
00231
00232
00233 GetCertificates(cert, certList, source, pbd, ps);
00234
00235 PKIInfoSource sourceType = GetSourceType();
00236
00237
00238
00239
00240 CPKIFCertificateList::iterator pos;
00241 CPKIFCertificateList::iterator end = certList.end();
00242 for(pos = certList.begin(); pos != end; ++pos)
00243 {
00244
00245 CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00246 tmpNodeEntry->SetCert(*pos);
00247 tmpNodeEntry->SetSource(sourceType);
00248
00249
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
00284 CPKIFCertificateList certList;
00285
00286
00287 GetCertificates(subDN, certList, source, ps);
00288
00289 PKIInfoSource sourceType = GetSourceType();
00290
00291
00292
00293
00294 CPKIFCertificateList::iterator pos;
00295 CPKIFCertificateList::iterator end = certList.end();
00296 for(pos = certList.begin(); pos != end; ++pos)
00297 {
00298
00299 CPKIFCertificateNodeEntryPtr tmpNodeEntry(new CPKIFCertificateNodeEntry);
00300 tmpNodeEntry->SetCert(*pos);
00301 tmpNodeEntry->SetSource(sourceType);
00302
00303
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 }