AuthorityInfoAccess.cpp
Go to the documentation of this file.00001
00010 #include "AuthorityInfoAccess.h"
00011 #include "AccessDescription.h"
00012 #include "Buffer.h"
00013 #include "OID.h"
00014 #include "X509Extension.h"
00015
00016 #include "ASN1Helper.h"
00017 #include "PKIX1Implicit88.h"
00018 #include "PKIX1Explicit88.h"
00019
00020 #include <iostream>
00021 #include <sstream>
00022
00023 using namespace std;
00024
00026
00027 struct CPKIFAuthorityInfoAccessImpl
00028 {
00029 CPKIFAccessDescriptionListPtr m_accessDescriptions;
00030 CPKIFBufferPtr m_value;
00031 bool m_extModified;
00032 };
00033
00035
00036 char CPKIFAuthorityInfoAccess::extOID[] = "1.3.6.1.5.5.7.1.1";
00037
00045 CPKIFAuthorityInfoAccess::CPKIFAuthorityInfoAccess()
00046 : m_impl (new CPKIFAuthorityInfoAccessImpl)
00047 {
00048 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00115 CPKIFAuthorityInfoAccess::CPKIFAuthorityInfoAccess(
00117 const bool& criticality,
00119 const CPKIFBufferPtr& ext)
00120 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFAuthorityInfoAccessImpl)
00121 {
00122 CACASNWRAPPER_CREATE(CACX509V3AuthorityInfoAccessSyntax, objPDU);
00123 objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00124
00125 DListNode* cur = objPDU->head;
00126 if(NULL != cur)
00127 {
00128 CPKIFAccessDescriptionListPtr adList(new CPKIFAccessDescriptionList);
00129 m_impl->m_accessDescriptions = adList;
00130 }
00131 while(NULL != cur)
00132 {
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 ASN1OpenType* openType = (ASN1OpenType*)cur->data;
00149
00150 CPKIFBufferPtr tmpBuffer(new CPKIFBuffer(openType->data, openType->numocts));
00151
00152
00153
00154 CPKIFAccessDescriptionPtr ad(new CPKIFAccessDescription(tmpBuffer));
00155 m_impl->m_accessDescriptions->push_back(ad);
00156 cur = cur->next;
00157 }
00158
00159 m_impl->m_value = ext;
00160 m_impl->m_extModified = false;
00161 }
00162
00170 CPKIFAuthorityInfoAccess::~CPKIFAuthorityInfoAccess()
00171 {
00172 if(m_impl)
00173 {
00174 delete m_impl;
00175 m_impl = 0;
00176 }
00177 }
00186 const CPKIFOIDPtr CPKIFAuthorityInfoAccess::oid() const
00187 {
00188
00189 static CPKIFOID staticOID(extOID);
00190
00191 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00192 return tmp;
00193 }
00201 CPKIFAccessDescriptionListPtr CPKIFAuthorityInfoAccess::GetAccessDescriptions() const
00202 {
00203 return m_impl->m_accessDescriptions;
00204 }
00205
00213 CPKIFBufferPtr CPKIFAuthorityInfoAccess::value() const
00214 {
00215 CPKIFBufferPtr rv = m_impl->m_value;
00216 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00217 {
00218
00219 }
00220
00221 return rv;
00222 }
00223
00225 CAC_API std::ostream& operator<<(std::ostream & os, const CPKIFAuthorityInfoAccessPtr & aia)
00226 {
00227 return operator<<(os,*aia);
00228 }
00229
00231 CAC_API std::ostream& operator<<(std::ostream & os, const CPKIFAuthorityInfoAccess& aia)
00232 {
00233
00234 CPKIFAccessDescriptionListPtr adl = aia.GetAccessDescriptions();
00235 if(adl)
00236 {
00237 CPKIFAccessDescription ad;
00238 CPKIFAccessDescriptionList::iterator pos;
00239 CPKIFAccessDescriptionList::iterator end = adl->end();
00240 int count = 1;
00241 for(pos = adl->begin(); pos != end; ++pos)
00242 {
00243 if(count > 1) os << endl;
00244 os << "[" << count <<"]" << "Authority Info Access: " << endl;
00245 CPKIFOIDPtr accessMethod = (*pos)->AccessMethod();
00246 string accessMethodStr(accessMethod->ToString());
00247 if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.2"))
00248 {
00249 accessMethodStr = "CA Issuer (1.3.6.1.5.5.7.48.2)";
00250 }
00251 else if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.5"))
00252 {
00253 accessMethodStr = "CA Repository (1.3.6.1.5.5.7.48.5)";
00254 }
00255 else if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.1"))
00256 {
00257 accessMethodStr = "On-line Certificate Status Protocol (1.3.6.1.5.5.7.48.1)";
00258 }
00259
00260 os << "\tAccess Method: " << accessMethodStr << endl;
00261
00262 CPKIFGeneralNamePtr gn = (*pos)->AccessLocation();
00263 if(gn)
00264 {
00265 os << "\tAccess Location: " << gn;
00266 } else {
00267 os << "\tAccess Location: (null)";
00268 }
00269
00270 count++;
00271 }
00272 }
00273
00274 return os;
00275 }