FreshestCRL.cpp

Go to the documentation of this file.
00001 
00009 #include "FreshestCRL.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012 #include "CRLDistributionPoint.h"
00013 
00014 #include "ASN1Helper.h"
00015 #include "PKIX1Implicit88.h"
00016 #include "PKIX1Explicit88.h"
00017 
00019 
00020 struct CPKIFFreshestCRLImpl
00021 {
00022     CPKIFCRLDistributionPointListPtr m_crlDPs;
00023     CPKIFBufferPtr m_value;
00024     bool m_extModified;
00025 };
00026 
00028 
00029 char CPKIFFreshestCRL::extOID[] =               "2.5.29.46";
00030 
00038 CPKIFFreshestCRL::CPKIFFreshestCRL()
00039   :m_impl (new CPKIFFreshestCRLImpl)
00040 {
00041 }
00049 CPKIFCRLDistributionPointListPtr CPKIFFreshestCRL::DPs() const 
00050 {
00051     return m_impl->m_crlDPs;
00052 }
00063 //CPKIFFreshestCRL::CPKIFFreshestCRL(
00064 //  //![in] Reference to an internal structure representation of the extension containing information used to construct the object
00065 //  const CACX509V3Extension& ext) 
00066 //  : CPKIFX509Extension(ext), m_impl (new CPKIFFreshestCRLImpl)
00067 //{
00068 //  //Freshest CRL is of type CRLDistPointsSyntax so we can simply reuse that decoder
00069 //  CACASNWRAPPER_CREATE(CACX509V3CRLDistributionPoints, objPDU);
00070 //  objPDU.Decode(ext.extnValue.data, ext.extnValue.numocts);
00071 //
00072 //  DListNode* cur = objPDU->head;
00073 //  if(NULL != cur)
00074 //  {
00075 //      CPKIFCRLDistributionPointListPtr piList(new CPKIFCRLDistributionPointList);
00076 //      m_impl->m_crlDPs = piList;
00077 //  }
00078 //  while(NULL != cur)
00079 //  {
00080 //      CPKIFCRLDistributionPointPtr dp(new CPKIFCRLDistributionPoint((CACX509V3DistributionPoint*)cur->data));
00081 //      m_impl->m_crlDPs->push_back(dp);
00082 //      cur = cur->next;
00083 //  }
00084 //}
00085 
00096 CPKIFFreshestCRL::CPKIFFreshestCRL(
00097     const bool& criticality,
00098     const CPKIFBufferPtr& ext) 
00099   : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFFreshestCRLImpl)
00100 {
00101     //Freshest CRL is of type CRLDistPointsSyntax so we can simply reuse that decoder
00102     CACASNWRAPPER_CREATE(CACX509V3CRLDistributionPoints, objPDU);
00103     objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00104 
00105     DListNode* cur = objPDU->head;
00106     if(NULL != cur)
00107     {
00108         CPKIFCRLDistributionPointListPtr piList(new CPKIFCRLDistributionPointList);
00109         m_impl->m_crlDPs = piList;
00110     }
00111     while(NULL != cur)
00112     {
00113         //CACASNWRAPPER_CREATE(CACX509V3DistributionPoint, extsWrapper);
00114         //ASN1OpenType *data = extsWrapper.Encode ((CACX509V3DistributionPoint*)cur->data);
00115         //CPKIFBufferPtr tempBuffer(new CPKIFBuffer(data->data, data->numocts));
00116         //CPKIFCRLDistributionPointPtr dp(new CPKIFCRLDistributionPoint((CACX509V3DistributionPoint*)cur->data));
00117         ASN1OpenType* openType = (ASN1OpenType*)cur->data;
00118         CPKIFBufferPtr tmpBuffer(new CPKIFBuffer(openType->data, openType->numocts));
00119 
00120         CPKIFCRLDistributionPointPtr dp(new CPKIFCRLDistributionPoint(tmpBuffer));
00121         m_impl->m_crlDPs->push_back(dp);
00122         cur = cur->next;
00123     }
00124 
00125     m_impl->m_value = ext;
00126     m_impl->m_extModified = false;
00127 }
00128 
00136 CPKIFFreshestCRL::~CPKIFFreshestCRL()
00137 {
00138     if(m_impl)
00139     {
00140         delete m_impl;
00141         m_impl = 0;
00142     }
00143 }
00152 const CPKIFOIDPtr CPKIFFreshestCRL::oid() const
00153 {
00154     //added static variable for copying instead of string creation each call
00155     static CPKIFOID staticOID(extOID);
00156     //CPKIFOIDPtr tmp(new CPKIFOID(new std::string(extOID)));
00157     static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00158     return tmp;
00159 }
00167 CPKIFBufferPtr CPKIFFreshestCRL::value() const 
00168 {
00169     CPKIFBufferPtr rv = m_impl->m_value;
00170     if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00171     {
00172         //XXX ENCODE HERE and set rv if necessary 
00173     }
00174 
00175     return rv;
00176 }

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