CRLDistributionPoints.cpp
Go to the documentation of this file.00001
00009 #include "CRLDistributionPoints.h"
00010 #include "CRLDistributionPoint.h"
00011 #include "DistributionPointName.h"
00012
00013 #include "OID.h"
00014 #include "Buffer.h"
00015
00016 #include "ASN1Helper.h"
00017 #include "PKIX1Implicit88.h"
00018 #include "PKIX1Explicit88.h"
00019
00020 #include "ToolkitUtils.h"
00021
00022 #include <iostream>
00023 #include <sstream>
00024
00025 #include <boost/algorithm/string/replace.hpp>
00026 #include <boost/algorithm/string/find_iterator.hpp>
00027
00028 using namespace boost::algorithm;
00029 using namespace std;
00030
00032
00033 struct CPKIFCRLDistributionPointsImpl
00034 {
00035 CPKIFCRLDistributionPointListPtr m_crlDPs;
00036 CPKIFBufferPtr m_value;
00037 bool m_extModified;
00038 };
00039
00041
00042 char CPKIFCRLDistributionPoints::extOID[] = "2.5.29.31";
00043
00052 CPKIFCRLDistributionPoints::CPKIFCRLDistributionPoints()
00053 :m_impl (new CPKIFCRLDistributionPointsImpl)
00054 {
00055 }
00064 CPKIFCRLDistributionPointListPtr CPKIFCRLDistributionPoints::DPs() const
00065 {
00066 return m_impl->m_crlDPs;
00067 }
00068
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00118 CPKIFCRLDistributionPoints::CPKIFCRLDistributionPoints(
00121 const bool& criticality,
00122 const CPKIFBufferPtr& ext)
00123 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFCRLDistributionPointsImpl)
00124 {
00125 CACASNWRAPPER_CREATE(CACX509V3CRLDistributionPoints, objPDU);
00126 objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00127
00128 DListNode* cur = objPDU->head;
00129 if(NULL != cur)
00130 {
00131 CPKIFCRLDistributionPointListPtr piList(new CPKIFCRLDistributionPointList);
00132 m_impl->m_crlDPs = piList;
00133 }
00134 while(NULL != cur)
00135 {
00136
00137
00138
00139
00140
00141 ASN1OpenType* openType = (ASN1OpenType*)cur->data;
00142
00143 CPKIFBufferPtr tempBuffer(new CPKIFBuffer(openType->data, openType->numocts));
00144
00145 CPKIFCRLDistributionPointPtr dp(new CPKIFCRLDistributionPoint(tempBuffer));
00146 m_impl->m_crlDPs->push_back(dp);
00147 cur = cur->next;
00148 }
00149
00150 m_impl->m_value = ext;
00151 m_impl->m_extModified = false;
00152 }
00153
00161 CPKIFCRLDistributionPoints::~CPKIFCRLDistributionPoints()
00162 {
00163 if(m_impl)
00164 {
00165 delete m_impl;
00166 m_impl = 0;
00167 }
00168 }
00177 const CPKIFOIDPtr CPKIFCRLDistributionPoints::oid() const
00178 {
00179
00180 static CPKIFOID staticOID(extOID);
00181
00182 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00183 return tmp;
00184 }
00185
00193 CPKIFBufferPtr CPKIFCRLDistributionPoints::value() const
00194 {
00195 CPKIFBufferPtr rv = m_impl->m_value;
00196 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00197 {
00198
00199 }
00200
00201 return rv;
00202 }
00203
00204
00205 CAC_API std::ostream& operator<<(std::ostream & os, const CPKIFCRLDistributionPointsPtr & extension)
00206 {
00207 return operator<<(os,*extension);
00208 }
00209
00210 CAC_API std::ostream& operator<<(std::ostream & os, const CPKIFCRLDistributionPoints& extension)
00211 {
00212
00213 CPKIFCRLDistributionPointListPtr dps = extension.DPs();
00214 CPKIFCRLDistributionPointList::iterator pos;
00215 CPKIFCRLDistributionPointList::iterator end = dps->end();
00216 int count = 1;
00217 for(pos = dps->begin(); pos != end; ++pos)
00218 {
00219 if(count > 1) os << endl;
00220 os << "[" << count <<"]" << "CRL Distribution Point"<<endl;
00221 CPKIFDistributionPointNamePtr dp = (*pos)->DistributionPoint();
00222 {
00223 os << "\tDistribution Point Name:"<<endl;
00224 CPKIFGeneralNameList gns;
00225 dp->FullName(gns);
00226 ostringstream gnls;
00227 gnls << gns;
00228 os << "\t\tFull Name:" << endl;
00229 string name = gnls.str();
00230 for(split_iterator<string::iterator> line = make_split_iterator(name,first_finder("\n",is_equal()));
00231 line != split_iterator<string::iterator>(); ++line)
00232 {
00233 os << "\t\t\t" << (*line) << endl;
00234 }
00235 }
00236 }
00237 return os;
00238 }
00239
00240