PKIFAiaOrSiaRetrieval.cpp

Go to the documentation of this file.
00001 
00009 #include "PKIFdll.h"
00010 
00011 #include "AccessDescription.h"
00012 #include "AuthorityInfoAccess.h"
00013 #include "Buffer.h"
00014 #include "Certificate.h"
00015 #include "components.h"
00016 #include "DistributionPointName.h"
00017 #include "GeneralName.h"
00018 #include "GottaMatch.h"
00019 #include "IPKIFColleague.h"
00020 #include "IssuerAltName.h"
00021 #include "LDAP_URL_Header.h"
00022 #include "PKIFAiaOrSiaRetrieval.h"
00023 #include "PKIFHttpCertNode.h"
00024 #include "PKIFLdapCertNode.h"
00025 #include "SubjectInfoAccess.h"
00026 #include "ToolkitUtils.h"
00027 
00028 
00030 struct CPKIFAiaOrSiaRetrievalImpl
00031 {
00032 };
00034 
00042 CPKIFAiaOrSiaRetrieval::CPKIFAiaOrSiaRetrieval(void)
00043     :m_impl (new CPKIFAiaOrSiaRetrievalImpl)
00044 {
00045     LOG_STRING_DEBUG("CPKIFAiaOrSiaRetrieval::CPKIFAiaOrSiaRetrieval(void)", TOOLKIT_SR_MISC, 0, this);
00046 }
00054 CPKIFAiaOrSiaRetrieval::~CPKIFAiaOrSiaRetrieval(void)
00055 {
00056     LOG_STRING_DEBUG("CPKIFAiaOrSiaRetrieval::~CPKIFAiaOrSiaRetrieval(void)", TOOLKIT_SR_MISC, 0, this);
00057 
00058     delete m_impl;
00059     m_impl = NULL;
00060 }
00061 
00069 void CPKIFAiaOrSiaRetrieval::Initialize(void) 
00070 {
00071 }
00072 
00084 void CPKIFAiaOrSiaRetrieval::GetCertificates(
00086     const CPKIFCertificatePtr& cert,
00088     CPKIFCertificateNodeList& certNodeList,
00089     PKIInfoSource source,
00091     PathBuildingDirection pbd)
00092 {
00093     LOG_STRING_DEBUG("CPKIFAiaOrSiaRetrieval::GetCertificates", TOOLKIT_SR_MISC, 0, this);
00094 
00095     if(LOCAL == source)
00096         return;
00097 
00098     GetCertsFromIssuerAltName(*cert, certNodeList, source, pbd);
00099 }
00100 
00101 void CPKIFAiaOrSiaRetrieval::GetCertificates(const CPKIFCertificatePtr& cert, CPKIFCertificateList& certList, PKIInfoSource source, PathBuildingDirection pbd)
00102 {
00103     LOG_STRING_DEBUG("CPKIFAiaOrSiaRetrieval::GetCertificates", TOOLKIT_SR_MISC, 0, this);
00104 
00105     if(LOCAL == source)
00106         return;
00107 
00108     CPKIFCertificateNodeList certNodeList;
00109     GetCertsFromIssuerAltName(*cert, certNodeList, source, pbd);
00110 
00111     CPKIFCertificateNodeList::iterator pos;
00112     CPKIFCertificateNodeList::iterator end = certNodeList.end();
00113     for(pos = certNodeList.begin(); pos != end; ++pos)
00114     {
00115         certList.push_back((*pos)->GetCert());
00116     }
00117 }
00118 
00127 void CPKIFAiaOrSiaRetrieval::GetCertificateSources(
00129     const CPKIFCertificatePtr& cert,
00131     CPKIFCertificateSourceList& certNodeList,
00133     PathBuildingDirection pbd)
00134 {
00135     LOG_STRING_DEBUG("CPKIFAiaOrSiaRetrieval::GetCertificateSources", TOOLKIT_SR_MISC, 0, this);
00136 
00137     //see if the cert has an issuer alt name - if it does not the return
00138     CPKIFIssuerAltNamePtr ian;
00139     try
00140     {
00141         ian = cert->GetExtension<CPKIFIssuerAltName>();
00142     }
00143     catch(...)
00144     {
00145     }
00146     CPKIFAuthorityInfoAccessPtr aia;
00147     try
00148     {
00149         aia = cert->GetExtension<CPKIFAuthorityInfoAccess>();
00150     }
00151     catch(...)
00152     {
00153     }
00154     CPKIFSubjectInfoAccessPtr sia;
00155     try
00156     {
00157         sia = cert->GetExtension<CPKIFSubjectInfoAccess>();
00158     }
00159     catch(...)
00160     {
00161     }
00162     if(ian == (CPKIFIssuerAltNamePtr*)NULL && aia == (CPKIFAuthorityInfoAccess*)NULL && sia == (CPKIFSubjectInfoAccess*)NULL)
00163         return;
00164 
00165     CPKIFCertificateList certsFromIAN;
00166     CPKIFGeneralNameList genNames;
00167 
00168     if(PBD_FORWARD == pbd)
00169     {
00170         if(ian != (CPKIFIssuerAltNamePtr*)NULL)
00171         {
00172             ian->GeneralNames(genNames);
00173         }
00174 
00175         if(aia != (CPKIFAuthorityInfoAccess*)NULL)
00176         {
00177             CPKIFAccessDescriptionListPtr adl = aia->GetAccessDescriptions();
00178             CPKIFAccessDescriptionList::iterator aPos;
00179             CPKIFAccessDescriptionList::iterator aEnd = adl->end();
00180             for(aPos = adl->begin(); aPos != aEnd; ++aPos)
00181             {
00182                 CPKIFOIDPtr aOID = (*aPos)->AccessMethod();
00183                 if(aOID != (CPKIFOID*)NULL && *aOID == *g_aiaCAIssuer)
00184                 {
00185                     CPKIFGeneralNamePtr aGN = (*aPos)->AccessLocation();
00186                     genNames.push_back(aGN);
00187                 }
00188             }
00189         }
00190     }
00191     else
00192     {
00193         if(sia != (CPKIFSubjectInfoAccess*)NULL)
00194         {
00195             CPKIFAccessDescriptionListPtr adl = sia->GetAccessDescriptions();
00196             CPKIFAccessDescriptionList::iterator aPos;
00197             CPKIFAccessDescriptionList::iterator aEnd = adl->end();
00198             for(aPos = adl->begin(); aPos != aEnd; ++aPos)
00199             {
00200                 CPKIFOIDPtr aOID = (*aPos)->AccessMethod();
00201                 if(aOID != (CPKIFOID*)NULL && *aOID == *g_aiaCARepository)
00202                 {
00203                     CPKIFGeneralNamePtr aGN = (*aPos)->AccessLocation();
00204                     genNames.push_back(aGN);
00205                 }
00206             }
00207         }
00208     }
00209 
00210     CPKIFGeneralNameList::iterator gnPos;
00211     CPKIFGeneralNameList::iterator gnEnd = genNames.end();
00212     for(gnPos = genNames.begin(); gnPos != gnEnd; ++gnPos)
00213     {
00214         //in search of any URI entries.
00215         const char* url = (*gnPos)->uri();
00216         if(url != NULL)
00217         {
00218             std::string urlStr = url;
00219             if(0 == urlStr.find("ldap"))
00220             {
00221                 if(!UriAlreadyInList(certNodeList, urlStr))
00222                 {
00223                     CPKIFLdapCertNodePtr newNode(new CPKIFLdapCertNode);
00224                     newNode->AddSource(urlStr);
00225                     certNodeList.push_back(newNode);
00226                 }
00227             }
00228             else if(0 == urlStr.find("http"))
00229             {
00230                 if(!UriAlreadyInList(certNodeList, urlStr))
00231                 {
00232                     CPKIFHttpCertNodePtr newNode(new CPKIFHttpCertNode);
00233                     newNode->AddSource(urlStr);
00234                     certNodeList.push_back(newNode);
00235                 }
00236             }
00237         }
00238     }
00239 }
00240 
00249 void CPKIFAiaOrSiaRetrieval::GetCertificates(
00251     const CPKIFNamePtr& subDN,
00253     CPKIFCertificateList& certList,
00255     PKIInfoSource source)
00256 {
00257     //no-op.  this function takes a name, not a cert so there's nothing to do.
00258 }

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