CRLDistributionPoint.cpp

Go to the documentation of this file.
00001 
00009 #include "CRLDistributionPoint.h"
00010 
00011 #include "DistributionPointName.h"
00012 #include "ReasonFlags.h"
00013 #include "GeneralName.h"
00014 
00015 #include "ooasn1.h"
00016 #include "ASN1Helper.h"
00017 #include "PKIX1Implicit88.h"
00018 #include "PKIX1Explicit88.h"
00019 
00020 using namespace std;
00021 
00022 
00024 struct CPKIFCRLDistributionPointImpl
00025 {
00026   CPKIFDistributionPointNamePtr m_dp;
00027   CPKIFGeneralNameList m_crlIssuer;
00028   CPKIFReasonFlagsPtr m_reasons;
00029 };
00030 
00032 
00040 CPKIFCRLDistributionPoint::CPKIFCRLDistributionPoint()
00041   :m_impl (new CPKIFCRLDistributionPointImpl)
00042 {
00043 }
00053 CPKIFCRLDistributionPoint::CPKIFCRLDistributionPoint(
00055     const CPKIFBufferPtr& buffer)
00056   :m_impl (new CPKIFCRLDistributionPointImpl)
00057 {
00058 
00059     CACASNWRAPPER_CREATE(CACX509V3DistributionPoint, objPDU);
00060     objPDU.Decode(buffer->GetBuffer(), buffer->GetLength());
00061 
00062     if(objPDU->m.distributionPointPresent)
00063     {
00064         CPKIFBufferPtr tmpBuf(new CPKIFBuffer(objPDU->distributionPoint.data, objPDU->distributionPoint.numocts));
00065         CPKIFDistributionPointNamePtr dp(new CPKIFDistributionPointName(tmpBuf));
00066         m_impl->m_dp = dp;
00067     }
00068 
00069     if(objPDU->m.reasonsPresent)
00070     {
00071         CPKIFReasonFlagsPtr tmpReasons(new CPKIFReasonFlags);
00072         m_impl->m_reasons = tmpReasons;
00073 
00074         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3unused ) 
00075         {
00076             m_impl->m_reasons->SetUnused();
00077         }       
00078         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3keyCompromise ) 
00079         {
00080             m_impl->m_reasons->SetKeyCompromise();
00081         }       
00082         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3cACompromise ) 
00083         {
00084             m_impl->m_reasons->SetCACompromise();
00085         }       
00086         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3affiliationChanged ) 
00087         {
00088             m_impl->m_reasons->SetAffiliationChanged();
00089         }       
00090         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3superseded ) 
00091         {
00092             m_impl->m_reasons->SetSuperseded();
00093         }       
00094         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3cessationOfOperation ) 
00095         {
00096             m_impl->m_reasons->SetCessationOfOperation();
00097         }       
00098         if( objPDU->reasons.data[BytXCACX509V3unused] & BitMCACX509V3certificateHold ) 
00099         {
00100             m_impl->m_reasons->SetCertificateHold();
00101         }       
00102 
00103         //added 12/3/2003
00104         if( objPDU->reasons.data[BytXCACX509V3privilegeWithdrawn] & BitMCACX509V3privilegeWithdrawn ) 
00105         {
00106             m_impl->m_reasons->SetPrivilegeWithdrawn();
00107         }       
00108         if( 8 < objPDU->reasons.numbits && objPDU->reasons.data[BytXCACX509V3aACompromise] & BitMCACX509V3aACompromise ) 
00109         {
00110             m_impl->m_reasons->SetAACompromise();
00111         }       
00112     }
00113 
00114     if(objPDU->m.cRLIssuerPresent)
00115     {
00116         DListNode* cur = objPDU->cRLIssuer.head;
00117         for(unsigned int ii = 0; ii < objPDU->cRLIssuer.count; ++ii)
00118         {
00119             //CPKIFGeneralNamePtr tmpGN(new CPKIFGeneralName(*(CACX509V3GeneralName*)cur->data));
00120             CACASNWRAPPER_CREATE(CACX509V3GeneralName, objPDU);
00121             ASN1OpenType* data1 = objPDU.Encode((CACX509V3GeneralName*)cur->data);
00122             CPKIFBufferPtr tmpBuf;
00123             if (data1 != NULL)
00124             {
00125                  tmpBuf = CPKIFBufferPtr(new CPKIFBuffer(data1->data, data1->numocts));
00126                 delete data1;
00127             }
00128             CPKIFGeneralNamePtr tmpGN(new CPKIFGeneralName(tmpBuf));
00129             m_impl->m_crlIssuer.push_back(tmpGN);
00130 
00131             cur = cur->next;
00132         }
00133     }
00134 }
00142 CPKIFCRLDistributionPoint::~CPKIFCRLDistributionPoint()
00143 {
00144     if(m_impl)
00145     {
00146         delete m_impl;
00147         m_impl = 0;
00148     }
00149 }
00157 void CPKIFCRLDistributionPoint::CRLIssuer(CPKIFGeneralNameList& genNames) const
00158 {
00159     genNames.clear();
00160 
00161     CPKIFGeneralNameList::const_iterator pos;
00162     CPKIFGeneralNameList::const_iterator end = m_impl->m_crlIssuer.end();
00163     for(pos = m_impl->m_crlIssuer.begin(); pos != end; ++pos)
00164     {
00165         genNames.push_back(*pos);
00166     }
00167 }
00175 CPKIFDistributionPointNamePtr CPKIFCRLDistributionPoint::DistributionPoint() const 
00176 {
00177     return m_impl->m_dp;
00178 }
00179 
00187 CPKIFReasonFlagsPtr CPKIFCRLDistributionPoint::Reasons()const
00188 {
00189     return m_impl->m_reasons;
00190 }

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