CRLStreamIdentifier.cpp

Go to the documentation of this file.
00001 
00009 #include "CRLStreamIdentifier.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012 
00013 #include "ASN1Helper.h"
00014 #include "PKIX1Implicit88.h"
00015 #include "PKIX1Explicit88.h"
00016 
00018 
00019 struct CPKIFCRLStreamIdentifierImpl
00020 {
00021     CPKIFStringPtr m_crlStreamIdentifier;
00022     CPKIFBufferPtr m_value;
00023     bool m_extModified;
00024 };
00025 
00027 
00028 char CPKIFCRLStreamIdentifier::extOID[] =       "2.5.29.40";
00029 
00037 CPKIFCRLStreamIdentifier::CPKIFCRLStreamIdentifier()
00038   :m_impl (new CPKIFCRLStreamIdentifierImpl)
00039 {
00040 }
00051 //CPKIFCRLStreamIdentifier::CPKIFCRLStreamIdentifier(
00052 //  //![in] Reference to an internal structure representation of the extension containing information used to construct the ob
00053 //  const CACX509V3Extension& ext) 
00054 //  : CPKIFX509Extension(ext), m_impl (new CPKIFCRLStreamIdentifierImpl)
00055 //{
00056 //  //both SkipCerts and Delta are simply integers
00057 //  CACASNWRAPPER_CREATE(CACX509V3CRLNumber, objPDU);
00058 //  objPDU.Decode(ext.extnValue.data, ext.extnValue.numocts);
00059 //  
00060 //  CACX509V3CRLNumber* tmp = objPDU.data();
00061 //  if(NULL != tmp)
00062 //  {
00063 //      CPKIFStringPtr tmpStr(new std::string((char*)*tmp));
00064 //      m_impl->m_crlStreamIdentifier = tmpStr;
00065 //  }
00066 //}
00067 
00078 CPKIFCRLStreamIdentifier::CPKIFCRLStreamIdentifier(
00079     const bool& criticality,
00080     const CPKIFBufferPtr& ext) 
00081   : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFCRLStreamIdentifierImpl)
00082 {
00083     //both SkipCerts and Delta are simply integers
00084     CACASNWRAPPER_CREATE(CACX509V3CRLNumber, objPDU);
00085     objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00086     
00087     CACX509V3CRLNumber* tmp = objPDU.data();
00088     if(NULL != tmp)
00089     {
00090         CPKIFStringPtr tmpStr(new std::string((char*)*tmp));
00091         m_impl->m_crlStreamIdentifier = tmpStr;
00092     }
00093 
00094     m_impl->m_value = ext;
00095     m_impl->m_extModified = false;
00096 }
00097 
00098 
00106 CPKIFCRLStreamIdentifier::~CPKIFCRLStreamIdentifier()
00107 {
00108     if(m_impl)
00109     {
00110         delete m_impl;
00111         m_impl = 0;
00112     }
00113 }
00121 const CPKIFOIDPtr CPKIFCRLStreamIdentifier::oid() const
00122 {
00123     //added static variable for copying instead of string creation each call
00124     static CPKIFOID staticOID(extOID);
00125     //CPKIFOIDPtr tmp(new CPKIFOID(new std::string(extOID)));
00126     static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00127     return tmp;
00128 }
00136 const char* CPKIFCRLStreamIdentifier::CRLStreamIdentifier() const
00137 {
00138     if(m_impl->m_crlStreamIdentifier == (std::string*)NULL)
00139         return false;
00140     else
00141         return m_impl->m_crlStreamIdentifier->c_str();
00142 }
00150 bool CPKIFCRLStreamIdentifier::operator==(
00152     const CPKIFCRLStreamIdentifier& rhs)
00153 {
00154     const char* v1 = CRLStreamIdentifier();
00155     const char* v2 = rhs.CRLStreamIdentifier();
00156     if(NULL != v1 && NULL != v2)
00157         return 0 == strcmp(v1, v2);
00158     /*else if(NULL == v1 && NULL == v2)
00159          return true;*/
00160     else
00161         return false;
00162 }
00170 CPKIFBufferPtr CPKIFCRLStreamIdentifier::value() const 
00171 {
00172     CPKIFBufferPtr rv = m_impl->m_value;
00173     if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00174     {
00175         //XXX ENCODE HERE and set rv if necessary 
00176     }
00177 
00178     return rv;
00179 }

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