IssuerAltName.cpp
Go to the documentation of this file.00001
00009 #include "IssuerAltName.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012 #include "GeneralName.h"
00013
00014 #include "ASN1Helper.h"
00015 #include "PKIX1Implicit88.h"
00016 #include "PKIX1Explicit88.h"
00017
00019
00020 struct CPKIFIssuerAltNameImpl
00021 {
00022 CPKIFGeneralNameList m_generalNames;
00023 CPKIFBufferPtr m_value;
00024 bool m_extModified;
00025 };
00026
00028
00029 char CPKIFIssuerAltName::extOID[] = "2.5.29.18";
00030
00038 CPKIFIssuerAltName::CPKIFIssuerAltName()
00039 :m_impl (new CPKIFIssuerAltNameImpl)
00040 {
00041 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00080 CPKIFIssuerAltName::CPKIFIssuerAltName(
00081 const bool& criticality,
00082 const CPKIFBufferPtr& ext)
00083 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFIssuerAltNameImpl)
00084 {
00085 CACASNWRAPPER_CREATE(CACX509V3GeneralNames, objPDU);
00086 CACX509V3GeneralNames* gns = objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00087
00088 DListNode* cur = gns->head;
00089 for(unsigned int ii = 0; ii < gns->count; ++ii)
00090 {
00091
00092
00093
00094 CACASNWRAPPER_CREATE(CACX509V3GeneralName, objPDU);
00095 ASN1OpenType* data1 = objPDU.Encode((CACX509V3GeneralName*)cur->data);
00096 CPKIFBufferPtr tmpBuf;
00097 if (data1 != NULL)
00098 {
00099 tmpBuf = CPKIFBufferPtr(new CPKIFBuffer(data1->data, data1->numocts));
00100 delete data1;
00101 }
00102 CPKIFGeneralNamePtr tmpGN(new CPKIFGeneralName(tmpBuf));
00103 m_impl->m_generalNames.push_back(tmpGN);
00104
00105 cur = cur->next;
00106 }
00107 m_impl->m_value = ext;
00108 m_impl->m_extModified = false;
00109 }
00110
00118 void CPKIFIssuerAltName::GeneralNames(
00120 CPKIFGeneralNameList& genNames) const
00121 {
00122 genNames.clear();
00123
00124 CPKIFGeneralNameList::const_iterator pos;
00125 CPKIFGeneralNameList::const_iterator end = m_impl->m_generalNames.end();
00126 for(pos = m_impl->m_generalNames.begin(); pos != end; ++pos)
00127 {
00128 genNames.push_back(*pos);
00129 }
00130 }
00138 CPKIFIssuerAltName::~CPKIFIssuerAltName()
00139 {
00140 if(m_impl)
00141 {
00142 delete m_impl;
00143 m_impl = 0;
00144 }
00145 }
00146
00154 const CPKIFOIDPtr CPKIFIssuerAltName::oid() const
00155 {
00156
00157 static CPKIFOID staticOID(extOID);
00158
00159 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00160 return tmp;
00161 }
00162
00170 CPKIFBufferPtr CPKIFIssuerAltName::value() const
00171 {
00172 CPKIFBufferPtr rv = m_impl->m_value;
00173 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00174 {
00175
00176 }
00177
00178 return rv;
00179 }