IPKIFPkiArtifact.cpp

Go to the documentation of this file.
00001 
00010 #include "IPKIFPkiArtifact.h"
00011 #include "PKIFTime.h"
00012 #include "SubjectPublicKeyInfo.h"
00013 #include "AlgorithmIdentifier.h"
00014 
00015 #include <map>
00016 #include <iterator>
00017 using namespace std;
00018 
00020 struct IPKIFPkiArtifactImpl
00021 {
00022     std::map<std::string, CPKIFTimePtr> m_sources;
00023     CPKIFSubjectPublicKeyInfoPtr m_spki;
00024     CPKIFAlgorithmIdentifierPtr m_params;
00025     PKIArtifactState m_pas;
00026 };
00028 
00035 IPKIFPkiArtifact::IPKIFPkiArtifact() : m_impl(new IPKIFPkiArtifactImpl)
00036 {
00037     m_impl->m_pas = PAS_PENDING;
00038 }
00046 IPKIFPkiArtifact::~IPKIFPkiArtifact()
00047 {
00048     if(m_impl) delete m_impl;
00049 }
00050 
00051 
00059 void IPKIFPkiArtifact::AddSource(
00061     std::string& sourceURI)
00062 {
00063     // GCC doesn't like CurrentTime() as a reference
00064     CPKIFTimePtr t = CPKIFTime::CurrentTime();
00065     AddSource(sourceURI, t);
00066 }
00067 
00068 
00076 void IPKIFPkiArtifact::AddSource(
00078     std::string& sourceURI,
00080     CPKIFTimePtr& retrievalTime)
00081 {
00082     m_impl->m_sources[sourceURI] = retrievalTime;
00083 }
00084 
00085 
00093 void IPKIFPkiArtifact::GetSources(
00095     vector<std::string>& sourceURIs) const
00096 {
00097     std::map<std::string, CPKIFTimePtr>::iterator pos;
00098     std::map<std::string, CPKIFTimePtr>::iterator end = m_impl->m_sources.end();
00099     for(pos = m_impl->m_sources.begin(); pos != end; ++pos)
00100     {
00101         sourceURIs.push_back((*pos).first);
00102     }
00103 }
00104 
00112 void IPKIFPkiArtifact::GetSources(
00114     std::vector<std::pair<std::string, CPKIFTimePtr> >& sourceURIs) const
00115 {
00116     copy(m_impl->m_sources.begin(), m_impl->m_sources.end(), back_inserter(sourceURIs));
00117 }
00118 
00126 CPKIFTimePtr IPKIFPkiArtifact::GetLatestRetrievalTime() const
00127 {
00128     CPKIFTimePtr latestTime;
00129 
00130     std::map<std::string, CPKIFTimePtr>::iterator pos;
00131     std::map<std::string, CPKIFTimePtr>::iterator end = m_impl->m_sources.end();
00132     for(pos = m_impl->m_sources.begin(); pos != end; ++pos)
00133     {
00134         if(latestTime == (CPKIFTime*)NULL)
00135             latestTime = (*pos).second;
00136         else if(latestTime < (*pos).second)
00137             latestTime = (*pos).second;
00138     }
00139 
00140     return latestTime;
00141 }
00142 
00150 void IPKIFPkiArtifact::SetVerificationPublicKey(
00152     CPKIFSubjectPublicKeyInfoPtr& spki)
00153 {
00154     m_impl->m_spki = spki;
00155 }
00156 
00164 CPKIFSubjectPublicKeyInfoPtr IPKIFPkiArtifact::SetVerificationPublicKey() const
00165 {
00166     return m_impl->m_spki;
00167 }
00168 
00176 void IPKIFPkiArtifact::SetVerificationParameters(
00178     CPKIFAlgorithmIdentifierPtr& params)
00179 {
00180     m_impl->m_params = params;
00181 }
00182 
00190 CPKIFAlgorithmIdentifierPtr IPKIFPkiArtifact::GetVerificationPublicKey() const
00191 {
00192     return m_impl->m_params;
00193 }
00194 
00202 PKIArtifactState IPKIFPkiArtifact::GetState() const
00203 {
00204     return m_impl->m_pas;
00205 }
00206 
00207 
00215 void IPKIFPkiArtifact::SetState(PKIArtifactState state) const
00216 {
00217     m_impl->m_pas = state;
00218 }
00219 
00227 CPKIFCertificateSource::CPKIFCertificateSource()
00228 {
00229 }
00237 CPKIFCertificateSource::~CPKIFCertificateSource()
00238 {
00239 }
00240 
00241 bool CPKIFCertificateSource::operator==(const CPKIFCertificateSource& rhs)
00242 {
00243     vector<string> vl, vr;
00244     GetSources(vl);
00245     rhs.GetSources(vr);
00246     
00247     vector<string>::iterator pos;
00248     vector<string>::iterator end = vl.end();
00249     for(pos = vl.begin(); pos != end; ++pos)
00250     {
00251         if(vr.end() == find(vr.begin(), vr.end(), *pos))
00252             return false;
00253     }
00254 
00255     return true;
00256 }
00257 
00265 /*
00266 void CPKIFCertificateSource::GetCertificates(
00268     CPKIFCertificateNodeList& certNodeList,
00270     PathBuildingDirection pbd)
00271 {
00272 }
00273 */
00281 CPKIFCrlSource::CPKIFCrlSource()
00282 {
00283 }
00291 CPKIFCrlSource::~CPKIFCrlSource()
00292 {
00293 }
00301 void CPKIFCrlSource::GetCrls(
00303     CPKIFCRLNodeList& certNodeList)
00304 {
00305 }

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