CertificateIssuer.cpp
Go to the documentation of this file.00001
00009 #include "CertificateIssuer.h"
00010 #include "GeneralName.h"
00011 #include "OID.h"
00012 #include "Buffer.h"
00013
00014 #include "ASN1Helper.h"
00015 #include "PKIX1Implicit88.h"
00016 #include "PKIX1Explicit88.h"
00017
00018 using namespace std;
00020
00021 struct CPKIFCertificateIssuerImpl
00022 {
00023 CPKIFGeneralNameList m_gns;
00024 CPKIFBufferPtr m_value;
00025 bool m_extModified;
00026 };
00027
00029
00030 char CPKIFCertificateIssuer::extOID[] = "2.5.29.29";
00031
00039 CPKIFCertificateIssuer::CPKIFCertificateIssuer()
00040 :m_impl (new CPKIFCertificateIssuerImpl)
00041 {
00042 }
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00077 CPKIFCertificateIssuer::CPKIFCertificateIssuer(
00078 const bool& criticality,
00079 const CPKIFBufferPtr& ext)
00080 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFCertificateIssuerImpl)
00081 {
00082 CACASNWRAPPER_CREATE(CACX509V3GeneralNames, objPDU);
00083 objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00084
00085 DListNode* cur = objPDU->head;
00086 for(unsigned int ii = 0; ii < objPDU->count; ++ii)
00087 {
00088
00089
00090
00091 CACASNWRAPPER_CREATE(CACX509V3GeneralName, objPDU);
00092 ASN1OpenType* data1 = objPDU.Encode((CACX509V3GeneralName*)cur->data);
00093 CPKIFBufferPtr tmpBuf;
00094 if (data1 != NULL)
00095 {
00096 tmpBuf = CPKIFBufferPtr(new CPKIFBuffer(data1->data, data1->numocts));
00097 delete data1;
00098 }
00099 CPKIFGeneralNamePtr tmpGN(new CPKIFGeneralName(tmpBuf));
00100
00101 m_impl->m_gns.push_back(tmpGN);
00102
00103 cur = cur->next;
00104 }
00105
00106 m_impl->m_value = ext;
00107 m_impl->m_extModified = false;
00108 }
00109
00117 CPKIFCertificateIssuer::~CPKIFCertificateIssuer()
00118 {
00119 if(m_impl)
00120 {
00121 delete m_impl;
00122 m_impl = 0;
00123 }
00124 }
00133 const CPKIFOIDPtr CPKIFCertificateIssuer::oid() const
00134 {
00135
00136 static CPKIFOID staticOID(extOID);
00137
00138 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00139 return tmp;
00140 }
00148 void CPKIFCertificateIssuer::CertificateIssuer(
00150 CPKIFGeneralNameList& genNames)
00151 {
00152 genNames.clear();
00153
00154 CPKIFGeneralNameList::const_iterator pos;
00155 CPKIFGeneralNameList::const_iterator end = m_impl->m_gns.end();
00156 for(pos = m_impl->m_gns.begin(); pos != end; ++pos)
00157 {
00158 genNames.push_back(*pos);
00159 }
00160 }
00168 CPKIFBufferPtr CPKIFCertificateIssuer::value() const
00169 {
00170 CPKIFBufferPtr rv = m_impl->m_value;
00171 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00172 {
00173
00174 }
00175
00176 return rv;
00177 }